diff --git a/_xtool/llcppsigfetch/dbg/debug.go b/_xtool/llcppsigfetch/dbg/debug.go index 5d74bbc2..9c39df88 100644 --- a/_xtool/llcppsigfetch/dbg/debug.go +++ b/_xtool/llcppsigfetch/dbg/debug.go @@ -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 = 0 ) func SetDebugParse() { @@ -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 +} diff --git a/_xtool/llcppsigfetch/dbg/debug_test.go b/_xtool/llcppsigfetch/dbg/debug_test.go new file mode 100644 index 00000000..2997d708 --- /dev/null +++ b/_xtool/llcppsigfetch/dbg/debug_test.go @@ -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) + } + }) + } +} diff --git a/_xtool/llcppsigfetch/llcppsigfetch.go b/_xtool/llcppsigfetch/llcppsigfetch.go index 24d4f0be..1441d882 100644 --- a/_xtool/llcppsigfetch/llcppsigfetch.go +++ b/_xtool/llcppsigfetch/llcppsigfetch.go @@ -43,9 +43,6 @@ func main() { printUsage() return } - if ags.VerboseSigfetchParse { - dbg.SetDebugParse() - } if ags.Verbose { dbg.SetDebugAll() } diff --git a/_xtool/llcppsymg/args/args.go b/_xtool/llcppsymg/args/args.go index db83ea03..968bcb09 100644 --- a/_xtool/llcppsymg/args/args.go +++ b/_xtool/llcppsymg/args/args.go @@ -6,12 +6,10 @@ import ( ) type Args struct { - Help bool - Verbose bool - VerboseSigfetchParse bool //-vsp llcppsigfetch parse.go - VerboseParseIsMethod bool //-vpim - UseStdin bool - CfgFile string + Help bool + Verbose bool + UseStdin bool + CfgFile string } func ParseArgs(args []string, defaultCfgFile string, swflags map[string]bool) (*Args, []string) { @@ -27,12 +25,6 @@ func ParseArgs(args []string, defaultCfgFile string, swflags map[string]bool) (* case "-v": result.Verbose = true continue - case "-vpim": - result.VerboseParseIsMethod = true - continue - case "-vsp": - result.VerboseSigfetchParse = true - continue case "-": result.UseStdin = true continue diff --git a/_xtool/llcppsymg/dbg/debug.go b/_xtool/llcppsymg/dbg/debug.go index de27a3ad..21da6612 100644 --- a/_xtool/llcppsymg/dbg/debug.go +++ b/_xtool/llcppsymg/dbg/debug.go @@ -7,9 +7,18 @@ 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 = 0 ) +func SetDebugAll() { + flags = DbgFlagAll +} + func SetDebugSymbol() { flags |= DbgSymbol } @@ -25,3 +34,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 +} diff --git a/_xtool/llcppsymg/dbg/debug_test.go b/_xtool/llcppsymg/dbg/debug_test.go new file mode 100644 index 00000000..82e31dcb --- /dev/null +++ b/_xtool/llcppsymg/dbg/debug_test.go @@ -0,0 +1,149 @@ +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) + } + }) + } +} + +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 dbgFlags != DbgFlagAll { + t.Errorf("dbgFlags = %v, want %v", dbgFlags, DbgFlagAll) + } + }) + } +} \ No newline at end of file diff --git a/_xtool/llcppsymg/llcppsymg.go b/_xtool/llcppsymg/llcppsymg.go index 18836ba7..fd229f9b 100644 --- a/_xtool/llcppsymg/llcppsymg.go +++ b/_xtool/llcppsymg/llcppsymg.go @@ -51,12 +51,8 @@ func main() { check(err) defer conf.Delete() - if ags.VerboseParseIsMethod { - dbg.SetDebugParseIsMethod() - } - if ags.Verbose { - dbg.SetDebugSymbol() + dbg.SetDebugAll() if ags.UseStdin { fmt.Println("Config From Stdin") } else { diff --git a/cmd/gogensig/dbg/debug.go b/cmd/gogensig/dbg/debug.go index b920fc93..dc488b5f 100644 --- a/cmd/gogensig/dbg/debug.go +++ b/cmd/gogensig/dbg/debug.go @@ -8,7 +8,11 @@ const ( DbgSymbolNotFound dbgFlags = 1 << iota DbgError // print when error ocur DbgLog // print log info - DbgFlagAll = 0 | DbgError | DbgLog + DbgSetCurFile + DbgNew + DbgWrite + DbgUnmarshalling + DbgFlagAll = 0 ) func SetDebugSymbolNotFound() { @@ -38,3 +42,35 @@ func GetDebugLog() bool { func SetDebugAll() { flags = DbgFlagAll } + +func SetDebugSetCurFile() { + flags |= DbgSetCurFile +} + +func GetDebugSetCurFile() bool { + return flags&DbgSetCurFile != 0 +} + +func SetDebugNew() { + flags |= DbgNew +} + +func GetDebugNew() bool { + return flags&DbgNew != 0 +} + +func SetDebugWrite() { + flags |= DbgWrite +} + +func GetDebugWrite() bool { + return flags&DbgWrite != 0 +} + +func SetDebugUnmarshalling() { + flags |= DbgUnmarshalling +} + +func GetDebugUnmarshalling() bool { + return flags&DbgUnmarshalling != 0 +} diff --git a/cmd/gogensig/dbg/debug_test.go b/cmd/gogensig/dbg/debug_test.go new file mode 100644 index 00000000..dd6672cc --- /dev/null +++ b/cmd/gogensig/dbg/debug_test.go @@ -0,0 +1,147 @@ +package dbg + +import ( + "testing" +) + +func TestSetDebugSymbolNotFound(t *testing.T) { + tests := []struct { + name string + }{{ + "TestSetDebugSymbolNotFound", + }} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + SetDebugSymbolNotFound() + if !GetDebugSymbolNotFound() { + t.Errorf("GetDebugSymbolNotFound() = %v, want %v", false, true) + } + }) + } +} + +func TestSetDebugError(t *testing.T) { + tests := []struct { + name string + }{ + { + "TestSetDebugError", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + SetDebugError() + if !GetDebugError() { + t.Errorf("GetDebugError() = %v, want %v", false, true) + } + }) + } +} + +func TestSetDebugLog(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "TestSetDebugLog", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + SetDebugLog() + if !GetDebugLog() { + t.Errorf("GetDebugLog() = %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 TestSetDebugSetCurFile(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "TestSetDebugSetCurFile", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + SetDebugSetCurFile() + if !GetDebugSetCurFile() { + t.Errorf("GetDebugSetCurFile() = %v, want %v", false, true) + } + }) + } +} + +func TestSetDebugNew(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "TestSetDebugNew", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + SetDebugNew() + if !GetDebugNew() { + t.Errorf("GetDebugNew() = %v, want %v", false, true) + } + }) + } +} + +func TestSetDebugWrite(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "TestSetDebugWrite", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + SetDebugWrite() + if !GetDebugWrite() { + t.Errorf("GetDebugWrite() = %v, want %v", false, true) + } + }) + } +} + +func TestSetDebugUnmarshalling(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "TestSetDebugUnmarshalling", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + SetDebugUnmarshalling() + if !GetDebugUnmarshalling() { + t.Errorf("GetDebugUnmarshalling() = %v, want %v", false, true) + } + }) + } +} diff --git a/cmd/gogensig/unmarshal/unmarshal.go b/cmd/gogensig/unmarshal/unmarshal.go index 578237cb..9c9d1310 100644 --- a/cmd/gogensig/unmarshal/unmarshal.go +++ b/cmd/gogensig/unmarshal/unmarshal.go @@ -667,7 +667,7 @@ func File(data []byte) (ast.Node, error) { for i, declData := range fileData.Decls { declNode, err := Node(declData) if err != nil { - fmt.Fprintf(os.Stderr, "error unmarshalling %d Decl in File: %v\n%s\n", i, err, string(declData)) + fmt.Fprintf(os.Stderr, "error unmarshalling %d Decl err: %v\n", i, err) continue } decl, ok := declNode.(ast.Decl)