gdb
gdb

Reputation: 7809

Why I can't access the memory directly?

(gdb) p it
$2 = (item *) 0x6
(gdb) p *it
$3 = {next = 0x0, prev = 0x0, h_next = 0x0, time = 0, exptime = 0, nbytes = 7, refcount = 1, nsuffix = 6 '\006', it_flags = 2 '\002', slabs_clsid = 1 '\001', nkey = 6 '\006', 
  end = 0x7f0890b6e040}
(gdb) p *0x6
Cannot access memory at address 0x6

Isn't p *it and p *0x6 the same thing here??

Upvotes: 0

Views: 2280

Answers (2)

Employed Russian
Employed Russian

Reputation: 213947

Unless you are on an embedded target that has real memory mapped at address 0, the value of it == 0x6 is bogus (usually result of a null pointer dereference).

The fact that gdb prints *it probably means there is a bug in gdb, but it's hard to say. Unfortunately you didn't say which version of GDB, and what OS, you are using.

Upvotes: 1

ArtoAle
ArtoAle

Reputation: 2977

The gdb 'p' command can only be used for printing variables value. If you want to inspect memory have a look there

Upvotes: 0

Related Questions