Using username "aq". Authenticating with public key "rsa-key-20170307" from agent aq@ecegrid-thin7 ~ $ c2m aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ ll total 4 -rw-r--r-- 1 aq ece264w 224 Dec 6 09:08 a.c aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gcc a.c -o a a.c: In function ‘main’: a.c:7:6: warning: unused variable ‘n’ [-Wunused-variable] int n = 5; ^ aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ ll total 16 -rwxr-xr-x 1 aq ece264w 10752 Dec 6 09:08 a* -rw-r--r-- 1 aq ece264w 224 Dec 6 09:08 a.c aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gdb a GNU gdb (GDB) 9.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from a... (gdb) l 1 #include 2 #include 3 #include 4 #include 5 6 int main(int argc, char* argv[]) { 7 int n = 5; 8 9 return EXIT_SUCCESS; 10 } (gdb) b 9 Breakpoint 1 at 0x4004f7: file a.c, line 9. (gdb) r Starting program: /web/groups/ece264/22au/lecture/20221206/snippets/a Breakpoint 1, main (argc=1, argv=0x7fffffffd568) at a.c:9 9 return EXIT_SUCCESS; (gdb) p n $1 = 5 (gdb) p/x n $2 = 0x5 (gdb) p/d n $3 = 5 (gdb) p &n $4 = (int *) 0x7fffffffd47c (gdb) x/1bx 0x7fffffffd47c 0x7fffffffd47c: 0x05 (gdb) x/4bx 0x7fffffffd47c 0x7fffffffd47c: 0x05 0x00 0x00 0x00 (gdb) x/1wx 0x7fffffffd47c 0x7fffffffd47c: 0x00000005 (gdb) quit A debugging session is active. Inferior 1 [process 31577] will be killed. Quit anyway? (y or n) EOF [assumed Y] aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gcc a.c -o a a.c: In function ‘main’: a.c:8:6: warning: unused variable ‘x’ [-Wunused-variable] int x = 0xdecafbad; ^ a.c:7:6: warning: unused variable ‘n’ [-Wunused-variable] int n = 5; ^ aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gdb a GNU gdb (GDB) 9.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from a... (gdb) l 1 #include 2 #include 3 #include 4 #include 5 6 int main(int argc, char* argv[]) { 7 int n = 5; 8 int x = 0xdecafbad; 9 10 return EXIT_SUCCESS; (gdb) b 10 Breakpoint 1 at 0x4004fe: file a.c, line 10. (gdb) r Starting program: /web/groups/ece264/22au/lecture/20221206/snippets/a Breakpoint 1, main (argc=1, argv=0x7fffffffd568) at a.c:10 10 return EXIT_SUCCESS; (gdb) x/1wx &n 0x7fffffffd47c: 0x00000005 (gdb) x/4bx &n 0x7fffffffd47c: 0x05 0x00 0x00 0x00 (gdb) x/1wx &x 0x7fffffffd478: 0xdecafbad (gdb) x/4bx &x 0x7fffffffd478: 0xad 0xfb 0xca 0xde (gdb) x/1wt &x 0x7fffffffd478: 11011110110010101111101110101101 (gdb) x/4bt &x 0x7fffffffd478: 10101101 11111011 11001010 11011110 (gdb) quit A debugging session is active. Inferior 1 [process 16771] will be killed. Quit anyway? (y or n) EOF [assumed Y] aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gcc b.c -o b b.c: In function ‘main’: b.c:8:7: warning: unused variable ‘a_numbers_0’ [-Wunused-variable] int* a_numbers_0 = &numbers[0]; ^~~~~~~~~~~ aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gdb b GNU gdb (GDB) 9.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from b... (gdb) l 1 #include 2 #include 3 #include 4 #include 5 6 int main(int argc, char* argv[]) { 7 int numbers[] = { 10, 11, 12 }; 8 int* a_numbers_0 = &numbers[0]; 9 10 return EXIT_SUCCESS; (gdb) b 10 Breakpoint 1 at 0x40050d: file b.c, line 10. (gdb) r Starting program: /web/groups/ece264/22au/lecture/20221206/snippets/b Breakpoint 1, main (argc=1, argv=0x7fffffffd568) at b.c:10 10 return EXIT_SUCCESS; (gdb) p &numbers $1 = (int (*)[3]) 0x7fffffffd46c (gdb) p &numbers[0] $2 = (int *) 0x7fffffffd46c (gdb) p a_numbers_0 $3 = (int *) 0x7fffffffd46c (gdb) x/4wd a_numbers_0 0x7fffffffd46c: 10 11 12 -11156 (gdb) x/3wd a_numbers_0 0x7fffffffd46c: 10 11 12 (gdb) x/3wx a_numbers_0 0x7fffffffd46c: 0x0000000a 0x0000000b 0x0000000c (gdb) x/12bx a_numbers_0 0x7fffffffd46c: 0x0a 0x00 0x00 0x00 0x0b 0x00 0x00 0x00 0x7fffffffd474: 0x0c 0x00 0x00 0x00 (gdb) quit A debugging session is active. Inferior 1 [process 12676] will be killed. Quit anyway? (y or n) EOF [assumed Y] aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gcc c.c -o c c.c: In function ‘main’: c.c:13:13: warning: unused variable ‘p’ [-Wunused-variable] NamedPoint p = { .x = 5, .y = 7, .name = "Lee" }; ^ aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gdb c GNU gdb (GDB) 9.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from c... (gdb) b No default breakpoint address now. (gdb) l 1 #include 2 #include 3 #include 4 #include 5 6 typedef struct { 7 int x; 8 int y; 9 char* name; 10 } NamedPoint; (gdb) 11 12 int main(int argc, char* argv[]) { 13 NamedPoint p = { .x = 5, .y = 7, .name = "Lee" }; 14 return EXIT_SUCCESS; 15 } 16 /* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */ (gdb) b 14 Breakpoint 1 at 0x400506: file c.c, line 14. (gdb) r Starting program: /web/groups/ece264/22au/lecture/20221206/snippets/c Breakpoint 1, main (argc=1, argv=0x7fffffffd568) at c.c:14 14 return EXIT_SUCCESS; (gdb) quit A debugging session is active. Inferior 1 [process 28665] will be killed. Quit anyway? (y or n) EOF [assumed Y] aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gcc c.c -o c c.c: In function ‘main’: c.c:14:13: warning: unused variable ‘p’ [-Wunused-variable] NamedPoint p = { .x = 5, .y = 7, .name = "Lee" }; ^ aq@ecegrid-thin7 /web/groups/ece264/22au/lecture/20221206/snippets $ gdb c GNU gdb (GDB) 9.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from c... (gdb) b 15 Breakpoint 1 at 0x400506: file c.c, line 15. (gdb) r Starting program: /web/groups/ece264/22au/lecture/20221206/snippets/c Breakpoint 1, main (argc=1, argv=0x7fffffffd568) at c.c:15 15 return EXIT_SUCCESS; (gdb) p sizeof(p) $1 = 16 (gdb) whatis p type = NamedPoint (gdb) x/16bx &p 0x7fffffffd470: 0x05 0x00 0x00 0x00 0x07 0x00 0x00 0x00 0x7fffffffd478: 0xe8 0x05 0x40 0x00 0x00 0x00 0x00 0x00 (gdb) p 'L' $2 = 76 'L' (gdb) p/x 'L' $3 = 0x4c (gdb) p/x 'e' $4 = 0x65 (gdb) x/4wx &p 0x7fffffffd470: 0x00000005 0x00000007 0x004005e8 0x00000000 (gdb) x/2gx &p 0x7fffffffd470: 0x0000000700000005 0x00000000004005e8 (gdb) x/4bc 0x00000000004005e8 0x4005e8: 76 'L' 101 'e' 101 'e' 0 '\000' (gdb) x/4bx 0x00000000004005e8 0x4005e8: 0x4c 0x65 0x65 0x00 (gdb) x/4bd 0x00000000004005e8 0x4005e8: 76 101 101 0 (gdb) x/4bo 0x00000000004005e8 0x4005e8: 0114 0145 0145 0 (gdb)