My breakout program runs (sort of) with a few bugs. When I try to use gdb to help fix them, I get this:

(gdb) break main
Breakpoint 1 at 0x804a0e3
(gdb) run
Starting program: /home/jharvard/Dropbox/pset4/breakout1 

Breakpoint 1, 0x0804a0e3 in main ()
(gdb) n
Single stepping until exit from function main,
which has no line number information.
Detaching after fork from child process 15385.

Can someone help me understand what I might be doing wrong?

Thank you.

The output using "break 1" is:

(gdb) break 1
No symbol table is loaded.  Use the "file" command.

Here is the output from running gdb on ./breakout:


gdb) break 1
Breakpoint 1 at 0x804946e: file breakout.c, line 1.
(gdb) run
Starting program: /home/jharvard/Dropbox/pset4/breakout 

Breakpoint 1, main_ () at breakout.c:47
47      srand48(time(NULL));
(gdb) n
50      GWindow window = newGWindow(WIDTH, HEIGHT);
(gdb) n
Detaching after fork from child process 11442.
53      initBricks(window);
(gdb) n

Program received signal SIGPIPE, Broken pipe.
0xb7fff424 in __kernel_vsyscall ()
(gdb) n
Single stepping until exit from function __kernel_vsyscall,
which has no line number information.
_IO_new_file_write (f=0x808d2d8, data=0xb7ffc000, n=33) at fileops.c:1255
1255          if (count < 0)
(gdb) n
1257          f->_flags |= _IO_ERR_SEEN;
(gdb) n
1264      if (f->_offset >= 0)
(gdb) n

GDB excerpt from properly working breakout code:

111         else if (getY(ball) + getHeight(ball) >= getHeight(window))
(gdb) n
124      GEvent event = getNextEvent(MOUSE_EVENT);
(gdb) print getX(ball)
No symbol "getX" in current context.
(gdb) n
125         if (event != NULL)
(gdb) print event
$10 = (GEvent) 0x0
(gdb) n
138  GObject object = detectCollision(window, ball);
(gdb) n
141          if(object != NULL)
(gdb) n
153        if(object != NULL && object != paddle)
(gdb) n
167     }
(gdb) n
78     while (lives > 0 && bricks > 0)
(gdb) print bricks
$11 = 50
(gdb) print object
No symbol "object" in current context.

Try executing

break 1

instead of break main!

  • See above addition to original post. – Robert Feduniak Nov 3 '14 at 21:13
  • @RobertFeduniak try executing file breakout where breakout is the name of your executable then try again! – kzidane Nov 3 '14 at 21:18
  • Kareem: Do you mean rename my program, or run the CS50 framework (already named breakout) under gdb? – Robert Feduniak Nov 3 '14 at 23:32
  • @RobertFeduniak I'm sorry, are you trying to run gdb on the staff's implementation? If yes, then it's not compiled with debugging information and you won't be able to do that. If no, then I just noticed that your executable file is named breakout1 instead of breakout. So you should either rename your file to be breakout (that's what the grader expects to see) and execute the gdb command file breakout or to leave its name as it is and execute file breakout1 – kzidane Nov 4 '14 at 10:19
  • I tried renaming my draft breakout and got the same result. Sorry if I used wrong terminology--I also ran gdb on what David referred to as the "skeleton", which is the 183 line "breakout.c" after first using make to create a ./breakout. GDB worked on that, though of course there wasn't much for it to work on. – Robert Feduniak Nov 4 '14 at 18:02

You must log in to answer this question.

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