1

I'm working on pset4 and trying to do the following:

Allow us to suggest that you also run copy within GDB while answering these questions as follows:

  • Click Debug atop CS50 IDE, which should open a new terminal window (toward the bottom of CS50 IDE) for GDB.
  • To the right of Command: within that terminal, you should see pset4/bmp/copy.c in a text box. To run copy within GDB with command-line arguments, change the contents of that text box to be, e.g., copy.c smiley.bmp copy.bmp.
  • Set a breakpoint within main (as by clicking to the left of the line number for main).
  • Then click Run (or Stop and then Run) within GDB’s terminal window and step through the program via GDB’s righthand panel, keeping an eye on bf and bi in particular.

For some reason, the debugger keeps on exiting automatically without having done anything.

This is a screenshot of what I'm seeing.

enter image description here

I'd really appreciate if you could help me out, thank you!

2

You need to pass GDB the complete path to your program, THEN whichever arguments you need.

Correct format: pset4/bmp/copy.c smiley.bmp copy.bmp

| improve this answer | |
  • I see thank you. Why do I need to pass the arguments? Aren't the 3 arguments: 0. copy.c 1. smiley.bmp 2. copy.bmp? – gloopit Aug 2 '16 at 2:23
  • You are right, those are the three arguments, but in the debugger case the first argument should be the whole path to the program you are trying to run since it doesn't know which folder you are currently exploring on any given terminal. – dLopez Aug 2 '16 at 2:26
  • I see. So I could have just left out the arguments when running the program in the debugger? Seeing as I have to input them anyway? – gloopit Aug 2 '16 at 2:47
  • No. The program needs its parameters since without them it would immediately fail your if (argc != 3) test and exit with error code1, even when debugging. The only thing you need to understand is that the debugger runs on your root folder, so if you dont specify the whole path for the executable it just wont know what program to debug. Carefully read the answer I posted, it should point you in the right direction. – dLopez Aug 2 '16 at 7:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .