Last active
June 22, 2019 18:14
-
-
Save dovideh/14c21dc23d7b48cb0f763f4c2e2d2105 to your computer and use it in GitHub Desktop.
lldb debug for while loop in hashing program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(lldb) | |
Process 27249 stopped | |
* thread #1, name = 't_hash', stop reason = step over | |
frame #0: 0x00005555555554bc t_hash`h_search(hTable=0x0000555555559260, key="400") at myhash.c:134:30 | |
131 else { | |
132 // looking for the key inside the next element of the linked list | |
133 char* keyAtNextValue = hTable->h_items[resultHash]->h_next->h_key; | |
-> 134 while( nextValue->h_next != NULL) { | |
135 fprintf(stderr, "Found a collision, traversing Linked list at address %p, key is: %s", | |
136 nextValue, nextValue); | |
137 nextValue += 1; | |
(lldb) print nextValue | |
(HashNode *) $0 = 0x00005555555592e0 | |
(lldb) br l | |
Current breakpoints: | |
1: name = 'h_search', locations = 1, resolved = 1, hit count = 1 | |
1.1: where = t_hash`h_search + 17 at myhash.c:97:39, address = 0x0000555555555401, resolved, hit count = 1 | |
(lldb) print *nextValue | |
(HashNode) $1 = { | |
h_next = 0x0000000000000000 | |
h_key = 0x0000555555559300 "400" | |
h_value = 0x0000555555559320 "101" | |
} | |
(lldb) print *nextValue->h_next | |
error: Couldn't apply expression side effects : Couldn't dematerialize a result variable: couldn't read its memory | |
(lldb) print nextValue->h_next | |
(HashNode *) $3 = 0x0000000000000000 | |
(lldb) print *nextValue->h_key | |
(char) $4 = '4' | |
(lldb) print nextValue->h_key | |
(char *) $5 = 0x0000555555559300 "400" | |
(lldb) bt | |
* thread #1, name = 't_hash', stop reason = step over | |
* frame #0: 0x00005555555554bc t_hash`h_search(hTable=0x0000555555559260, key="400") at myhash.c:134:30 | |
frame #1: 0x0000555555555217 t_hash`main at t_hash.c:14:27 | |
frame #2: 0x00007ffff7dd7ee3 libc.so.6`__libc_start_main + 243 | |
frame #3: 0x00005555555550fe t_hash`_start + 46 | |
(lldb) me read 0x00005555555592e0 -fX -c25 -s8 --force | |
0x5555555592e0: 0x0000000000000000 | |
0x5555555592e8: 0x0000555555559300 | |
0x5555555592f0: 0x0000555555559320 | |
0x5555555592f8: 0x0000000000000021 | |
0x555555559300: 0x0000000000303034 | |
0x555555559308: 0x0000000000000000 | |
0x555555559310: 0x0000000000000000 | |
0x555555559318: 0x0000000000000021 | |
0x555555559320: 0x0000000000313031 | |
0x555555559328: 0x0000000000000000 | |
0x555555559330: 0x0000000000000000 | |
0x555555559338: 0x0000000000000021 | |
0x555555559340: 0x00005555555592E0 | |
0x555555559348: 0x0000555555559360 | |
0x555555559350: 0x0000555555559380 | |
0x555555559358: 0x0000000000000021 | |
0x555555559360: 0x0000000000303034 | |
0x555555559368: 0x0000000000000000 | |
0x555555559370: 0x0000000000000000 | |
0x555555559378: 0x0000000000000021 | |
0x555555559380: 0x0000000000313031 | |
0x555555559388: 0x0000000000000000 | |
0x555555559390: 0x0000000000000000 | |
0x555555559398: 0x0000000000020C71 | |
0x5555555593a0: 0x0000000000000000 | |
(lldb) me read 0x00005555555592e0 -c256 | |
0x5555555592e0: 00 00 00 00 00 00 00 00 00 93 55 55 55 55 00 00 ..........UUUU.. | |
0x5555555592f0: 20 93 55 55 55 55 00 00 21 00 00 00 00 00 00 00 .UUUU..!....... | |
0x555555559300: 34 30 30 00 00 00 00 00 00 00 00 00 00 00 00 00 400............. | |
0x555555559310: 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... | |
0x555555559320: 31 30 31 00 00 00 00 00 00 00 00 00 00 00 00 00 101............. | |
0x555555559330: 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... | |
0x555555559340: e0 92 55 55 55 55 00 00 60 93 55 55 55 55 00 00 ..UUUU..`.UUUU.. | |
0x555555559350: 80 93 55 55 55 55 00 00 21 00 00 00 00 00 00 00 ..UUUU..!....... | |
0x555555559360: 34 30 30 00 00 00 00 00 00 00 00 00 00 00 00 00 400............. | |
0x555555559370: 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 ........!....... | |
0x555555559380: 31 30 31 00 00 00 00 00 00 00 00 00 00 00 00 00 101............. | |
0x555555559390: 00 00 00 00 00 00 00 00 71 0c 02 00 00 00 00 00 ........q....... | |
0x5555555593a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ | |
0x5555555593b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ | |
0x5555555593c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ | |
0x5555555593d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ | |
(lldb) | |
--- | |
lldb) frame variable | |
(HashTable *) hTable = 0x0000555555559260 | |
(char *) key = 0x0000555555556004 "400" | |
(size_t) resultHash = 5 | |
(HashNode *) nextValue = 0x00005555555592e0 | |
(char *) keyStrAtIndex = <variable not available> | |
(char *) keyAtNextValue = <no location, value may have been optimized out> | |
(lldb) fr v | |
(HashTable *) hTable = 0x0000555555559260 | |
(char *) key = 0x0000555555556004 "400" | |
(size_t) resultHash = 5 | |
(HashNode *) nextValue = 0x00005555555592e0 | |
(char *) keyStrAtIndex = <variable not available> | |
(char *) keyAtNextValue = <no location, value may have been optimized out> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment