You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Anirudh via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/08/16 15:44:37 UTC
[Apache TVM Discuss] [Questions] Finding types of TVM objects and
accessing their attributes in GDB
Hi all,
Just a generic question about debugging in GDB. Is there a good way to find the proper type of an `"object"` in GDB?
What I mean by that is, say there is an `AddNode` passed to a function as a `PrimExpr` and while debugging this function, is there way to find that it actually belongs to an `AddNode`. Trying `whatis object` or `ptype object` just prints that it's a `PrimExpr`.
I found a rather hacky way to do this by printing
the `object.deleter_` if it's a subclass of `tvm::runtime::Object`, and
`object.get().deleter_` if it's a subclass of `tvm::runtime::ObjectRef`
This prints the type of the `Deleter_` for that object and the template argument to the Handler contains the proper type (a sample output for `AddNode` is as shown below:)
> $65 = (tvm::runtime::Object::FDeleter) 0x7fffaf6c9300 <tvm::runtime::SimpleObjAllocator::Handler\<**tvm::tir::AddNode**\>::Deleter_(tvm::runtime::Object*)>
I was just wondering whether there's a stable/reliable way to get this info.
---
[Visit Topic](https://discuss.tvm.apache.org/t/finding-types-of-tvm-objects-and-accessing-their-attributes-in-gdb/10813/1) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/fcc7d26800a570a0d2a74d572e079afb29835b971d928b9bec57495984a67467).
[Apache TVM Discuss] [Questions] Finding types of TVM objects and
accessing their attributes in GDB
Posted by Anirudh via Apache TVM Discuss <no...@discuss.tvm.ai>.
Right, I think `tvm::Dump(xxx)` also supports printing entire PrimFunc. The main question I had was, is there a clean way to find the underlying type of an `Object`/`ObjectRef`. Basically, if I have a `PrimFunc` is there a way to find that the underlying type is say an `AddNode`.
---
[Visit Topic](https://discuss.tvm.apache.org/t/finding-types-of-tvm-objects-and-accessing-their-attributes-in-gdb/10813/5) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/020c32e6ee437769e4f4cdab372e06dfc611906650d2d36a79331380d7eca8f9).
[Apache TVM Discuss] [Questions] Finding types of TVM objects and
accessing their attributes in GDB
Posted by Johnson9009 via Apache TVM Discuss <no...@discuss.tvm.ai>.
I haven't used `tvm::Dump(xxx)`, I use `call (size_t)puts(PrettyPrint(xxx).c_str())` when the `xxx` is a large node, e.g., the whole of PrimFunc, you can try with these large node.
---
[Visit Topic](https://discuss.tvm.apache.org/t/finding-types-of-tvm-objects-and-accessing-their-attributes-in-gdb/10813/4) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/478bf88bbdead3da46fec2b48a401366b1c2e617160f04d0e74f5fcfc84650b7).
[Apache TVM Discuss] [Questions] Finding types of TVM objects and
accessing their attributes in GDB
Posted by Anirudh via Apache TVM Discuss <no...@discuss.tvm.ai>.
Thanks for the reply, atleast I'm not the only one who is using the deleter_ hack to find the types of nodes.
And thanks for the ideas with PrettyPrint, I haven't used it too much in gdb, I normally use the `p tvm::Dump(xxx)` for printing Objects and ObjectRefs.
So, out of curiosity, is there a difference between what's printed by `tvm::Dump` vs what's printed by `call (size_t)puts(PrettyPrint(xxx).c_str())`. I tried it on a couple of simple examples and did not see any major differences.
---
[Visit Topic](https://discuss.tvm.apache.org/t/finding-types-of-tvm-objects-and-accessing-their-attributes-in-gdb/10813/3) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/6e6aac52d4e43c8e5f37a792619aea57c5ad538d2829270c828df2aa6f55a6b8).
[Apache TVM Discuss] [Questions] Finding types of TVM objects and
accessing their attributes in GDB
Posted by Johnson9009 via Apache TVM Discuss <no...@discuss.tvm.ai>.
I use the same way, and when I need inspect more details of the class object, I will use `p PrettyPrint(xxx).c_str()`, in addition if I want a more clear display(do the real line break instead of just print it as "\n"), the gdb command `call (size_t)puts(PrettyPrint(xxx).c_str())` will be used.
for the last command, it is better to set the standard output of the process to another terminal.
---
[Visit Topic](https://discuss.tvm.apache.org/t/finding-types-of-tvm-objects-and-accessing-their-attributes-in-gdb/10813/2) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/31287ff698aa6cda13d3fd13ca6849963c946f9553202855bfa1fffa7ee32998).