Skip to content

Commit

Permalink
add better formatting and function names
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Jan 5, 2022
1 parent 6c1ea50 commit 3b50196
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,11 @@ Here we see the virtual table element location attributes:

```bash
$ go run main.go vtable
VtableElementLocation [16 3]
[16 3]
VtableElementLocation [16 0]
[16 0]
VtableElementLocation [16 3]
[16 3]
VtableElementLocation [16 0]
[16 0]
VtableElementLocation [16 1]
[16 1]
getname : VtableElementLocation : [16 3]
warmblooded : VtableElementLocation : [16 0]
getname : VtableElementLocation : [16 3]
getname : VtableElementLocation : [16 0]
warmblooded : VtableElementLocation : [16 1]
```

[The attribute](https://cs.opensource.google/go/go/+/master:src/debug/dwarf/const.go;l=73;bpv=1;bpt=1) is
Expand Down
9 changes: 4 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"log"
"os"

"github.com/vsoch/debug_dwarf/pkg/debug/elf"
"github.com/vsoch/debug_dwarf/pkg/debug/dwarf"
"github.com/vsoch/debug_dwarf/pkg/debug/elf"
)

// usage (vtable is an ELF binary with dwarf debug symbols)
Expand Down Expand Up @@ -35,21 +35,20 @@ func ParseDwarf(dwf *dwarf.Data) {
}

switch entry.Tag {

// We found a function! Functions have this vtable attribute
case dwarf.TagSubprogram:

// DW_AT_vtable_elem_location = 0x4d // block, loclistptr
loc := entry.Val(dwarf.AttrVtableElemLoc)
name := entry.Val(dwarf.AttrName)
if loc != nil {
fmt.Println("VtableElementLocation", loc)
fmt.Println(loc)
fmt.Printf("%-15s : VtableElementLocation : %v\n", name, loc)
}
}
}
}


func main() {

args := os.Args[1:]
Expand Down

0 comments on commit 3b50196

Please sign in to comment.