Created
January 20, 2012 11:05
-
-
Save kenjiskywalker/1646721 to your computer and use it in GitHub Desktop.
addressof.gdb
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
% gdb -q ./a.out | |
Reading symbols for shared libraries .. done | |
(gdb) list | |
1 #include <stdio.h> | |
2 | |
3 int main() { | |
4 int int_var = 5; | |
5 int *int_ptr; | |
6 | |
7 int_ptr = &int_var; // int_varのアドレスをint_ptrに設定する | |
8 } | |
(gdb) break 8 | |
Breakpoint 1 at 0x100000f33: file addressof.c, line 8. | |
(gdb) run | |
Starting program: /Users/kenji/Dropbox/home/work/github/study/a.out | |
Reading symbols for shared libraries +........................ done | |
Breakpoint 1, main () at addressof.c:8 | |
8 } | |
(gdb) print int_var | |
$1 = 5 | |
(gdb) print &int_var | |
$2 = (int *) 0x7fff5fbff448 | |
(gdb) print int_ptr | |
$3 = (int *) 0x7fff5fbff448 | |
(gdb) print &int_ptr | |
$4 = (int **) 0x7fff5fbff440 | |
(gdb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment