1

I need some clarifications on how GDB works in the IDE environment on cloud9

Is there two things different types of debuggers that the IDE environment?

  • Debugger, through debug command input which looks does step by step compilation / checks inputs? (for source file)

  • GDB, which checks the executable program?

Also, how do you pass arguments into GDB? I can't seem to figure this out.

I'm looking at pset4 and want to run GDB on the executable "copy" and pass in an input and an output file name

how would i do that in the terminal

EDIT

also my debugger is always broken as well

1 Answer 1

3

To run GDB with arguments in the terminal, use the --args parameter.

gdb --args name arg1 arg2 arg3

debug50 (the graphical debugger) is just GDB with a GUI. GDB was originally designed to be run through the terminal, and still is. It is much more flexible than any graphical debugger.

However, here's some basics:

  • Step-by-step debugging: next (or n)
  • Setting a break point is done with break (or b) [function or line number], for example:

    break main or break 20 where '20' is the line to break.

  • Run the program with run (or r).

  • Use continue or c to skip to the next break point.

  • To print a variable inside GDB (not using printf()) type print varname.

Alternatively, now that you know a few commands, you can run your program with some arguments with [r]un arg1 arg2 arg3.

As for your issues with debug50, I'm sorry to say that debug50's predecessor was broken and it looks like debug50 is now also broken. I never managed to fix it at least.

2
  • thanks for the very indepth answer!. Also another question, is GDB preinstalled in some linux Bash environments and maybe windows command prompt? Commented Nov 3, 2016 at 21:12
  • GDB comes preinstalled in every Linux distribution as far as I know, and certainly in the most popular (arch, debian, ubuntu, etc..). To get it on Windows you might have to use Cygwin or MinGW (collections of Linux/GNU/POSIX tools and things), I don't know if the "official" download on the GDB download page gnu.org/software/gdb actually supports windows, I haven't tried. Commented Nov 3, 2016 at 21:29

You must log in to answer this question.

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