Skip to content

Commit

Permalink
Merge pull request #66 from mkonshie/skip-rust
Browse files Browse the repository at this point in the history
Skip rust compilation units and add version flag
  • Loading branch information
npetroni authored Oct 8, 2024
2 parents d88b399 + 0ccdfb0 commit 9f14607
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
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

0 comments on commit 9f14607

Please sign in to comment.