简体   繁体   中英

Debugging json_t object with GDB

I have a application in C programming which uses jansson library(json library written in C). I'm trying to view value of json_t object in gdb but it just prints

(gdb) p jmsg
$20 = (json_t *) 0x69c350
(gdb) p *jmsg
$21 = {type = JSON_OBJECT, refcount = 1}

How is it possible to view the value of json_t in gdb.?

When in GDB, you can make function calls directly. Jansson library has a json_dumps(json_t *, int flags) API that returns a char* string of the json_t object.

So while in GDB, just simply do:

(gdb) call json_dumps(obj, 0)

GDB will then print the string output of your json object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM