Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] GDB-GDBserver problem

Hi,

         As in my previous mails, we are using gdbserver to debug GTK based applications . The debugging worked perfectly in 3.1 but failed in 3.1.1,3.1.2 and 4.0 RC1 to figure out the problem i enabled the GDB MI logging and got the following output.

Output for 3.1

GDB (gdb)
[1,181,727,547,315] 1-gdb-set confirm off
[1,181,727,547,317] 1^done
[1,181,727,547,320] 2-gdb-set width 0
[1,181,727,547,320] (gdb)
[1,181,727,547,321] 2^done
[1,181,727,547,321] 3-gdb-set height 0
[1,181,727,547,322] (gdb)
[1,181,727,547,322] 3^done
[1,181,727,547,323] 4-interpreter-exec console echo
[1,181,727,547,323] (gdb)
[1,181,727,547,323] 4^done
[1,181,727,547,325] 5-gdb-show prompt
[1,181,727,547,325] (gdb)
[1,181,727,547,326] 5^done,value="(gdb) "
[1,181,727,547,328] 6-target-select remote localhost:1234
[1,181,727,547,328] (gdb)
[1,181,727,547,448] 6^connected,thread-id="0",frame={addr="0xb7f266b0",func="??",args=[]}
[1,181,727,547,459] (gdb)
[1,181,727,547,607] 7-gdb-set auto-solib-add on
[1,181,727,547,608] 7^done
[1,181,727,547,611] 8-gdb-set stop-on-solib-events 0
[1,181,727,547,611] (gdb)
[1,181,727,547,612] 8^done
[1,181,727,547,612] 9-gdb-set stop-on-solib-events 0
[1,181,727,547,613] (gdb)
[1,181,727,547,613] 9^done
[1,181,727,547,626] (gdb)
[1,181,727,547,658] 10-environment-cd /scratchbox/users/sheldon/home/sheldon/workspace/clock
[1,181,727,547,658] 10^done
[1,181,727,547,659] (gdb)
[1,181,727,547,878] 11-environment-directory /scratchbox/users/sheldon/home/sheldon/workspace/clock \
/scratchbox/users/sheldon/home/sheldon/workspace/clock/.settings /scratchbox/users/sheldon/home/shel\
don/workspace/clock/autom4te.cache /scratchbox/users/sheldon/home/sheldon/workspace/clock/images /sc\
ratchbox/users/sheldon/home/sheldon/workspace/clock/images/.svn /scratchbox/users/sheldon/home/sheld\
on/workspace/clock/images/.svn/prop-base /scratchbox/users/sheldon/home/sheldon/workspace/clock/imag\
es/.svn/props /scratchbox/users/sheldon/home/sheldon/workspace/clock/images/.svn/text-base /scratchb\
ox/users/sheldon/home/sheldon/workspace/clock/images/.svn/wcprops /scratchbox/users/sheldon/home/she\
ldon/workspace/clock/src /scratchbox/users/sheldon/home/sheldon/workspace/clock/src/.deps /scratchbo\
x/users/sheldon/home/sheldon/workspace/clock/src/.svn /scratchbox/users/sheldon/home/sheldon/workspa\
ce/clock/src/.svn/text-base /scratchbox/users/sheldon/home/sheldon/workspace/clock/src/.svn/wcprops
[1,181,727,547,883] 11^done,source-path="/scratchbox/users/sheldon/home/sheldon/workspace/clock:/scr\
atchbox/users/sheldon/home/sheldon/workspace/clock/.settings:/scratchbox/users/sheldon/home/sheldon/\
workspace/clock/autom4te.cache:/scratchbox/users/sheldon/home/sheldon/workspace/clock/images:/scratc\
hbox/users/sheldon/home/sheldon/workspace/clock/images/.svn:/scratchbox/users/sheldon/home/sheldon/w\
orkspace/clock/images/.svn/prop-base:/scratchbox/users/sheldon/home/sheldon/workspace/clock/images/.\
svn/props:/scratchbox/users/sheldon/home/sheldon/workspace/clock/images/.svn/text-base:/scratchbox/u\
sers/sheldon/home/sheldon/workspace/clock/images/.svn/wcprops:/scratchbox/users/sheldon/home/sheldon\
/workspace/clock/src:/scratchbox/users/sheldon/home/sheldon/workspace/clock/src/.deps:/scratchbox/us\
ers/sheldon/home/sheldon/workspace/clock/src/.svn:/scratchbox/users/sheldon/home/sheldon/workspace/c\
lock/src/.svn/text-base:/scratchbox/users/sheldon/home/sheldon/workspace/clock/src/.svn/wcprops:$cdi\
r:$cwd"
[1,181,727,547,885] (gdb)
[1,181,727,547,886] 12 info threads
[1,181,727,547,888] &"info threads\n"
[1,181,727,547,888] ~"  1 Thread 6511  "
[1,181,727,547,889] 12^done,frame={addr="0xb7f266b0",func="??",args=[]}
[1,181,727,547,889] (gdb)
[1,181,727,547,901] 13-data-list-register-names
[1,181,727,547,902] 13^done,register-names=["eax","ecx","edx","ebx","esp","ebp","esi","edi","eip","e\
flags","cs","ss","ds","es","fs","gs","st0","st1","st2","st3","st4","st5","st6","st7","fctrl","fstat"\
,"ftag","fiseg","fioff","foseg","fooff","fop","xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7\
","mxcsr","orig_eax","mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7"]
[1,181,727,547,904] (gdb)
[1,181,727,547,921] 14-stack-info-depth
[1,181,727,547,926] 14^done,depth="1"
[1,181,727,547,927] 15-stack-list-frames 0 1
[1,181,727,547,928] (gdb)
[1,181,727,547,928] 15^done,stack=[frame={level="0",addr="0xb7f266b0",func="??"}]
[1,181,727,547,963] (gdb)
[1,181,727,548,076] 16-break-insert -t main
[1,181,727,548,082] 16^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0804be\
60",func="main",file="clock.c",line="865",times="0"}
[1,181,727,548,083] (gdb)
[1,181,727,548,088] 17-exec-continue
[1,181,727,548,141] 17^running
[1,181,727,548,142] (gdb)
[1,181,727,551,226] ~"[Switching to Thread 16384]\n"
[1,181,727,551,272] 17*stopped,thread-id="2",frame={addr="0x0804be60",func="main",args=[{name="argc"\
,value="134528608"},{name="argv",value="0x1"}],file=" clock.c",line="865"}
[1,181,727,551,274] 18 info threads
[1,181,727,551,274] (gdb)
[1,181,727,551,276] &"info threads\n"
[1,181,727,551,299] ~"* 2 Thread 16384  "
[1,181,727,551,301] 18^done,frame={func="main",args=[{name="argc",value="134528608"},{name="argv",va\
lue="0x1"}],file="clock.c",line="865"}
[1,181,727,551,303] 19-stack-info-depth
[1,181,727,551,303] (gdb)
[1,181,727,551,304] 19^done,depth="1"
[1,181,727,551,304] 20-stack-list-frames 0 1
[1,181,727,551,305] (gdb)
[1,181,727,551,305] 20^done,stack=[frame={level="0",addr="0x0804be60",func="main",file="clock.c",lin\
e="865"}]
[1,181,727,551,307] 21-data-list-changed-registers
[1,181,727,551,307] (gdb)
[1,181,727,551,308] 21^done,changed-registers=["0","1","2","3","4","5","6","7","8","9","10","11","12\
","13","15","24","26","40","41"]
[1,181,727,551,312] 22 info sharedlibrary
[1,181,727,551,313] (gdb)
[1,181,727,551,313] &"info sharedlibrary\n"
[1,181,727,551,328] ~"From        To          Syms Read   Shared Object Library\n"
[1,181,727,551,328] ~"0xb7ba0080  0xb7e5cc84  Yes         /usr/local/lib/libgtk-directfb-2.0.so.0\n"
[1,181,727,551,328] ~"0xb7af2a40  0xb7b2cd64  Yes         /usr/local/lib/libgdk- directfb-2.0.so.0\n"
[1,181,727,551,329] ~"0xb7ace660  0xb7adaaf4  Yes         /usr/local/lib/libatk-1.0.so.0\n"
[1,181,727,551,335] ~"0xb7ab22b0  0xb7ac3a54  Yes         /usr/local/lib/libgdk_pixbuf- 2.0.so.0\n"
[1,181,727,551,335] ~"0xb7a8c4f0  0xb7aa3ad0  Yes         /lib/libm.so.6\n"
[1,181,727,551,335] ~"0xb7a82ce0  0xb7a86df4  Yes         /usr/local/lib/libpangocairo-1.0.so.0\n"
[1,181,727,551,335] ~"0xb7a47b50  0xb7a6b794  Yes         /usr/local/lib/libpango-1.0.so.0\n"
[1,181,727,551,335] ~"0xb79e6170  0xb7a34fb4  Yes         /usr/local/lib/libcairo.so.2\n"
[1,181,727,551,336] ~"0xb79ac0e0  0xb79d5f14  Yes         /usr/local/lib/libgobject- 2.0.so.0\n"
[1,181,727,551,418] ~"0xb79a3d00  0xb79a4d64  Yes         /usr/local/lib/libgmodule-2.0.so.0\n"
[1,181,727,551,418] ~"0xb791e2f0  0xb79683f4  Yes         /usr/local/lib/libglib-2.0.so.0\n "
[1,181,727,551,418] ~"0xb78b4980  0xb78fc2e4  Yes         /usr/local/lib/libfreetype.so.6\n"
[1,181,727,551,418] ~"0xb787be20  0xb789ef14  Yes         /usr/local/lib/libfontconfig.so.1\n"
[1,181,727,551,419] ~"0xb781ff40  0xb78699e4  Yes         /usr/local/lib/libdirectfb-1.0.so.0\n"
[1,181,727,551,419] ~"0xb7800de0  0xb780f424  Yes         /usr/local/lib/libz.so.1\n"
[1,181,727,551,419] ~"0xb77d75e0  0xb77fad64  Yes         /usr/local/lib/libpng12.so.0\n"
[1,181,727,551,419] ~"0xb77c6d30  0xb77d1174  Yes         /usr/local/lib/libfusion-1.0.so.0\n"
[1,181,727,551,419] ~"0xb77b4e80  0xb77c0944  Yes         /usr/local/lib/libdirect-1.0.so.0\n"
[1,181,727,551,421] ~"0xb7765170  0xb776da70  Yes         /lib/libpthread.so.0\n"
[1,181,727,551,421] ~"0xb775cc90  0xb775d920  Yes         /lib/libdl.so.2\n"
[1,181,727,551,421] ~"0xb7725a60  0xb7750d14  Yes         /usr/local/lib/libgtkmidp.so\n"
[1,181,727,551,422] ~"0xb76fdeb0  0xb7700804  Yes         /usr/local/lib/libcelapp.so\n"
[1,181,727,551,422] ~"0xb76f16e0  0xb76f8124  Yes         /usr/local/lib/libclpappmgr.so\n"
[1,181,727,551,422] ~"0xb76d5a70  0xb76e7674  Yes         /usr/local/lib/libdbus-glib-1.so.2\n"
[1,181,727,551,422] ~"0xb76a1b30  0xb76c8524  Yes         /usr/local/lib/libdbus- 1.so.3\n"
[1,181,727,551,422] ~"0xb7678c80  0xb7694f24  Yes         /usr/local/lib/libgconf-2.so.4\n"
[1,181,727,551,429] ~"0xb7574080  0xb764b17c  Yes         /lib/libc.so.6\n"
[1,181,727,551,429] ~"0xb7f26690  0xb7f3582f  Yes         /lib/ld- linux.so.2\n"
[1,181,727,551,429] ~"0xb752fa00  0xb755b1c4  Yes         /usr/local/lib/libpangoft2-1.0.so.0\n"
[1,181,727,551,429] ~"0xb7519020  0xb751dac0  Yes         /lib/librt.so.1\n"
[1,181,727,551,429] ~"0xb741b440  0xb74f0894  Yes         /usr/local/lib/libxml2.so.2\n"
[1,181,727,551,430] ~"0xb73fb870  0xb73fea94  Yes         /usr/local/lib/libnotify.so.1\n"
[1,181,727,551,430] ~"0xb73e75b0  0xb73f3790  Yes         /lib/libnsl.so.1\n"
[1,181,727,551,430] 22^done
[1,181,727,551,430] (gdb)
[1,181,727,551,989] 23-stack-list-arguments 0 0 0
[1,181,727,551,989] 23^done,stack-args=[frame={level="0",args=[name="argc",name="argv"]}]
[1,181,727,551,991] (gdb)
[1,181,727,551,993] 24-stack-list-locals 0
[1,181,727,551,994] 24^done,locals=[name="__PRETTY_FUNCTION__",name="err"]
[1,181,727,551,994] (gdb)
[1,181,727,552,232] 25-var-create - * argc
[1,181,727,552,263] 25^done,name="var1",numchild="0",type="int"
[1,181,727,552,263] (gdb)
[1,181,727,552,270] 26-var-evaluate-_expression_ var1
[1,181,727,552,271] 26^done,value="134528608"
[1,181,727,552,271] (gdb)
[1,181,727,552,285] 27-var-create - * argv
[1,181,727,552,286] 27^done,name="var2",numchild="1",type="char **"
[1,181,727,552,286] (gdb)
[1,181,727,552,288] 28-var-evaluate-_expression_ var2
[1,181,727,552,288] 28^done,value="0x1"
[1,181,727,552,289] (gdb)
[1,181,727,552,291] 29-var-create - * __PRETTY_FUNCTION__
[1,181,727,552,292] 29^done,name="var3",numchild="5",type="const char [5]"
[1,181,727,552,292] (gdb)
[1,181,727,552,297] 30-var-create - * err
[1,181,727,552,298] 30^done,name="var4",numchild="3",type="GError *"
[1,181,727,552,299] (gdb)
[1,181,727,552,301] 31 ptype GError *
[1,181,727,552,303] &"ptype GError *\n"
[1,181,727,552,303] ~"type = struct _GError {\n"
[1,181,727,552,303] ~"    GQuark domain;\n"
[1,181,727,552,304] ~"    gint code;\n"
[1,181,727,552,304] ~"    gchar *message;\n"
[1,181,727,552,304] ~"} *\n"
[1,181,727,552,304] 31^done
[1,181,727,552,304] (gdb)
[1,181,727,552,311] 32-var-evaluate-_expression_ var4
[1,181,727,552,312] 32^done,value="0x8049b00"
[1,181,727,552,312] (gdb)
[1,181,727,555,876] 33-exec-continue
[1,181,727,555,877] 33^running
[1,181,727,555,877] (gdb)
[1,181,727,561,011] 33*stopped,reason="exited-normally"
[1,181,727,561,012] (gdb)
[1,181,727,561,043] 34-data-evaluate-_expression_ $_exitcode
[1,181,727,561,044] 34^done,value="0"
[1,181,727,561,044] (gdb)
[1,181,727,561,211] 35-gdb-exit
[1,181,727,561,215] 35^exit


Output for 3.1.1/3.1.2/4.0RC*

1,181,728,251,279] gdb -q -nw -i mi /home/sheldon/workspace/clock/src/clock
[1,181,728,251,467] 1-gdb-set confirm off
[1,181,728,251,471] 1^done
[1,181,728,251,473] 2-gdb-set width 0
[1,181,728,251,473] (gdb)
[1,181,728,251,473] 2^done
[1,181,728,251,473] 3-gdb-set height 0
[1,181,728,251,474] (gdb)
[1,181,728,251,474] 3^done
[1,181,728,251,474] 4-interpreter-exec console echo
[1,181,728,251,474] (gdb)
[1,181,728,251,474] 4^done
[1,181,728,251,475] 5-gdb-show prompt
[1,181,728,251,475] (gdb)
[1,181,728,251,475] 5^done,value="(gdb) "
[1,181,728,251,478] 6-gdb-set auto-solib-add on
[1,181,728,251,478] (gdb)
[1,181,728,251,479] 6^done
[1,181,728,251,479] 7-gdb-set stop-on-solib-events 0
[1,181,728,251,479] (gdb)
[1,181,728,251,479] 7^done
[1,181,728,251,480] 8-gdb-set stop-on-solib-events 0
[1,181,728,251,480] (gdb)
[1,181,728,251,480] 8^done
[1,181,728,251,481] 9-target-select remote localhost:1234
[1,181,728,251,481] (gdb)
[1,181,728,251,487] 9^connected,thread-id="0",frame={addr="0xb7fdf6b0",func="??",args=[]}
[1,181,728,251,491] 10-environment-cd /scratchbox/users/sheldon/home/sheldon/workspace/clock
[1,181,728,251,491] (gdb)
[1,181,728,251,495] 10^done
[1,181,728,251,497] (gdb)
[1,181,728,251,549] 11-environment-directory /scratchbox/users/sheldon/home/sheldon/workspace/clock \
/scratchbox/users/sheldon/home/sheldon/workspace/clock/.settings /scratchbox/users/sheldon/home/shel\
don/workspace/clock/autom4te.cache /scratchbox/users/sheldon/home/sheldon/workspace/clock/images /sc\
ratchbox/users/sheldon/home/sheldon/workspace/clock/images/.svn /scratchbox/users/sheldon/home/sheld\
on/workspace/clock/images/.svn/prop-base /scratchbox/users/sheldon/home/sheldon/workspace/clock/imag\
es/.svn/props /scratchbox/users/sheldon/home/sheldon/workspace/clock/images/.svn/text-base /scratchb\
ox/users/sheldon/home/sheldon/workspace/clock/images/.svn/wcprops /scratchbox/users/sheldon/home/she\
ldon/workspace/clock/src /scratchbox/users/sheldon/home/sheldon/workspace/clock/src/.deps /scratchbo\
x/users/sheldon/home/sheldon/workspace/clock/src/.svn /scratchbox/users/sheldon/home/sheldon/workspa\
ce/clock/src/.svn/text-base /scratchbox/users/sheldon/home/sheldon/workspace/clock/src/.svn/wcprops
[1,181,728,251,552] 11^done,source-path="/scratchbox/users/sheldon/home/sheldon/workspace/clock:/scr\
atchbox/users/sheldon/home/sheldon/workspace/clock/.settings:/scratchbox/users/sheldon/home/sheldon/\
workspace/clock/autom4te.cache:/scratchbox/users/sheldon/home/sheldon/workspace/clock/images:/scratc\
hbox/users/sheldon/home/sheldon/workspace/clock/images/.svn:/scratchbox/users/sheldon/home/sheldon/w\
orkspace/clock/images/.svn/prop-base:/scratchbox/users/sheldon/home/sheldon/workspace/clock/images/.\
svn/props:/scratchbox/users/sheldon/home/sheldon/workspace/clock/images/.svn/text-base:/scratchbox/u\
sers/sheldon/home/sheldon/workspace/clock/images/.svn/wcprops:/scratchbox/users/sheldon/home/sheldon\
/workspace/clock/src:/scratchbox/users/sheldon/home/sheldon/workspace/clock/src/.deps:/scratchbox/us\
ers/sheldon/home/sheldon/workspace/clock/src/.svn:/scratchbox/users/sheldon/home/sheldon/workspace/c\
lock/src/.svn/text-base:/scratchbox/users/sheldon/home/sheldon/workspace/clock/src/.svn/wcprops:$cdi\
r:$cwd"
[1,181,728,251,553] (gdb)
[1,181,728,251,554] 12 info threads
[1,181,728,251,554] &"info threads\n"
[1,181,728,251,556] ~"  1 Thread 7424  "
[1,181,728,251,556] 12^done,frame={addr="0xb7fdf6b0",func="??",args=[]}
[1,181,728,251,556] (gdb)
[1,181,728,251,561] 13-thread-select 1
[1,181,728,251,562] 13^done,new-thread-id="1",frame={level="0",addr="0xb7fdf6b0",func="??",args=[]}
[1,181,728,251,562] (gdb)
[1,181,728,251,564] 14 info threads
[1,181,728,251,564] &"info threads\n"
[1,181,728,251,564] ~"* 1 Thread 7424  "
[1,181,728,251,564] 14^done,frame={addr="0xb7fdf6b0",func="??",args=[]}
[1,181,728,251,565] (gdb)
[1,181,728,251,565] 15-stack-info-depth
[1,181,728,251,568] 15^done,depth="1"
[1,181,728,251,568] (gdb)
[1,181,728,251,580] 16-data-list-register-names
[1,181,728,251,583] 16^done,register-names=["eax","ecx","edx","ebx","esp","ebp","esi","edi","eip","e\
flags","cs","ss","ds","es","fs","gs","st0","st1","st2","st3","st4","st5","st6","st7","fctrl","fstat"\
,"ftag","fiseg","fioff","foseg","fooff","fop","xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7\
","mxcsr","orig_eax","mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7"]
[1,181,728,251,584] (gdb)
[1,181,728,251,597] 17-stack-list-frames 0 1
[1,181,728,251,607] 17^done,stack=[frame={level="0",addr="0xb7fdf6b0",func="??"}]
[1,181,728,251,613] (gdb)
[1,181,728,251,614] 18-break-insert -t main
[1,181,728,251,614] 18^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0804be\
60",func="main",file="clock.c",line="865",times="0"}
[1,181,728,251,635] (gdb)
[1,181,728,251,647] 19-exec-continue
[1,181,728,251,655] 19^running
[1,181,728,251,655] (gdb)
[1,181,728,260,123] 19*stopped,reason="exited-normally"
[1,181,728,260,138] 20-data-evaluate-_expression_ $_exitcode
[1,181,728,260,125] (gdb)
[1,181,728,260,139] 20^done,value="0"
[1,181,728,260,139] (gdb)
[1,181,728,260,216] 21-gdb-exit
[1,181,728,260,219] 21^exit


the problem was due to the commands in red a thread select was fired in 3.1.1 which caused the debug session to fail. I made the following changes to Target class
/**
     * Do the real work of call -thread-list-ids.
     */
    public Thread[] getCThreads() throws CDIException {
        Thread[] cthreads = noThreads;
        try {
            lockTarget();
            RxThread rxThread = miSession.getRxThread();
            rxThread.setEnableConsole(false);
            CommandFactory factory = miSession.getCommandFactory();
            CLIInfoThreads tids = factory.createCLIInfoThreads ();
            // HACK/FIXME: gdb/mi thread-list-ids does not
            // show any newly create thread, we workaround by
            // issuing "info threads" instead.
            // MIThreadListIds tids = factory.createMIThreadListIds();
            // MIThreadListIdsInfo info = tids.getMIThreadListIdsInfo();
            miSession.postCommand(tids);
            CLIInfoThreadsInfo info = tids.getMIInfoThreadsInfo();
            int[] ids;
            String[] names;
            if (info == null) {
                ids = new int[0];
                names = new String[0];
            } else {
                ids = info.getThreadIds();
                names = info.getThreadNames();
                currentThreadId = info.getCurrentThread();
            }
            if (ids != null && ids.length > 0) {
                cthreads = new Thread[ ids.length];
                // Ok that means it is a multiThreaded.
                if (names != null && names.length == ids.length) {
                    for (int i = 0; i < ids.length; i++) {
                        cthreads[i] = new Thread(this, ids[i], names[i]);
                    }
                } else {
                    for (int i = 0; i < ids.length; i++) {
                        cthreads[i] = new Thread(this, ids[i]);
                    }
                }
            } else {
                // Provide a dummy.
                cthreads = new Thread[]{new Thread(this, 0)};
            }
            // FIX: When attaching there is no thread selected
            // We will choose the first one as a workaround.
            if (currentThreadId == 0 && cthreads.length > 0) {
                currentThreadId = cthreads[0].getId();               Similar to what is happening in 3.1
//                setCurrentThread(cthreads[0], false);               
            }
        } catch (MIException e) {
            // Do not throw anything in this case.
            throw new CDIException( e.getMessage());
        } finally {
            RxThread rxThread = miSession.getRxThread();
            rxThread.setEnableConsole(true);
            releaseTarget();
        }
        return cthreads;
    }

and things are working now, I would like to know if this is the way to go or there is better solution to this problem.

Regards,


Back to the top