Displaying struct values in GDB

前端 未结 1 992
无人及你
无人及你 2021-02-02 10:05

In GDB, given a variable that points to a struct, print will display the raw pointer value and x will display the raw bytes pointed to. Is there any wa

相关标签:
1条回答
  • 2021-02-02 10:47
    print *variable
    

    If you do that it will display the value of that variable in GDB.
    You also have an option to display the struct in an indentation and new line:

    $1 = {
    next = 0x0,
    flags = {
    sweet = 1,
    sour = 1
    },
    meat = 0x54 "Pork"
    }
    

    For that you need to set the pretty print:

    set print pretty on
    

    If you want to print an array of values you do like so:

    print *array@len
    
    0 讨论(0)
提交回复
热议问题