문제

I am writing a simulator program for a custom microcontroler in C++. I would like a user to be able to use GDB to debug their program as if it was running on the real target.

The best solution I've found seems to involve writing a GDB stub for my simulator that would communicate with GDB using a network protocol. However, this involves writing a complete program that would take care of network communication and communication with GDB itself.

This seems a bit overkill since the client and the target will be running on the same machine. Is there not a simpler way? If there is not, with the popularity of GDB, I would have thought that a library, or at least examples, would exist to help embedding a stub in a normal desktop PC program?

도움이 되었습니까?

해결책

You can certainly write a "stub" that is part of the main application - all that you need to do is listen to the relevant communications channel, and respond appropriately to the commands/data being sent.

Here's an article that fairly well describes the process of writing a stub: http://www.embecosm.com/appnotes/ean4/embecosm-howto-rsp-server-ean4-issue-2.html

It also discusses (albeit briefly) the "using a simulator".

다른 팁

GDB also supports "embedding" simulator into gdb itself. This is invoked by "target sim" command in gdb.

See sim subdirectory of gdb for a number of simulators already implemented.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top