ssh -Y you@your_machine.cs.swarthmore.eduOnce remotely connected to cs, you can start other xterms on our system by:
$ xterm &Then create a week06 subdirectory in your weeklylab subdirectory and copy over some files:
cd cs31/weeklylab pwd mkdir week06 ls cd week06 pwd cp ~newhall/public/cs31/week06/* . ls
Here is the general form of a switch statement:
switch ( expression ) { case constant-expression1 : statements when expression == constant-expression1 break; // a break statement is often used at the end to break out // of the body of the switch statement (execute next_stmt next) // if no break statement here, then the very next instruction in sequential order // will be executed next (the stmt immediately after case constant-expression2:) case constant-expression2 : statements when expression == constant-expression2 break; ... case constant-expressionN : statements when expression == constant-expressionN break; default : // default is optional, like the last else is in if-else default statements } next_stmt;Here is an example:
switch(x+8-y) { case 3: // start executing code here when (x+8-y) == 3 x = x + 10; break; case 5: // start executing code here when (x+8-y) == 5 x = y + 10; break; case 7: // start executing code here when (x+8-y) == 7 x = y - x; break; default: // executed when (x+8-y) is not equal to one of 3, 5, or 7 x = 2*y - 6; }
strings a.out
nm --format sysv a.out # dump the symbol table in the a.out file objdump -t a.out # dump the symbol table in the a.out file
See the week 4 lab page for more information and examples. Here are a summary of some of the most useful commands:
ddd a.out (gdb) break main (gdb) run 6 # run with the command line argument 6 (gdb) disass main (gdb) break theSwitchWay2 # set a break point at the begining of a function (gdb) cont (gdb) break *0x0804851a # set a break point and memory address 0x0804851a (gdb) ni # execute the next instruction (gdb) si # step into a function call (step instruction) (gdb) info registers (gdb) p *(int *)($ebp + 8) # print out the value of an int at addr 0x88760 (gdb) x/d $ebp + 8 # examine the contents of memory at the given address # (interpret it as an int) (gdb) p %eax
Figure 3.30 on p.255 of the textbook lists gdb commands.