GUF-Yocto-jethro-9.0-r7707-0
i.MX6
User Manual
...
class AnotherClass
{
public:
AnotherClass();
};
...
class AClass
{
public:
void pub()
};
void TestClass2::pub()
{
static Anotherclass crashingInstance;
}
...
MainClass::MainClass()
{
AClass anInstance;
anInstace.pub();
}
...
11.2
Simple command line application debugging
We will take the C++ Hello World application
myapp
from chapter
[
I
7.2 Simple command-line application]
here
to show how to set up a remote debugging session with GDB using the Yocto SDK.
Though, most of the readers are intersted in using a debugger GUI this chapter is eesential since most debug-
ger GUIs for Linux,
including Eclipse CDT and QtCreator
, are frontends to GDB and the setup require an
understanding how GDB works in the background.
Modify thee
Makefile
as follows:
myapp: main.cpp
#
$(CXX) ${CXXFLAGS} -o $@ $<
$(CXX) ${CXXFLAGS} -O0 -o $@ $<
#
$(STRIP) $@
clean:
rm -f myapp *.o *~ *.bak
Since the code is debugged with
-O2
optimization, the debugger can’t cleanly relate object code to high level
source lines. That will result in problems on high level language (C/C++ in this case) stepping (the cursor will
jump arround) as already discussed in
[
I
. We add
-O0
to allow proper stepping.
Further, we do not strip the debug symbols, since they are needed for debugging. This topic was also already
discussed in
[
I
.
Now, we have to assure that the development host and the target device are connected to the same IP network.
Check the IP address of the target device:
root@santaro:~# ifconfig
eth0
Link encap:Ethernet
HWaddr 00:07:8E:1C:38:B2
inet addr:172.20.55.89
Bcast:172.20.255.255
Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST
MTU:1500
Metric:1
RX packets:84 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6792 (6.6 KiB)
TX bytes:4551 (4.4 KiB)
...
68