Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 C 编程应用程序,它使用 jansson 库(用 C 编写的 json 库)。我正在尝试在 gdb 中查看 json_t 对象的值,但它只是打印
(gdb) p jmsg $20 = (json_t *) 0x69c350 (gdb) p *jmsg $21 = {type = JSON_OBJECT, refcount = 1}
如何在 gdb 中查看 json_t 的值?
在 GDB 中,您可以直接进行函数调用。Jansson 库有一个 json_dumps(json_t *, int flags) API,它返回 json_t 对象的 char* 字符串。
因此,在 GDB 中,只需执行以下操作:
(gdb) call json_dumps(obj, 0)
然后 GDB 将打印您的 json 对象的字符串输出。