c - Understanding memory of Doubly linked list struct -
this homework question. book not address how sift through addresses need help
given struct
struct lnode { struct lnode *prev; char *str; int strsize; struct lnode *next; };
the linked list starts @ address 0x0602060, , looking @ memory around address see
(gdb) x/36x 0x0602010 0x602010: 0x0000000000602060 0x0000000000602040 0x602020: 0x0000000000000016 0x00000000006020b0 0x602030: 0x0000000000000000 0x0000000000000021 0x602040: 0x206d72657464696d 0x756874206e6f2031 0x602050: 0x00000a7961647372 0x0000000000000031 0x602060: 0x0000000000000000 0x0000000000602090 0x602070: 0x000000000000000d 0x0000000000602010 0x602080: 0x0000000000000000 0x0000000000000021 0x602090: 0x6f662074276e6f64 0x0000000a74656772 0x6020a0: 0x0000000000000000 0x0000000000000031 0x6020b0: 0x0000000000602010 0x00000000006020e0 0x6020c0: 0x0000000000000016 0x0000000000000000 0x6020d0: 0x0000000000000000 0x0000000000000021 0x6020e0: 0x2035206573616870 0x6d20657564207369 0x6020f0: 0x00000a7961646e6f 0x0000000000020f11 0x602100: 0x0000000000000000 0x0000000000000000 0x602110: 0x0000000000000000 0x0000000000000000 0x602120: 0x0000000000000000 0x0000000000000000
i understand how traverse singly linked list single variable in memory. :
1.begin @ first address, check points to, follow next set of memory
2.the first set of bytes hold value in node, second set hold pointer next node
3.continue
however, not work here.
the first node said @ 0x602060. going there , checking bytes reveals there no variable values, followed pointer next node 0x602090.
0x0000000000000000 0x0000000000602090
going 0x602090 presents bytes in both sections no apparent return address. considering size of struct assume first char pointer shown, size in second column follows
0x6f662074276e6f64 (char*) 0x0000000a74656772 (int padding)
going on, however, i'm looking @ starts make less sense assumption next 2 lines
(1) 0x0000000000000000 0x0000000000000031 (2) 0x0000000000602010 0x00000000006020e0
represent (1) unknown result don't have consider , (2) previous pointer followed next pointer? previous pointer not same start location. , assumption 1 node represented 3 line chunks not seem hold starting @ address 0x6020e0.
can please give me hints how supposed traverse this? appreciated.
your structure contains 4 64-bit values. complete structure starting @ address 0x602060 spread across 2 lines of memory dump:
prev str 0x602060: 0x0000000000000000 0x0000000000602090 0x602070: 0x000000000000000d 0x0000000000602010 strsize next
notice 0x0000000000000000
64 bits long, or 16 hexadecimal digits.
the pointer 0x0000000000602090 pointer string data (for node @ 0x602060), not pointer next node.
Comments
Post a Comment