Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GDB Questions
- ==============================
- ```bash
- # run with gdb
- pintos --gdb --filesys-size=2 -p build/tests/userprog/args-none -a args-none -- -q -f run args-none
- ```
- The questions you should answer in your design doc are the following.
- 1. Set a break point at process_execute and continue to that point.
- * What is the name and address of the thread running this function?
- ```json
- (struct thread *) 0xc000e000 = {
- tid = 1,
- status = THREAD_RUNNING,
- name = "main", '\000' <repeats 11 times>,
- stack = 0xc000ee0c "\210", <incomplete sequence \357>,
- priority = 31,
- allelem = {
- prev = 0xc0034f68 <all_list>,
- next = 0xc0104020
- },
- fd_list = {
- head = {
- prev = 0x0,
- next = 0xc000e030
- },
- tail = {
- prev = 0xc000e028,
- next = 0x0
- }
- },
- elem = {
- prev = 0xc0034f78 <ready_list>,
- next = 0xc0034f80 <ready_list+8>
- },
- pagedir = 0x0,
- magic = 3446325067
- }
- ```
- * What other threads are present in pintos at this time?
- ```json
- (struct thread *) 0xc0104000 = {
- tid = 2,
- status = THREAD_BLOCKED,
- name = "idle", '\000' <repeats 11 times>,
- stack = 0xc0104f34 "",
- priority = 0,
- allelem = {
- prev = 0xc000e020,
- next = 0xc0034f70 <all_list+8>
- },
- fd_list = {
- head = {
- prev = 0x0,
- next = 0xc0104030
- },
- tail = {
- prev = 0xc0104028,
- next = 0x0
- }
- },
- elem = {
- prev = 0xc0034f78 <ready_list>,
- next = 0xc0034f80 <ready_list+8>
- },
- pagedir = 0x0,
- magic = 3446325067
- }
- ```
- 2. What is the backtrace for the current thread?
- ```
- #0 process_execute (file_name=file_name@entry=0xc0007d50 "args-none") at ../../userprog/process.c:39
- #1 0xc002025e in run_task (argv=0xc0034e0c <argv+12>) at ../../threads/init.c:288
- #2 0xc00208e4 in run_actions (argv=0xc0034e0c <argv+12>) at ../../threads/init.c:340
- #3 main () at ../../threads/init.c:133
- ```
- 3. Set a breakpoint at start_process and continue to that point.
- * What is the name and address of the thread running this function?
- ```json
- (struct thread *) 0xc010b000 = {
- tid = 3,
- status = THREAD_RUNNING,
- name = "args-none\000\000\000\000\000\000",
- stack = 0xc010bfd4 "",
- priority = 31,
- allelem = {
- prev = 0xc0104020,
- next = 0xc0034f70 <all_list+8>
- },
- fd_list = {
- head = {
- prev = 0x0,
- next = 0xc010b030
- },
- tail = {
- prev = 0xc010b028,
- next = 0x0
- }
- },
- elem = {
- prev = 0xc0034f78 <ready_list>,
- next = 0xc0034f80 <ready_list+8>
- },
- pagedir = 0x0,
- magic = 3446325067
- }
- ```
- * What other threads are present in pintos at this time?
- ```json
- #1 (struct thread *) 0xc0104000 = {
- tid = 2,
- status = THREAD_BLOCKED,
- name = "idle", '\000' <repeats 11 times>,
- stack = 0xc0104f34 "",
- priority = 0,
- allelem = {
- prev = 0xc000e020,
- next = 0xc010b020
- },
- fd_list = {
- head = {
- prev = 0x0,
- next = 0xc0104030
- },
- tail = {
- prev = 0xc0104028,
- next = 0x0
- }
- },
- elem = {
- prev = 0xc0034f78 <ready_list>,
- next = 0xc0034f80 <ready_list+8>
- },
- pagedir = 0x0,
- magic = 3446325067
- }
- #2 (struct thread *) 0xc010b000 = {
- tid = 3,
- status = THREAD_RUNNING,
- name = "args-none\000\000\000\000\000\000",
- stack = 0xc010bfd4 "",
- priority = 31,
- allelem = {
- prev = 0xc0104020,
- next = 0xc0034f70 <all_list+8>
- },
- fd_list = {
- head = {
- prev = 0x0,
- next = 0xc010b030
- },
- tail = {
- prev = 0xc010b028,
- next = 0x0
- }
- },
- elem = {
- prev = 0xc0034f78 <ready_list>,
- next = 0xc0034f80 <ready_list+8>
- },
- pagedir = 0x0,
- magic = 3446325067
- }
- ```
- 4. Where is the thread running start_process created?
- ```c
- /* Create a new thread to execute FILE_NAME. */
- tid = thread_create(file_exe, PRI_DEFAULT, start_process, fn_copy);
- ```
- 5. Continue one more time. The userprogram should cause a page fault and thus cause the page fault
- handler to be executed. It’ll look something like
- ```
- [Thread <main>] #1 stopped.
- pintos-debug: a page fault exception occurred in user mode
- pintos-debug: hit ’c’ to continue, or ’s’ to step to intr_handler
- 0xc0021ab7 in intr0e_stub ()
- ```
- Please find out what line of our user program caused the page fault. Don’t worry if it’s just an hex address. (Hint: btpagefault may be useful)
- ```c
- (gdb) btpagefault
- #0 0x0804870c in ?? ()
- process_execute
- |
- |
- v
- start_process
- |
- v
- asm volatile("movl %0, %%esp; jmp intr_exit"
- :
- : "g"(&if_)
- : "memory");
- ```
- 6. The reason why btpagefault returns an hex address is because pintos-gdb build/kernel.o
- only loads in the symbols from the kernel. The instruction that caused the page fault is in our
- userprogram so we have to load these symbols into gdb. To do this use
- loadusersymbols build/tests/userprog/args-none
- . Now do btpagefault again and copy down the results.
- ```
- _start (argc=<error reading variable: can't compute CFA for this frame>, argv=<error reading variable: can't compute CFA for this frame>) at ../../lib/user/entry.c:9
- ```
- 7. Why did our user program page fault on this line?
- ```
- reason is this part of code "main (argc, argv)". Here code tries to access argc and argv. both of them are in the part of the stack, but we haven't pushed down stack pointer down yet. Not reducing esp (stack pointer) we will always access address that is not in our virtual adress space.
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement