-
Notifications
You must be signed in to change notification settings - Fork 11
add dbg flag for llcppsigfetch, llcppsymg, gogensig to control log #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| package dbg | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestSetDebugParse(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugParse", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugParse() | ||
| if !GetDebugParse() { | ||
| t.Errorf("GetDebugParse() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugAll(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugAll", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugAll() | ||
| if flags != DbgFlagAll { | ||
| t.Errorf("flags = %v, want %v", flags, DbgFlagAll) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugVisitTop(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugVisitTop", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugVisitTop() | ||
| if !GetDebugVisitTop() { | ||
| t.Errorf("GetDebugVisitTop() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugProcess(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugProcess", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugProcess() | ||
| if !GetDebugProcess() { | ||
| t.Errorf("GetDebugProcess() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugGetCurFile(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugGetCurFile", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugGetCurFile() | ||
| if !GetDebugGetCurFile() { | ||
| t.Errorf("GetDebugGetCurFile() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugMacro(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugMacro", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugMacro() | ||
| if !GetDebugMacro() { | ||
| t.Errorf("GetDebugMacro() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugFileType(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugFileType", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugFileType() | ||
| if !GetDebugFileType() { | ||
| t.Errorf("GetDebugFileType() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,12 @@ var flags dbgFlags | |
| const ( | ||
| DbgSymbol dbgFlags = 1 << iota | ||
| DbgParseIsMethod //print parse.go isMethod debug log info | ||
| DbgFlagAll = DbgSymbol | DbgParseIsMethod | ||
| DbgEditSymMap //print user edit sym map info | ||
| DbgVisitTop //print visitTop | ||
| DbgCollectFuncInfo | ||
| DbgNewSymbol | ||
| DbgFileType | ||
| DbgFlagAll = DbgSymbol | DbgParseIsMethod | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 之前的DbgFlagAll = DbgSymbol | DbgParseIsMethod 是因为只有两个flag,现在的DbgFlagAll其实就不应该这么写了,而是应该组合前面所有的Flag。 https://github.com/goplus/gogen/blob/ba6f4f0b5b8a936aac433e2b202a9de05ab0915a/package.go#L30C1-L40C2
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
这个在开发调试的时候可以修改。对于产品发布,或者对于测试输出就禁止了吧。否则log太多对排查问题来说很不方便。这是故意这样做的。
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DbgFlagAll的语义就会不明确
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
怎么不明确了,这个DbgFlagAll是由你控制的一个flag,如果是0,就是不输出log,如果是DbgVisitTop|DbgFileType,就是输出其他,这个DbgFlagAll的意思就是所有要输出的log的意思。
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
这个是故意这样做的,只有在调试的时候,才需要输出log,按照你想输出什么log,DbgFlagAll=flagA|flagB,只输出A和B的log。然后运行的时候添加-v标志,只输出你想要的log。 |
||
| ) | ||
|
|
||
| func SetDebugSymbol() { | ||
|
|
@@ -25,3 +30,43 @@ func SetDebugParseIsMethod() { | |
| func GetDebugParseIsMethod() bool { | ||
| return flags&DbgParseIsMethod != 0 | ||
| } | ||
|
|
||
| func SetDebugEditSymMap() { | ||
| flags |= DbgEditSymMap | ||
| } | ||
|
|
||
| func GetDebugEditSymMap() bool { | ||
| return flags&DbgEditSymMap != 0 | ||
| } | ||
|
|
||
| func SetDebugVisitTop() { | ||
| flags |= DbgVisitTop | ||
| } | ||
|
|
||
| func GetDebugVisitTop() bool { | ||
| return flags&DbgVisitTop != 0 | ||
| } | ||
|
|
||
| func SetDebugCollectFuncInfo() { | ||
| flags |= DbgCollectFuncInfo | ||
| } | ||
|
|
||
| func GetDebugCollectFuncInfo() bool { | ||
| return flags&DbgCollectFuncInfo != 0 | ||
| } | ||
|
|
||
| func SetDebugNewSymbol() { | ||
| flags |= DbgNewSymbol | ||
| } | ||
|
|
||
| func GetDebugNewSymbol() bool { | ||
| return flags&DbgNewSymbol != 0 | ||
| } | ||
|
|
||
| func SetDebugFileType() { | ||
| flags |= DbgFileType | ||
| } | ||
|
|
||
| func GetDebugFileType() bool { | ||
| return flags&DbgFileType != 0 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| package dbg | ||
|
|
||
| import ( | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestSetDebugSymbol(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugSymbol", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugSymbol() | ||
| if !GetDebugSymbol() { | ||
| t.Errorf("GetDebugSymbol() = got %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugParseIsMethod(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugParseIsMethod", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugParseIsMethod() | ||
| if !GetDebugParseIsMethod() { | ||
| t.Errorf("GetDebugParseIsMethod() = got %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugEditSymMap(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugEditSymMap", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugEditSymMap() | ||
| if !GetDebugEditSymMap() { | ||
| t.Errorf("GetDebugEditSymMap() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugVisitTop(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| "TestSetDebugVisitTop", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugVisitTop() | ||
| if !GetDebugVisitTop() { | ||
| t.Errorf("GetDebugVisitTop() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugCollectFuncInfo(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugCollectFuncInfo", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugCollectFuncInfo() | ||
| if !GetDebugCollectFuncInfo() { | ||
| t.Errorf("GetDebugCollectFuncInfo() got = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugNewSymbol(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugNewSymbol", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugNewSymbol() | ||
| if !GetDebugNewSymbol() { | ||
| t.Errorf("GetDebugNewSymbol() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetDebugFileType(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| }{ | ||
| { | ||
| name: "TestSetDebugFileType", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| SetDebugFileType() | ||
| if !GetDebugFileType() { | ||
| t.Errorf("GetDebugFileType() = %v, want %v", false, true) | ||
| } | ||
| }) | ||
| } | ||
| } |


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
相同的问题需要处理~ #245 (comment)