Skip to content
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

Skip rust compilation units and add version flag #66

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ To run:
Commands:
linux generate ISF for Linux analysis
mac generate ISF for macOS analysis

Options:
-h, --help Show this screen.
-v, --version Show tool and output schema version.
```

Note: processing large DWARF files requires a minimum of 8GB RAM.
Expand Down
19 changes: 17 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ import (
)

const (
DW_LANG_Rust = 0x001c

DW_OP_addr = 0x3
)

const (
TOOL_NAME = "dwarf2json"
TOOL_VERSION = "0.8.0"
TOOL_VERSION = "0.9.0"
FORMAT_VERSION = "6.2.0"
)

Expand Down Expand Up @@ -448,11 +450,17 @@ func (doc *vtypeJson) addDwarf(data *dwarf.Data, endian string, extract Extract)
// fmt.Printf("Done!\n")
break
}

if err != nil {
return err
}

if entry.Tag == dwarf.TagCompileUnit || entry.Tag == dwarf.TagTypeUnit || entry.Tag == dwarf.TagPartialUnit {
if val, ok := entry.Val(dwarf.AttrLanguage).(int64); ok && val == DW_LANG_Rust {
reader.SkipChildren()
continue
}
}

for _, cb := range callBacks {
err = cb(entry, reader.AddressSize())
if err != nil {
Expand Down Expand Up @@ -672,6 +680,9 @@ Commands:
linux generate ISF for Linux analysis
mac generate ISF for macOS analysis

Options:
-h, --help Show this screen.
-v, --version Show tool and output schema version.
`,
os.Args[0])
}
Expand Down Expand Up @@ -782,6 +793,10 @@ Commands:
case "-h", "--help":
pflag.Usage()
os.Exit(0)
case "-v", "--version":
fmt.Printf("%s %s\n", TOOL_NAME, TOOL_VERSION)
fmt.Printf("output schema %s\n", FORMAT_VERSION)
os.Exit(0)
default:
fmt.Fprintf(
os.Stderr,
Expand Down
Loading