# emacs + gdb



## balanga (Jun 3, 2018)

I'm hoping to single step through a program which has been compiled using gcc with the '-g' option so that I can use gdb, but I want to run it from within emacs. The program works fine on Linux but not on FreeBSD. It needs command line arguments and involves accessing a serial port (/dev/cuaU0).

Can anyone give me any tips on how to start debugging this program? 
I suspect the reason it doesn't work on FreeBSD is because serial port handling on FreeBSD is different to Linux... What to look for? Where to set breakpoints?


----------



## balanga (Jun 4, 2018)

This gives me a start... but keep hitting all sorts of errors like being told that I did not specify *-i=mi* on GDB's command line when I clearly did.

Trying to enter command line parameters is difficult since gdb seems to think the parameters are for gdb... not sure if I should put quotes around all the parameters...


----------



## balanga (Jun 4, 2018)

balanga said:


> Trying to enter command line parameters is difficult since gdb seems to think the parameters are for gdb... not sure if I should put quotes around all the parameters...



gdb --args executablename arg1 arg2 arg3


----------



## balanga (Jun 4, 2018)

Phishfry said:


> I know this post has nothing to do with gdb, I just thoght I would show you that sometimes you don't need to tear apart code to get a Linux program working.



In theory it should work because the serial port is specified as a command line parameter. There is no conf file.

I just want to figure out what happens when it tries to open the port... Shouldn't be too difficult... Getting the hang of gdb is proving to be the difficult bit.


----------



## shkhln (Jun 4, 2018)

balanga said:


> I just want to figure out what happens when it tries to open the port... Shouldn't be too difficult...



Run it with _truss_, look for the failing calls.


----------

