Remote debugging using GDB


I'am trying to debugg a program loaded into a freescale M52233DEMO evaluation board.

I'am starting GDB and than connects to the ev-board using the following command:

target remote | m68k-elf-cfpe-stub -d USBMultilink -t m52235evb

I can than communicate with the board using different GDB commands. I can view memory and register content, disassemble, set and view breakpoints. So it seams to work ok. But! At this stage I se that my programcounter is pointing att some odd point in memory. Probably due to some bug in my program. Than I want to set a breakpoint and restart the program, and as beginner at using GDB I found in the manual that this is done using the 'run' command. But then I get:

" (gdb) b start Breakpoint 6 at 0x408: file system/crt0.S, line 54. (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y

Starting program: C:\Projects\Test/test.elf Don't know how to run. Try "help target". "

And after this I have no conntact with my board any more.....

Why!? What to do? (And obviously, I have tried "help target", but now help there. I did use the target command to connect to the board).

Any help highly appreciated!

Rgds, Mats

Reply to
Loading thread data ...

Don't use the 'run' command. AFAICT, 'run' isn't aplicable to remote debugging.

Use the 'continue' command instead of 'run'. If you want to 'restart' your program, you might have to set the PC/SP/whatever to the proper values. Or depending on the target, you be able to 'load' the program to get things initialized:

(gdb) load 'myprog.elf' [...] (gdb) continue

Grant Edwards
Reply to
Grant Edwards

I didn't see in your description any indication that you have loaded the program into the target memory - don't forget that step!

When the program is loaded by gdb from a file with symbols (e.g., an elf file), gdb will set the program counter correctly to the entry point of the program. If your program is there from before (in flash, for example), you may have to set the program counter manually with something like "set $pc = start".

Exactly. It's a common (and understandable) mistake when first using gdb. "Run" is used by gdb to set up a program's environment, link in dynamic libraries, etc., which is only appropriate if you are using a proper OS. For most embedded work, what you want to do is make sure your program counter is at the program's entry point, and "continue" from the start.

Reply to
David Brown

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.