llcppsymg:symbol debug log

This commit is contained in:
luoliwoshang
2024-10-17 18:54:28 +08:00
parent 7fe9c9366e
commit 905ed36afd
3 changed files with 131 additions and 30 deletions

View File

@@ -20,6 +20,7 @@ import (
"fmt"
"io"
"os"
"strings"
"github.com/goplus/llgo/chore/_xtool/llcppsymg/config"
"github.com/goplus/llgo/chore/_xtool/llcppsymg/parse"
@@ -29,22 +30,49 @@ import (
func main() {
cfgFile := "llcppg.cfg"
symbFile := "llcppg.symb.json"
if len(os.Args) > 1 {
cfgFile = os.Args[1]
verbose := false
readStdin := false
for i := 1; i < len(os.Args); i++ {
arg := os.Args[i]
if arg == "-" {
readStdin = true
} else if arg == "-v" {
verbose = true
} else if !strings.HasPrefix(arg, "-") {
cfgFile = arg
break
}
}
var data []byte
var err error
if cfgFile == "-" {
if readStdin {
data, err = io.ReadAll(os.Stdin)
} else {
data, err = os.ReadFile(cfgFile)
}
check(err)
conf, err := config.GetConf(data)
check(err)
defer conf.Delete()
if verbose {
symbol.SetDebug(symbol.DbgFlagAll)
if readStdin {
fmt.Println("Config From Stdin")
} else {
fmt.Println("Config From File", cfgFile)
}
fmt.Println("Name:", conf.Name)
fmt.Println("CFlags:", conf.CFlags)
fmt.Println("Libs:", conf.Libs)
fmt.Println("Include:", conf.Include)
fmt.Println("TrimPrefixes:", conf.TrimPrefixes)
fmt.Println("Cplusplus:", conf.Cplusplus)
}
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to parse config file:", cfgFile)
}
@@ -53,6 +81,11 @@ func main() {
filepaths, err := parse.GenHeaderFilePath(conf.CFlags, conf.Include)
check(err)
if verbose {
fmt.Println("filepaths", filepaths)
}
headerInfos, err := parse.ParseHeaderFile(filepaths, conf.TrimPrefixes, conf.Cplusplus, false)
check(err)