Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions _xtool/llcppsigfetch/dbg/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ type dbgFlags = int
var flags dbgFlags

const (
DbgParse dbgFlags = 1 << iota
DbgFlagAll = DbgParse
DbgParse dbgFlags = 1 << iota
DbgVisitTop
DbgProcess
DbgGetCurFile
DbgMacro
DbgFileType
DbgFlagAll = DbgParse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

相同的问题需要处理~ #245 (comment)

)

func SetDebugParse() {
Expand All @@ -20,3 +25,43 @@ func GetDebugParse() bool {
func SetDebugAll() {
flags = DbgFlagAll
}

func SetDebugVisitTop() {
flags |= DbgVisitTop
}

func GetDebugVisitTop() bool {
return flags&DbgVisitTop != 0
}

func SetDebugProcess() {
flags |= DbgProcess
}

func GetDebugProcess() bool {
return flags&DbgProcess != 0
}

func SetDebugGetCurFile() {
flags |= DbgGetCurFile
}

func GetDebugGetCurFile() bool {
return flags&DbgGetCurFile != 0
}

func SetDebugMacro() {
flags |= DbgMacro
}

func GetDebugMacro() bool {
return flags&DbgMacro != 0
}

func SetDebugFileType() {
flags |= DbgFileType
}

func GetDebugFileType() bool {
return flags&DbgFileType != 0
}
129 changes: 129 additions & 0 deletions _xtool/llcppsigfetch/dbg/debug_test.go
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)
}
})
}
}
47 changes: 46 additions & 1 deletion _xtool/llcppsymg/dbg/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

这个在开发调试的时候可以修改。对于产品发布,或者对于测试输出就禁止了吧。否则log太多对排查问题来说很不方便。这是故意这样做的。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DbgFlagAll的语义就会不明确

Copy link
Contributor Author

@tsingbx tsingbx Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DbgFlagAll的语义就会不明确

怎么不明确了,这个DbgFlagAll是由你控制的一个flag,如果是0,就是不输出log,如果是DbgVisitTop|DbgFileType,就是输出其他,这个DbgFlagAll的意思就是所有要输出的log的意思。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
根据最新的这个提交,在位标志中,0表示“没有标志被设置”。如果 DbgAll 定义为0,就意味着没有一个调试标志被启用,这与“所有标志都开启”的意思完全相反。因此,为了表示所有调试标志都被激活,DbgAll 必须由所有标志的非零值按位“或”得到,而不能简单地用0表示。

Copy link
Contributor Author

@tsingbx tsingbx Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image 根据最新的这个提交,在位标志中,0表示“没有标志被设置”。如果 DbgAll 定义为0,就意味着没有一个调试标志被启用,这与“所有标志都开启”的意思完全相反。因此,为了表示所有调试标志都被激活,DbgAll 必须由所有标志的非零值按位“或”得到,而不能简单地用0表示。

纠结这种小问题没有意义,我也没有那么多时间,被这些小问题困扰,不停的修改。现在的问题是_llcppgtest目录下的demo输出了大量的log,有几千行的log,里面有个demo错误,你需要查找很久,必须下载log文件才能排查出那个demo出错了。而且除非你去调试,没有必要输出这么多log。

Copy link
Contributor Author

@tsingbx tsingbx Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

根据最新的这个提交,在位标志中,0表示“没有标志被设置”。如果 DbgAll 定义为0,就意味着没有一个调试标志被启用,这与“所有标志都开启”的意思完全相反。因此,为了表示所有调试标志都被激活,DbgAll 必须由所有标志的非零值按位“或”得到,而不能简单地用0表示。

这个是故意这样做的,只有在调试的时候,才需要输出log,按照你想输出什么log,DbgFlagAll=flagA|flagB,只输出A和B的log。然后运行的时候添加-v标志,只输出你想要的log。

)

func SetDebugSymbol() {
Expand All @@ -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
}
131 changes: 131 additions & 0 deletions _xtool/llcppsymg/dbg/debug_test.go
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)
}
})
}
}
Loading
Loading