Skip to content

Commit 9f14607

Browse files
authored
Merge pull request #66 from mkonshie/skip-rust
Skip rust compilation units and add version flag
2 parents d88b399 + 0ccdfb0 commit 9f14607

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ To run:
2222
Commands:
2323
linux generate ISF for Linux analysis
2424
mac generate ISF for macOS analysis
25+
26+
Options:
27+
-h, --help Show this screen.
28+
-v, --version Show tool and output schema version.
2529
```
2630

2731
Note: processing large DWARF files requires a minimum of 8GB RAM.

main.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ import (
2929
)
3030

3131
const (
32+
DW_LANG_Rust = 0x001c
33+
3234
DW_OP_addr = 0x3
3335
)
3436

3537
const (
3638
TOOL_NAME = "dwarf2json"
37-
TOOL_VERSION = "0.8.0"
39+
TOOL_VERSION = "0.9.0"
3840
FORMAT_VERSION = "6.2.0"
3941
)
4042

@@ -448,11 +450,17 @@ func (doc *vtypeJson) addDwarf(data *dwarf.Data, endian string, extract Extract)
448450
// fmt.Printf("Done!\n")
449451
break
450452
}
451-
452453
if err != nil {
453454
return err
454455
}
455456

457+
if entry.Tag == dwarf.TagCompileUnit || entry.Tag == dwarf.TagTypeUnit || entry.Tag == dwarf.TagPartialUnit {
458+
if val, ok := entry.Val(dwarf.AttrLanguage).(int64); ok && val == DW_LANG_Rust {
459+
reader.SkipChildren()
460+
continue
461+
}
462+
}
463+
456464
for _, cb := range callBacks {
457465
err = cb(entry, reader.AddressSize())
458466
if err != nil {
@@ -672,6 +680,9 @@ Commands:
672680
linux generate ISF for Linux analysis
673681
mac generate ISF for macOS analysis
674682
683+
Options:
684+
-h, --help Show this screen.
685+
-v, --version Show tool and output schema version.
675686
`,
676687
os.Args[0])
677688
}
@@ -782,6 +793,10 @@ Commands:
782793
case "-h", "--help":
783794
pflag.Usage()
784795
os.Exit(0)
796+
case "-v", "--version":
797+
fmt.Printf("%s %s\n", TOOL_NAME, TOOL_VERSION)
798+
fmt.Printf("output schema %s\n", FORMAT_VERSION)
799+
os.Exit(0)
785800
default:
786801
fmt.Fprintf(
787802
os.Stderr,

0 commit comments

Comments
 (0)