Coder Social home page Coder Social logo

tvm-gdb-commands's Introduction

TVM specific GDB commands

This extension adds 4 new commands to gdb that improve the experience of debugging the Apache TVM code. The commands are explained below with examples.

Installation

Run the below command

bash < <(curl -s https://raw.githubusercontent.com/anirudhsundar/tvm-gdb-commands/master/install.sh)

Alternatively, download the commands.py to some location and source the commands.py file, either directly in your gdb session or add the below line to your .gdbinit

source /path/to/commands.py

Commands Explained

tvm_dump (tvd)

tvm_dump / tvd - Calls p tvm::Dump(<value>) for a given value

tvd is an alias to tvm_dump

Eg:

(gdb) tvd index
(((j.outer*64) + (i*n)) + j.inner)

tvm_type (tvt)

tvm_type / tvt - Prints the original object type of a given value. When a function gets a PrimExpr as argument, this commands prints which sub-class of PrimExpr the given value is. This is in same spirit to whatis command in gdb

tvt is an alias to tvm_type

For example, AddNode could be the underlying original type of the object, declared using it's parent PrimExprNode

Usage:

(gdb) whatis index
type = tvm::PrimExpr
(gdb) tvt index
tvm::tir::AddNode

tvm_attr (tvat)

tvm_attr / tvat - This commmand extends the use of tvm_type and tries to access the underlying attributes/members of the original object.

tvat is an alias to tvm_attr

For example, AddNode has the members a and b, so this allows us to access those members.

This prints out 3 lines, where the first line shows the access string used to access the member, second line shows the type of the object, and the last line prints a dump of the object

(gdb) tvat index.a
access string '((tvm::tir::AddNode*)index).a'
Type of object: 'tvm::tir::AddNode'
((j.outer*64) + (i*n))

This command can also take attributes recursively For example:

(gdb) tvat index.a.a.b
access string '((tvm::tir::MulNode*)((tvm::tir::AddNode*)((tvm::tir::AddNode*)index).a).a).b'
Type of object: 'tvm::IntImmNode'
64

tvm_fields (tvf)

tvm_fields / tvf - This command prints the list of fields available in the given object/object.attributes. This can be called with either a single object, or the object.attr.attr syntax

tvf is an alias to tvm_fields

Note: The fields can also be directly found by completion when using the tvm_attr command, but there are some gotchas in that method, especially when trying completion more than once, so this command was written to help with that.

For example:

(gdb) tvf index.a.a
tvm::PrimExprNode       a       b       _type_final     _type_child_slots

Other Tips

There are 4 aliases (as shown below) defined in the code and if you wish to remove them in favor of others one might like, please comment out the last 4 lines in commands.py

alias tvd = tvm_dump
alias tvt = tvm_type
alias tvat = tvm_attr
alias tvf = tvm_fields

Contributions

Always welcome.

Acknowledgements

Thanks to Lunderberg for valuable feedback and whose tvm-gdb-extension was the inspiration to create this one

tvm-gdb-commands's People

Contributors

anirudhsundar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

sumrock walker-zg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.