CS31 Weekly Lab: Week 8

IA32 debugging, ddd, man, appropos

Week 8 lab topics:

  1. Revisit week 6 and 7 lab topics: tools, gdb (and ddd), for examining binary executable run state
  2. man and manpages


Tools for examining binary executables
Let's bring up reference resources from Week 6 Wed lab page.

There are no files to copy over for this week. Instead, lets revisit the mystery program from last week and try it in ddd again:

cd cs31/weeklylabs/week07/
ddd ./mystery
(gdb) break main
(gdb) run
  • what does main control flow look like?
  • let's add some break points around function calls and in functions
  • let's examine some state around functions
  • we can print out values on the stack using x
    (gdb) x/a  address   #  /a:  "examine memory contents as an adress" 
    (gdb) x/s  address   #  /s:  "examine memory contents as a string" 
    (gdb) x/wd address   #  /wd: "examine memory contents as a 4byte decimal"
    


    man
    First, we are going to learn how to use man to read manual pages, and how to use appropos to find commands: man and apropos

    Next, let's look at the man page for strcmp and for scanf to see what they are telling us about these functions.

    % man scanf
    % man 3 scanf   # or explictly specify the manual section:
                    # (C library function scanf is in section 3 of the manual) 
    % man strcmp