Skip to content

Commit 333ba03

Browse files
committed
set all DbgFlagAll to 0
1 parent 8d5ac7c commit 333ba03

File tree

9 files changed

+73
-24
lines changed

9 files changed

+73
-24
lines changed

_xtool/llcppsigfetch/dbg/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const (
1111
DbgGetCurFile
1212
DbgMacro
1313
DbgFileType
14-
DbgFlagAll = DbgParse
14+
DbgFlagAll = 0
1515
)
1616

1717
func SetDebugParse() {

_xtool/llcppsigfetch/llcppsigfetch.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ func main() {
4343
printUsage()
4444
return
4545
}
46-
if ags.VerboseSigfetchParse {
47-
dbg.SetDebugParse()
48-
}
4946
if ags.Verbose {
5047
dbg.SetDebugAll()
5148
}

_xtool/llcppsymg/args/args.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ import (
66
)
77

88
type Args struct {
9-
Help bool
10-
Verbose bool
11-
VerboseSigfetchParse bool //-vsp llcppsigfetch parse.go
12-
VerboseParseIsMethod bool //-vpim
13-
UseStdin bool
14-
CfgFile string
9+
Help bool
10+
Verbose bool
11+
UseStdin bool
12+
CfgFile string
1513
}
1614

1715
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) (*
2725
case "-v":
2826
result.Verbose = true
2927
continue
30-
case "-vpim":
31-
result.VerboseParseIsMethod = true
32-
continue
33-
case "-vsp":
34-
result.VerboseSigfetchParse = true
35-
continue
3628
case "-":
3729
result.UseStdin = true
3830
continue

_xtool/llcppsymg/dbg/debug.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ const (
1212
DbgCollectFuncInfo
1313
DbgNewSymbol
1414
DbgFileType
15-
DbgFlagAll = DbgSymbol | DbgParseIsMethod
15+
DbgFlagAll = 0
1616
)
1717

18+
func SetDebugAll() {
19+
flags = DbgFlagAll
20+
}
21+
1822
func SetDebugSymbol() {
1923
flags |= DbgSymbol
2024
}

_xtool/llcppsymg/dbg/debug_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,21 @@ func TestSetDebugFileType(t *testing.T) {
129129
})
130130
}
131131
}
132+
133+
func TestSetDebugAll(t *testing.T) {
134+
tests := []struct {
135+
name string
136+
}{
137+
{
138+
name: "TestSetDebugAll",
139+
}
140+
}
141+
for _, tt := range tests {
142+
t.Run(tt.name, func(t *testing.T) {
143+
SetDebugAll()
144+
if dbgFlags != DbgFlagAll {
145+
t.Errorf("dbgFlags = %v, want %v", dbgFlags, DbgFlagAll)
146+
}
147+
})
148+
}
149+
}

_xtool/llcppsymg/llcppsymg.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ func main() {
5151
check(err)
5252
defer conf.Delete()
5353

54-
if ags.VerboseParseIsMethod {
55-
dbg.SetDebugParseIsMethod()
56-
}
57-
5854
if ags.Verbose {
59-
dbg.SetDebugSymbol()
55+
dbg.SetDebugAll()
6056
if ags.UseStdin {
6157
fmt.Println("Config From Stdin")
6258
} else {

cmd/gogensig/dbg/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const (
1212
DbgNew
1313
DbgWrite
1414
DbgUnmarshalling
15-
DbgFlagAll = 0 | DbgError | DbgLog
15+
DbgFlagAll = 0
1616
)
1717

1818
func SetDebugSymbolNotFound() {

cmd/gogensig/unmarshal/unmarshal.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package unmarshal
33
import (
44
"encoding/json"
55
"fmt"
6+
"log"
67
"os"
78
"reflect"
89

910
"github.com/goplus/llcppg/ast"
11+
"github.com/goplus/llcppg/cmd/gogensig/dbg"
1012
"github.com/goplus/llcppg/llcppg"
1113
)
1214

@@ -667,7 +669,10 @@ func File(data []byte) (ast.Node, error) {
667669
for i, declData := range fileData.Decls {
668670
declNode, err := Node(declData)
669671
if err != nil {
670-
fmt.Fprintf(os.Stderr, "error unmarshalling %d Decl in File: %v\n%s\n", i, err, string(declData))
672+
fmt.Fprintf(os.Stderr, "error unmarshalling %d Decl err: %v\n", i, err)
673+
if dbg.GetDebugUnmarshalling() {
674+
log.Println(string(declData))
675+
}
671676
continue
672677
}
673678
decl, ok := declNode.(ast.Decl)

cmd/gogensig/unmarshal/unmarshal_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ package unmarshal_test
22

33
import (
44
"encoding/json"
5+
"fmt"
6+
"os"
7+
"os/exec"
58
"strings"
69
"testing"
710

811
"github.com/goplus/llcppg/ast"
12+
"github.com/goplus/llcppg/cmd/gogensig/dbg"
913
"github.com/goplus/llcppg/cmd/gogensig/unmarshal"
1014
"github.com/goplus/llcppg/llcppg"
1115
)
@@ -1799,3 +1803,36 @@ func TestUnmarshalPkgErrors(t *testing.T) {
17991803
})
18001804
}
18011805
}
1806+
1807+
func TestTestUnmarshalLog(t *testing.T) {
1808+
dbg.SetDebugUnmarshalling()
1809+
tmpDir, err := os.MkdirTemp(os.TempDir(), "isl")
1810+
if err != nil {
1811+
t.Error(err)
1812+
}
1813+
defer func() {
1814+
err = os.RemoveAll(tmpDir)
1815+
if err != nil {
1816+
t.Error(err)
1817+
}
1818+
}()
1819+
runCommandInDir(tmpDir, func(err error) {
1820+
runCommandInDir(tmpDir, func(err error) {
1821+
runCommandInDir(tmpDir, func(err error) {
1822+
fmt.Println("done")
1823+
}, "llcppg")
1824+
}, "llcppcfg", "gettext")
1825+
}, "go", "mod", "init", "gettext")
1826+
}
1827+
1828+
func runCommandInDir(dir string, done func(error), name string, args ...string) {
1829+
cmd := exec.Command(name, args...)
1830+
cmd.Stdin = os.Stdin
1831+
cmd.Stderr = os.Stderr
1832+
cmd.Stdout = os.Stdout
1833+
cmd.Dir = dir
1834+
err := cmd.Run()
1835+
if done != nil {
1836+
done(err)
1837+
}
1838+
}

0 commit comments

Comments
 (0)