vscode GDB display memory

In computing, endianness is the order or sequence of bytes of a word of digital data in computer memory. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the most significant byte of a word at the smallest memory address and the least significant byte at the largest. A little-endian system, in contrast, stores the least-significant byte at the smallest address.

  • big-endian: most significant byte in smallest memory address
  • little-endian: least significant byte at the smallest address

Question: How to display memory during a debug session #1503
Examine/display memory and register in gdb

const char  str[] = "hello world!";
const int   k = -15;  
-exec x/s str
0x7ff608319998 <str>:    "hello world!"

-exec x/13xb str
0x7ff608319998 <str>:    0x68    0x65    0x6c    0x6c    0x6f    0x20    0x77    0x6f
0x7ff6083199a0 <str+8>:  0x72    0x6c    0x64    0x21    0x00

-exec x &k
0x7ff6083199a8 <k>:      0xf1

-exec x/d &k
0x7ff6083199a8 <k>:      -15

-exec x/4b &k
0x7ff6083199a8 <k>:      -15    -1    -1    -1

-exec x/4xb &k
0x7ff6083199a8 <k>:      0xf1    0xff    0xff    0xff

-exec p sine
$2 = {0x7ff608319000 <sine_300> "", 0x7ff608319260 <sine_400> "", 0x7ff608319420 <sine_500> "", 0x7ff608319580 <sine_600> "", 0x7ff6083196a0 <sine_700> "", 0x7ff6083197a0 <sine_800> "", 0x7ff608319880 <sine_900> ""}

-exec x/7xg &sine
0x7ff608318020 <sine>:       0x00007ff608319000    0x00007ff608319260
0x7ff608318030 <sine+16>:    0x00007ff608319420    0x00007ff608319580
0x7ff608318040 <sine+32>:    0x00007ff6083196a0    0x00007ff6083197a0
0x7ff608318050 <sine+48>:    0x00007ff608319880

-exec x/8xh sine[0]
0x7ff608319000 <sine_300>:	0x0000	0x0000	0x0579	0x0578	0x0aeb	0x0aee	0x1062	0x105d

-exec x/8xh sine[1]
0x7ff608319260 <sine_400>:	0x0000	0x0000	0x074b	0x074a	0x0e8d	0x0e90	0x15ca	0x15c6

-exec x/8xh &m_wave
0x7ff7c3f2d060 <m_wave>:	0x0000	0x0000	0x02bc	0x0578	0x0aeb	0x0aee	0x1062	0x105d

-exec x/8xh wave_16bit
0x7ff7c3f2d060 <m_wave>:	0x0000	0x0000	0x02bc	0x0578	0x0aeb	0x0aee	0x1062	0x105d






-exec tui enable
Cannot enable the TUI when the interpreter is 'mi'

-exec show endian
The target endianness is set automatically (currently little endian).

Leave a Reply

Your email address will not be published. Required fields are marked *