Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Zhou Yaochen
goActuator
Commits
420350df
Commit
420350df
authored
Nov 12, 2021
by
Zhou Yaochen
Browse files
update ignore
parent
fc1f6363
Changes
723
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
403 deletions
+0
-403
pkg/mod/cloud.google.com/go@v0.34.0/cmd/go-cloud-debug-agent/internal/debug/dwarf/type_test.go
...md/go-cloud-debug-agent/internal/debug/dwarf/type_test.go
+0
-122
pkg/mod/cloud.google.com/go@v0.34.0/cmd/go-cloud-debug-agent/internal/debug/dwarf/typeunit.go
...cmd/go-cloud-debug-agent/internal/debug/dwarf/typeunit.go
+0
-181
pkg/mod/cloud.google.com/go@v0.34.0/cmd/go-cloud-debug-agent/internal/debug/dwarf/unit.go
...4.0/cmd/go-cloud-debug-agent/internal/debug/dwarf/unit.go
+0
-100
No files found.
Too many changes to show.
To preserve performance only
723 of 723+
files are displayed.
Plain diff
Email patch
pkg/mod/cloud.google.com/go@v0.34.0/cmd/go-cloud-debug-agent/internal/debug/dwarf/type_test.go
deleted
100644 → 0
View file @
fc1f6363
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
dwarf_test
import
(
"testing"
.
"cloud.google.com/go/cmd/go-cloud-debug-agent/internal/debug/dwarf"
"cloud.google.com/go/cmd/go-cloud-debug-agent/internal/debug/elf"
)
var
typedefTests
=
map
[
string
]
string
{
"t_ptr_volatile_int"
:
"*volatile int"
,
"t_ptr_const_char"
:
"*const char"
,
"t_long"
:
"long int"
,
"t_ushort"
:
"short unsigned int"
,
"t_func_int_of_float_double"
:
"func(float, double) int"
,
"t_ptr_func_int_of_float_double"
:
"*func(float, double) int"
,
"t_ptr_func_int_of_float_complex"
:
"*func(complex float) int"
,
"t_ptr_func_int_of_double_complex"
:
"*func(complex double) int"
,
"t_ptr_func_int_of_long_double_complex"
:
"*func(complex long double) int"
,
"t_func_ptr_int_of_char_schar_uchar"
:
"func(char, signed char, unsigned char) *int"
,
"t_func_void_of_char"
:
"func(char) void"
,
"t_func_void_of_void"
:
"func() void"
,
"t_func_void_of_ptr_char_dots"
:
"func(*char, ...) void"
,
"t_my_struct"
:
"struct my_struct {vi volatile int@0; x char@4 : 1@7; y int@4 : 4@27; z [0]int@8; array [40]long long int@8; zz [0]int@328}"
,
"t_my_struct1"
:
"struct my_struct1 {zz [1]int@0}"
,
"t_my_union"
:
"union my_union {vi volatile int@0; x char@0 : 1@7; y int@0 : 4@28; array [40]long long int@0}"
,
"t_my_enum"
:
"enum my_enum {e1=1; e2=2; e3=-5; e4=1000000000000000}"
,
"t_my_list"
:
"struct list {val short int@0; next *t_my_list@8}"
,
"t_my_tree"
:
"struct tree {left *struct tree@0; right *struct tree@8; val long long unsigned int@16}"
,
}
func
elfData
(
t
*
testing
.
T
,
name
string
)
*
Data
{
f
,
err
:=
elf
.
Open
(
name
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
d
,
err
:=
f
.
DWARF
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
d
}
func
TestTypedefsELF
(
t
*
testing
.
T
)
{
testTypedefs
(
t
,
elfData
(
t
,
"testdata/typedef.elf"
),
"elf"
)
}
func
TestTypedefsELFDwarf4
(
t
*
testing
.
T
)
{
testTypedefs
(
t
,
elfData
(
t
,
"testdata/typedef.elf4"
),
"elf"
)
}
func
testTypedefs
(
t
*
testing
.
T
,
d
*
Data
,
kind
string
)
{
r
:=
d
.
Reader
()
seen
:=
make
(
map
[
string
]
bool
)
for
{
e
,
err
:=
r
.
Next
()
if
err
!=
nil
{
t
.
Fatal
(
"r.Next:"
,
err
)
}
if
e
==
nil
{
break
}
if
e
.
Tag
==
TagTypedef
{
typ
,
err
:=
d
.
Type
(
e
.
Offset
)
if
err
!=
nil
{
t
.
Fatal
(
"d.Type:"
,
err
)
}
t1
:=
typ
.
(
*
TypedefType
)
var
typstr
string
if
ts
,
ok
:=
t1
.
Type
.
(
*
StructType
);
ok
{
typstr
=
ts
.
Defn
()
}
else
{
typstr
=
t1
.
Type
.
String
()
}
if
want
,
ok
:=
typedefTests
[
t1
.
Name
];
ok
{
if
seen
[
t1
.
Name
]
{
t
.
Errorf
(
"multiple definitions for %s"
,
t1
.
Name
)
}
seen
[
t1
.
Name
]
=
true
if
typstr
!=
want
{
t
.
Errorf
(
"%s:
\n\t
have %s
\n\t
want %s"
,
t1
.
Name
,
typstr
,
want
)
}
}
}
if
e
.
Tag
!=
TagCompileUnit
{
r
.
SkipChildren
()
}
}
for
k
:=
range
typedefTests
{
if
!
seen
[
k
]
{
t
.
Errorf
(
"missing %s"
,
k
)
}
}
}
func
TestTypeForNonTypeEntry
(
t
*
testing
.
T
)
{
d
:=
elfData
(
t
,
"testdata/typedef.elf"
)
// The returned entry will be a Subprogram.
ent
,
err
:=
d
.
LookupFunction
(
"main"
)
if
err
!=
nil
{
t
.
Fatal
(
"d.LookupFunction:"
,
err
)
}
_
,
err
=
d
.
Type
(
ent
.
Offset
)
if
err
==
nil
{
t
.
Fatal
(
"nil error for unreadable entry"
)
}
}
pkg/mod/cloud.google.com/go@v0.34.0/cmd/go-cloud-debug-agent/internal/debug/dwarf/typeunit.go
deleted
100644 → 0
View file @
fc1f6363
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
dwarf
import
(
"fmt"
"strconv"
)
// Parse the type units stored in a DWARF4 .debug_types section. Each
// type unit defines a single primary type and an 8-byte signature.
// Other sections may then use formRefSig8 to refer to the type.
// The typeUnit format is a single type with a signature. It holds
// the same data as a compilation unit.
type
typeUnit
struct
{
unit
toff
Offset
// Offset to signature type within data.
name
string
// Name of .debug_type section.
cache
Type
// Cache the type, nil to start.
}
// Parse a .debug_types section.
func
(
d
*
Data
)
parseTypes
(
name
string
,
types
[]
byte
)
error
{
b
:=
makeBuf
(
d
,
unknownFormat
{},
name
,
0
,
types
)
for
len
(
b
.
data
)
>
0
{
base
:=
b
.
off
dwarf64
:=
false
n
:=
b
.
uint32
()
if
n
==
0xffffffff
{
n64
:=
b
.
uint64
()
if
n64
!=
uint64
(
uint32
(
n64
))
{
b
.
error
(
"type unit length overflow"
)
return
b
.
err
}
n
=
uint32
(
n64
)
dwarf64
=
true
}
hdroff
:=
b
.
off
vers
:=
b
.
uint16
()
if
vers
!=
4
{
b
.
error
(
"unsupported DWARF version "
+
strconv
.
Itoa
(
int
(
vers
)))
return
b
.
err
}
var
ao
uint32
if
!
dwarf64
{
ao
=
b
.
uint32
()
}
else
{
ao64
:=
b
.
uint64
()
if
ao64
!=
uint64
(
uint32
(
ao64
))
{
b
.
error
(
"type unit abbrev offset overflow"
)
return
b
.
err
}
ao
=
uint32
(
ao64
)
}
atable
,
err
:=
d
.
parseAbbrev
(
ao
)
if
err
!=
nil
{
return
err
}
asize
:=
b
.
uint8
()
sig
:=
b
.
uint64
()
var
toff
uint32
if
!
dwarf64
{
toff
=
b
.
uint32
()
}
else
{
to64
:=
b
.
uint64
()
if
to64
!=
uint64
(
uint32
(
to64
))
{
b
.
error
(
"type unit type offset overflow"
)
return
b
.
err
}
toff
=
uint32
(
to64
)
}
boff
:=
b
.
off
d
.
typeSigs
[
sig
]
=
&
typeUnit
{
unit
:
unit
{
base
:
base
,
off
:
boff
,
data
:
b
.
bytes
(
int
(
Offset
(
n
)
-
(
b
.
off
-
hdroff
))),
atable
:
atable
,
asize
:
int
(
asize
),
vers
:
int
(
vers
),
is64
:
dwarf64
,
},
toff
:
Offset
(
toff
),
name
:
name
,
}
if
b
.
err
!=
nil
{
return
b
.
err
}
}
return
nil
}
// Return the type for a type signature.
func
(
d
*
Data
)
sigToType
(
sig
uint64
)
(
Type
,
error
)
{
tu
:=
d
.
typeSigs
[
sig
]
if
tu
==
nil
{
return
nil
,
fmt
.
Errorf
(
"no type unit with signature %v"
,
sig
)
}
if
tu
.
cache
!=
nil
{
return
tu
.
cache
,
nil
}
b
:=
makeBuf
(
d
,
tu
,
tu
.
name
,
tu
.
off
,
tu
.
data
)
r
:=
&
typeUnitReader
{
d
:
d
,
tu
:
tu
,
b
:
b
}
t
,
err
:=
d
.
readType
(
tu
.
name
,
r
,
Offset
(
tu
.
toff
),
make
(
map
[
Offset
]
Type
))
if
err
!=
nil
{
return
nil
,
err
}
tu
.
cache
=
t
return
t
,
nil
}
// typeUnitReader is a typeReader for a tagTypeUnit.
type
typeUnitReader
struct
{
d
*
Data
tu
*
typeUnit
b
buf
err
error
}
// Seek to a new position in the type unit.
func
(
tur
*
typeUnitReader
)
Seek
(
off
Offset
)
{
tur
.
err
=
nil
doff
:=
off
-
tur
.
tu
.
off
if
doff
<
0
||
doff
>=
Offset
(
len
(
tur
.
tu
.
data
))
{
tur
.
err
=
fmt
.
Errorf
(
"%s: offset %d out of range; max %d"
,
tur
.
tu
.
name
,
doff
,
len
(
tur
.
tu
.
data
))
return
}
tur
.
b
=
makeBuf
(
tur
.
d
,
tur
.
tu
,
tur
.
tu
.
name
,
off
,
tur
.
tu
.
data
[
doff
:
])
}
// AddressSize returns the size in bytes of addresses in the current type unit.
func
(
tur
*
typeUnitReader
)
AddressSize
()
int
{
return
tur
.
tu
.
unit
.
asize
}
// Next reads the next Entry from the type unit.
func
(
tur
*
typeUnitReader
)
Next
()
(
*
Entry
,
error
)
{
if
tur
.
err
!=
nil
{
return
nil
,
tur
.
err
}
if
len
(
tur
.
tu
.
data
)
==
0
{
return
nil
,
nil
}
e
:=
tur
.
b
.
entry
(
tur
.
tu
.
atable
,
tur
.
tu
.
base
)
if
tur
.
b
.
err
!=
nil
{
tur
.
err
=
tur
.
b
.
err
return
nil
,
tur
.
err
}
return
e
,
nil
}
// clone returns a new reader for the type unit.
func
(
tur
*
typeUnitReader
)
clone
()
typeReader
{
return
&
typeUnitReader
{
d
:
tur
.
d
,
tu
:
tur
.
tu
,
b
:
makeBuf
(
tur
.
d
,
tur
.
tu
,
tur
.
tu
.
name
,
tur
.
tu
.
off
,
tur
.
tu
.
data
),
}
}
// offset returns the current offset.
func
(
tur
*
typeUnitReader
)
offset
()
Offset
{
return
tur
.
b
.
off
}
pkg/mod/cloud.google.com/go@v0.34.0/cmd/go-cloud-debug-agent/internal/debug/dwarf/unit.go
deleted
100644 → 0
View file @
fc1f6363
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
dwarf
import
"strconv"
// DWARF debug info is split into a sequence of compilation units.
// Each unit has its own abbreviation table and address size.
type
unit
struct
{
base
Offset
// byte offset of header within the aggregate info
off
Offset
// byte offset of data within the aggregate info
data
[]
byte
atable
abbrevTable
asize
int
vers
int
is64
bool
// True for 64-bit DWARF format
}
// Implement the dataFormat interface.
func
(
u
*
unit
)
version
()
int
{
return
u
.
vers
}
func
(
u
*
unit
)
dwarf64
()
(
bool
,
bool
)
{
return
u
.
is64
,
true
}
func
(
u
*
unit
)
addrsize
()
int
{
return
u
.
asize
}
func
(
d
*
Data
)
parseUnits
()
([]
unit
,
error
)
{
// Count units.
nunit
:=
0
b
:=
makeBuf
(
d
,
unknownFormat
{},
"info"
,
0
,
d
.
info
)
for
len
(
b
.
data
)
>
0
{
len
:=
b
.
uint32
()
if
len
==
0xffffffff
{
len64
:=
b
.
uint64
()
if
len64
!=
uint64
(
uint32
(
len64
))
{
b
.
error
(
"unit length overflow"
)
break
}
len
=
uint32
(
len64
)
}
b
.
skip
(
int
(
len
))
nunit
++
}
if
b
.
err
!=
nil
{
return
nil
,
b
.
err
}
// Again, this time writing them down.
b
=
makeBuf
(
d
,
unknownFormat
{},
"info"
,
0
,
d
.
info
)
units
:=
make
([]
unit
,
nunit
)
for
i
:=
range
units
{
u
:=
&
units
[
i
]
u
.
base
=
b
.
off
n
:=
b
.
uint32
()
if
n
==
0xffffffff
{
u
.
is64
=
true
n
=
uint32
(
b
.
uint64
())
}
vers
:=
b
.
uint16
()
if
vers
!=
2
&&
vers
!=
3
&&
vers
!=
4
{
b
.
error
(
"unsupported DWARF version "
+
strconv
.
Itoa
(
int
(
vers
)))
break
}
u
.
vers
=
int
(
vers
)
atable
,
err
:=
d
.
parseAbbrev
(
b
.
uint32
())
if
err
!=
nil
{
if
b
.
err
==
nil
{
b
.
err
=
err
}
break
}
u
.
atable
=
atable
u
.
asize
=
int
(
b
.
uint8
())
u
.
off
=
b
.
off
u
.
data
=
b
.
bytes
(
int
(
n
-
(
2
+
4
+
1
)))
}
if
b
.
err
!=
nil
{
return
nil
,
b
.
err
}
return
units
,
nil
}
Prev
1
…
33
34
35
36
37
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment