Starting from:
$35

$29

Project 3: Virtual Memory Simulation Solution

    • ce >. trace  -r < algorithm >


13.5    Debugging Tips with GDB

If your program is crashing or misbehaving, you can use GDB to locate the bug. GDB is a command line inter-face that will allow you to set breakpoints, step through your code, see variable values, and identify segfaults. There are tons of online guides, click here (http://condor.depaul.edu/glancast/373class/docs/gdb.html) for one.

To compile with debugging information, you must build the program with make debug:
Project 3 - Virtual Memory CS 2200 - Systems and Networks    Spring 2022



    • make  clean

    • make  debug

To start your program in gdb, run:

    • gdb  ./ vm - sim

Within gdb, you can run your program with the run command, see below for an example:

    • ( gdb )  r  -i  traces / < trace >. trace  -r < algorithm >

You may find it useful to set a breakpoint inside the main loop of the simulator to debug specific simulator commands in your implementation. You can do this either by finding the line number inside pagesim.c and breaking there:

$
( gdb )
break  pagesim . c :53  !  set
b r e a k p o i n t  at  call  to  s y s t e m _ i n i t
$
( gdb )
r  -i
traces / < trace >. trace
-r < algorithm >
!
( wait
for
b r e a k p o i n t )


    • ( gdb )  s!  step  into  the  function  call

...or by using the actual function name being called from the main loop:

$
( gdb )
break  sim_cmd
!  set
b r e a k p o i n t  at  call  to  sim_cmd
$
( gdb )
r  -i
traces / < trace >. trace
-r < algorithm >
!
( wait
for
b r e a k p o i n t )



    • ( gdb )  s!  step  into  the  function  call

Sometimes, you may want to examine a large area of memory. To do this in GDB, you can use the x command (short for examine). For example, to examine the first 24 bytes of the frame table, we could do the following:

    • ( gdb )  x /24 xb  f r a m e _ t a b l e

0 x 1 0 0 4 0 0 0 a a :
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00
0 x 1 0 0 4 0 0 0 b 2 :
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00
0 x 1 0 0 4 0 0 0 b a :
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00
0 x00

The format of this command is x/nfu [memory location], where n is the number of items to print, f is a formatting identifier (for example, x for hexadecimal), and u is the specifier for the units you would like to print. b specifies units of 1 byte, h specifies 2 bytes, w specifies 4 bytes, and g specifies 8 bytes. So, our above command showed us 24 bytes of memory starting at frame_table in hexadecimal form.

If you use the corruption checker, you can set a breakpoint on panic() and use a backtrace to discover the context in which the panic occurred:

    • ( gdb )  break  panic

$ ( gdb ) r -i traces / < trace >. trace -r < algorithm > ! ( wait for GDB to stop at the b r e a k p o i n t )

    • ( gdb )  ba ck t ra ce

    • ( gdb )  frame  N!  where  N  is  the  frame  number  you  want  to  examine

Feel free to ask about gdb and how to use it in office hours and on Piazza. Do not ask a TA or post on Piazza about a segfault without first running your program through GDB.

13.6    Verifying Your Solution

On execution, the simulator will output data read/write values. To check against our solutions, run

$  ./ vm - sim  -i  traces / < trace >. trace  -r < algorithm >

>

my _o ut pu t . log
$  diff    m y_ ou tp ut . log    outputs / < trace >. log
Project 3 - Virtual Memory CS 2200 - Systems and Networks    Spring 2022



The second half of the output file name includes the type of replacement algorithm that should be run when comparing the output. Ex. astar-random.log should be compared with the output from using random replacement algorithm (−rrandom) as shown below.
    • ./ vm - sim  -i  traces / astar - random . trace  - rrandom  >  my _o ut pu t . log

    • diff  m y_ ou tp ut . log  outputs / astar - random . log

You MUST implement the Clock Sweep algorithm in order to test against all the *-clocksweep.log output files.

NOTE: To get full credit you must completely match the TA generated outputs for each trace.

14    How to Submit

Run make submit to automatically package your project for submission. Submit the resulting tar.gz zip on Canvas.

Always re-download your assignment from Canvas after submitting to ensure that all necessary files were properly uploaded. If what we download does not work, you will get a 0 regardless of what is on your machine.

This project will be demoed. In order to receive full credit, you must sign up for a demo slot and complete the demo. We will announce when demo times are released.

More products