> pintos/src/userprog/build$ pintos-gdb kernel.o Reading symbols from kernel.o...done. (gdb) target remote localhost:1234 //connect to pintos gdb Remote debugging using localhost:1234 0x0000fff0 in ?? () (gdb) b syscall_handler // insert a breakpoint in the syscall_handler ( file ../../userprog/syscall.c, line 17) Breakpoint 1 at 0xc010a7fa: file ../../userprog/syscall.c, line 17. (gdb) c // continue execution until a breakpoint is hit (or the program finishes/crashes) Continuing. Breakpoint 1, syscall_handler (f=0xc011ffb0) at ../../userprog/syscall.c:17. // BREAKPOINT WAS HIT :) 17 { (gdb) list // show the source code at the point it stopped 12 intr_register_int (0x30, 3, INTR_ON, syscall_handler, "syscall"); 13 } 14 15 static void 16 syscall_handler (struct intr_frame *f UNUSED) 17 { 18 printf ("system call!\n"); 19 thread_exit (); 20 } (gdb) ptype f // syscall_handler receives a struct intr_frame *f , print the details of such structure type = struct intr_frame { uint32_t edi; uint32_t esi; uint32_t ebp; uint32_t esp_dummy; uint32_t ebx; uint32_t edx; uint32_t ecx; uint32_t eax; uint16_t gs; uint16_t fs; uint16_t es; uint16_t ds; uint32_t vec_no; uint32_t error_code; void *frame_pointer; void (*eip)(void); uint16_t cs; uint32_t eflags; void *esp; uint16_t ss; } * (gdb) p f->esp // struct intr_frame *f has the user space program stack pointer, print the address $1 = (void *) 0xbffffed8 (gdb) x/5w f->esp // examine 5 words given by the esp pointer 0xbffffed8: 9 1 -1073742044 55 // here you can see the parameters of the system call (9 is SYS_WRITE from pintos/src/lib/syscall-nr.h, 1 is the standard output FD, -1073742044 is the address of the user space string that is supposed to be printed by the system call - displayed as an integer) 0xbffffee8: -1073742072 (gdb) p f->esp+8 // f->esp+8 prints the third parameter of the system call, the address of the string now displayed in hex $2 = (void *) 0xbffffee0 (gdb) x/s *(char**)(f->esp+8) // examine the address treating it as string (x/s) by dereferencing the pointer (first asterisk *), casting it as a pointer to a pointer to a char (char **) and taking the third parameter of the user’s stack (f->esp+8) 0xbfffff24: "You got it, use your debugging skills during the labs!\n"