Skip to content

Commit 8d5ac7c

Browse files
committed
add dbg flag for llcppsigfetch, llcppsymg, gogensig to control log output
1 parent 047c15a commit 8d5ac7c

File tree

6 files changed

+537
-4
lines changed

6 files changed

+537
-4
lines changed

_xtool/llcppsigfetch/dbg/debug.go

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ type dbgFlags = int
55
var flags dbgFlags
66

77
const (
8-
DbgParse dbgFlags = 1 << iota
9-
DbgFlagAll = DbgParse
8+
DbgParse dbgFlags = 1 << iota
9+
DbgVisitTop
10+
DbgProcess
11+
DbgGetCurFile
12+
DbgMacro
13+
DbgFileType
14+
DbgFlagAll = DbgParse
1015
)
1116

1217
func SetDebugParse() {
@@ -20,3 +25,43 @@ func GetDebugParse() bool {
2025
func SetDebugAll() {
2126
flags = DbgFlagAll
2227
}
28+
29+
func SetDebugVisitTop() {
30+
flags |= DbgVisitTop
31+
}
32+
33+
func GetDebugVisitTop() bool {
34+
return flags&DbgVisitTop != 0
35+
}
36+
37+
func SetDebugProcess() {
38+
flags |= DbgProcess
39+
}
40+
41+
func GetDebugProcess() bool {
42+
return flags&DbgProcess != 0
43+
}
44+
45+
func SetDebugGetCurFile() {
46+
flags |= DbgGetCurFile
47+
}
48+
49+
func GetDebugGetCurFile() bool {
50+
return flags&DbgGetCurFile != 0
51+
}
52+
53+
func SetDebugMacro() {
54+
flags |= DbgMacro
55+
}
56+
57+
func GetDebugMacro() bool {
58+
return flags&DbgMacro != 0
59+
}
60+
61+
func SetDebugFileType() {
62+
flags |= DbgFileType
63+
}
64+
65+
func GetDebugFileType() bool {
66+
return flags&DbgFileType != 0
67+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package dbg
2+
3+
import "testing"
4+
5+
func TestSetDebugParse(t *testing.T) {
6+
tests := []struct {
7+
name string
8+
}{
9+
{
10+
name: "TestSetDebugParse",
11+
},
12+
}
13+
for _, tt := range tests {
14+
t.Run(tt.name, func(t *testing.T) {
15+
SetDebugParse()
16+
if !GetDebugParse() {
17+
t.Errorf("GetDebugParse() = %v, want %v", false, true)
18+
}
19+
})
20+
}
21+
}
22+
23+
func TestSetDebugAll(t *testing.T) {
24+
tests := []struct {
25+
name string
26+
}{
27+
{
28+
name: "TestSetDebugAll",
29+
},
30+
}
31+
for _, tt := range tests {
32+
t.Run(tt.name, func(t *testing.T) {
33+
SetDebugAll()
34+
if flags != DbgFlagAll {
35+
t.Errorf("flags = %v, want %v", flags, DbgFlagAll)
36+
}
37+
})
38+
}
39+
}
40+
41+
func TestSetDebugVisitTop(t *testing.T) {
42+
tests := []struct {
43+
name string
44+
}{
45+
{
46+
name: "TestSetDebugVisitTop",
47+
},
48+
}
49+
for _, tt := range tests {
50+
t.Run(tt.name, func(t *testing.T) {
51+
SetDebugVisitTop()
52+
if !GetDebugVisitTop() {
53+
t.Errorf("GetDebugVisitTop() = %v, want %v", false, true)
54+
}
55+
})
56+
}
57+
}
58+
59+
func TestSetDebugProcess(t *testing.T) {
60+
tests := []struct {
61+
name string
62+
}{
63+
{
64+
name: "TestSetDebugProcess",
65+
},
66+
}
67+
for _, tt := range tests {
68+
t.Run(tt.name, func(t *testing.T) {
69+
SetDebugProcess()
70+
if !GetDebugProcess() {
71+
t.Errorf("GetDebugProcess() = %v, want %v", false, true)
72+
}
73+
})
74+
}
75+
}
76+
77+
func TestSetDebugGetCurFile(t *testing.T) {
78+
tests := []struct {
79+
name string
80+
}{
81+
{
82+
name: "TestSetDebugGetCurFile",
83+
},
84+
}
85+
for _, tt := range tests {
86+
t.Run(tt.name, func(t *testing.T) {
87+
SetDebugGetCurFile()
88+
if !GetDebugGetCurFile() {
89+
t.Errorf("GetDebugGetCurFile() = %v, want %v", false, true)
90+
}
91+
})
92+
}
93+
}
94+
95+
func TestSetDebugMacro(t *testing.T) {
96+
tests := []struct {
97+
name string
98+
}{
99+
{
100+
name: "TestSetDebugMacro",
101+
},
102+
}
103+
for _, tt := range tests {
104+
t.Run(tt.name, func(t *testing.T) {
105+
SetDebugMacro()
106+
if !GetDebugMacro() {
107+
t.Errorf("GetDebugMacro() = %v, want %v", false, true)
108+
}
109+
})
110+
}
111+
}
112+
113+
func TestSetDebugFileType(t *testing.T) {
114+
tests := []struct {
115+
name string
116+
}{
117+
{
118+
name: "TestSetDebugFileType",
119+
},
120+
}
121+
for _, tt := range tests {
122+
t.Run(tt.name, func(t *testing.T) {
123+
SetDebugFileType()
124+
if !GetDebugFileType() {
125+
t.Errorf("GetDebugFileType() = %v, want %v", false, true)
126+
}
127+
})
128+
}
129+
}

_xtool/llcppsymg/dbg/debug.go

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ var flags dbgFlags
77
const (
88
DbgSymbol dbgFlags = 1 << iota
99
DbgParseIsMethod //print parse.go isMethod debug log info
10-
DbgFlagAll = DbgSymbol | DbgParseIsMethod
10+
DbgEditSymMap //print user edit sym map info
11+
DbgVisitTop //print visitTop
12+
DbgCollectFuncInfo
13+
DbgNewSymbol
14+
DbgFileType
15+
DbgFlagAll = DbgSymbol | DbgParseIsMethod
1116
)
1217

1318
func SetDebugSymbol() {
@@ -25,3 +30,43 @@ func SetDebugParseIsMethod() {
2530
func GetDebugParseIsMethod() bool {
2631
return flags&DbgParseIsMethod != 0
2732
}
33+
34+
func SetDebugEditSymMap() {
35+
flags |= DbgEditSymMap
36+
}
37+
38+
func GetDebugEditSymMap() bool {
39+
return flags&DbgEditSymMap != 0
40+
}
41+
42+
func SetDebugVisitTop() {
43+
flags |= DbgVisitTop
44+
}
45+
46+
func GetDebugVisitTop() bool {
47+
return flags&DbgVisitTop != 0
48+
}
49+
50+
func SetDebugCollectFuncInfo() {
51+
flags |= DbgCollectFuncInfo
52+
}
53+
54+
func GetDebugCollectFuncInfo() bool {
55+
return flags&DbgCollectFuncInfo != 0
56+
}
57+
58+
func SetDebugNewSymbol() {
59+
flags |= DbgNewSymbol
60+
}
61+
62+
func GetDebugNewSymbol() bool {
63+
return flags&DbgNewSymbol != 0
64+
}
65+
66+
func SetDebugFileType() {
67+
flags |= DbgFileType
68+
}
69+
70+
func GetDebugFileType() bool {
71+
return flags&DbgFileType != 0
72+
}

_xtool/llcppsymg/dbg/debug_test.go

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
package dbg
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestSetDebugSymbol(t *testing.T) {
8+
tests := []struct {
9+
name string
10+
}{
11+
{
12+
name: "TestSetDebugSymbol",
13+
},
14+
}
15+
for _, tt := range tests {
16+
t.Run(tt.name, func(t *testing.T) {
17+
SetDebugSymbol()
18+
if !GetDebugSymbol() {
19+
t.Errorf("GetDebugSymbol() = got %v, want %v", false, true)
20+
}
21+
})
22+
}
23+
}
24+
25+
func TestSetDebugParseIsMethod(t *testing.T) {
26+
tests := []struct {
27+
name string
28+
}{
29+
{
30+
name: "TestSetDebugParseIsMethod",
31+
},
32+
}
33+
for _, tt := range tests {
34+
t.Run(tt.name, func(t *testing.T) {
35+
SetDebugParseIsMethod()
36+
if !GetDebugParseIsMethod() {
37+
t.Errorf("GetDebugParseIsMethod() = got %v, want %v", false, true)
38+
}
39+
})
40+
}
41+
}
42+
43+
func TestSetDebugEditSymMap(t *testing.T) {
44+
tests := []struct {
45+
name string
46+
}{
47+
{
48+
name: "TestSetDebugEditSymMap",
49+
},
50+
}
51+
for _, tt := range tests {
52+
t.Run(tt.name, func(t *testing.T) {
53+
SetDebugEditSymMap()
54+
if !GetDebugEditSymMap() {
55+
t.Errorf("GetDebugEditSymMap() = %v, want %v", false, true)
56+
}
57+
})
58+
}
59+
}
60+
61+
func TestSetDebugVisitTop(t *testing.T) {
62+
tests := []struct {
63+
name string
64+
}{
65+
{
66+
"TestSetDebugVisitTop",
67+
},
68+
}
69+
for _, tt := range tests {
70+
t.Run(tt.name, func(t *testing.T) {
71+
SetDebugVisitTop()
72+
if !GetDebugVisitTop() {
73+
t.Errorf("GetDebugVisitTop() = %v, want %v", false, true)
74+
}
75+
})
76+
}
77+
}
78+
79+
func TestSetDebugCollectFuncInfo(t *testing.T) {
80+
tests := []struct {
81+
name string
82+
}{
83+
{
84+
name: "TestSetDebugCollectFuncInfo",
85+
},
86+
}
87+
for _, tt := range tests {
88+
t.Run(tt.name, func(t *testing.T) {
89+
SetDebugCollectFuncInfo()
90+
if !GetDebugCollectFuncInfo() {
91+
t.Errorf("GetDebugCollectFuncInfo() got = %v, want %v", false, true)
92+
}
93+
})
94+
}
95+
}
96+
97+
func TestSetDebugNewSymbol(t *testing.T) {
98+
tests := []struct {
99+
name string
100+
}{
101+
{
102+
name: "TestSetDebugNewSymbol",
103+
},
104+
}
105+
for _, tt := range tests {
106+
t.Run(tt.name, func(t *testing.T) {
107+
SetDebugNewSymbol()
108+
if !GetDebugNewSymbol() {
109+
t.Errorf("GetDebugNewSymbol() = %v, want %v", false, true)
110+
}
111+
})
112+
}
113+
}
114+
115+
func TestSetDebugFileType(t *testing.T) {
116+
tests := []struct {
117+
name string
118+
}{
119+
{
120+
name: "TestSetDebugFileType",
121+
},
122+
}
123+
for _, tt := range tests {
124+
t.Run(tt.name, func(t *testing.T) {
125+
SetDebugFileType()
126+
if !GetDebugFileType() {
127+
t.Errorf("GetDebugFileType() = %v, want %v", false, true)
128+
}
129+
})
130+
}
131+
}

0 commit comments

Comments
 (0)