Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Frame issue with the debugger plugin

(1/14) > >>

scarphin:
I've compiled a 64-bit version of CB (svn10149) with a patched (some 64-bit friendly fixes) wxwidgets (2.8.12) on win7 x64. I've been using it for weeks without a single crash so far but I'm experiencing this weird debugger issue with frame numbers. The problem is the gdb/cdb debugger interprets the frame numbers incorrectly and sometimes debugger executes a 'frame ...' command and tries to switch to that undefined frame giving unexpected results. I'm using the word 'interpret' because this doesn't occur with a 32-bit build (same rev svn10149) of cb with the same project, same code, same settings, same gdb, same compiler, same everything... I believe this is something related to the 64-bit version. A screenshot below:


I also tried this with the gdb/mi plugin here -> http://forums.codeblocks.org/index.php?topic=16230.0
The problem doesn't occur with gdb/mi, screenshot below:


I'm aware that both gdb/cdb and gdb/mi plugins use different communication protocols and I believe the correct behavior with gdb/mi is a result of this fact but I really like to hunt down the incompability (I think) with gdb/cdb. Can someone point me in the direction of the code responsible for interpreting the gdb output? Is it the 'GDB_driver::ParseOutput' function or some regex? Thanks.

OS: Win7 x64

oBFusCATed:
Post the full debugger log. Screenshots doesn't help much.

scarphin:
Sorry, I was too biased to think that this is a 64-bit problem. Anyway debug log for gdb/cdb:

--- Code: ---Active debugger config: GDB/CDB debugger:GDB
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: D:\coding\projects\misc\exCpp\
Adding source dir: D:\coding\projects\misc\exCpp\
Adding file: D:\coding\projects\misc\exCpp\bin\Debug\exCpp.exe
Changing directory to: D:/coding/projects/misc/exCpp/bin/Debug/
Set variable: PATH=.;C:\Tools\mingw\4.9.2\x64_seh\bin;C:\Tools\mingw\4.9.2\x64_seh;C:\Tools\mingw\x64_seh\bin;C:\Tools\mingw\x64_seh;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files\MATLAB\R2011b\runtime\win64;C:\Program Files\MATLAB\R2011b\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Git\cmd;C:\Tools\msys64\bin;C:\Tools\python\2.7\x64;C:\Tools\python\2.7\x64\Scripts;C:\Tools\perl\5.20.1\x64\bin;C:\Tools\perl\5.20.1\x64\site\bin;D:\coding\lib\qt\4.8.6\x64_mingw-4.9.2_seh\bin;D:\coding\lib\opencv\2.4.10\x64_mingw-4.9.2_seh\bin;C:\Program Files\MiKTeX\miktex\bin\x64;C:\Program Files\Doxygen\bin;C:\Program Files (x86)\Graphviz\bin;C:\Program Files (x86)\Nmap;C:\Program Files (x86)\GPAC

[debug]Command-line: C:\Tools\mingw\4.9.2\x64_seh\bin\gdb.exe -fullname -quiet  -args D:/coding/projects/misc/exCpp/bin/Debug/exCpp.exe
[debug]Working dir : D:\coding\projects\misc\exCpp\bin\Debug

Starting debugger: C:\Tools\mingw\4.9.2\x64_seh\bin\gdb.exe -fullname -quiet  -args D:/coding/projects/misc/exCpp/bin/Debug/exCpp.exe
done

[debug]> set prompt >>>>>>cb_gdb:
[debug]Skip initializing the scripting!

Setting breakpoints

[debug]Reading symbols from D:/coding/projects/misc/exCpp/bin/Debug/exCpp.exe...
[debug]done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.8.1
[debug]Copyright (C) 2014 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-w64-mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.8.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory D:/coding/projects/misc/exCpp/
[debug]Source directories searched: D:/coding/projects/misc/exCpp;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "D:/coding/projects/misc/exCpp/src/main.cpp:13"
[debug]Breakpoint 2 at 0x4014fa: file D:\coding\projects\misc\exCpp\src\main.cpp, line 13.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: D:\coding\projects\misc\exCpp\bin\Debug\exCpp.exe

Child process PID: 2884

[debug][New Thread 2884.0x1254]
[debug]Breakpoint 2, testFunc (a_arg1=10, a_arg2=2) at D:\coding\projects\misc\exCpp\src\main.cpp:13
[debug]D:\coding\projects\misc\exCpp\src\main.cpp:13:185:beg:0x4014fa
[debug]>>>>>>cb_gdb:

At D:\coding\projects\misc\exCpp\src\main.cpp:13

[debug]> info args
[debug]a_arg1 = 10
[debug]a_arg2 = 2
[debug]>>>>>>cb_gdb:
[debug]> bt 30
[debug]#0  testFunc (a_arg1=10, a_arg2=2) at D:\coding\projects\misc\exCpp\src\main.cpp:13
[debug]#1  0x0000000000401545 in main (argc=1, argv=0x3f2700) at D:\coding\projects\misc\exCpp\src\main.cpp:23
[debug]>>>>>>cb_gdb:
[debug]> frame 198815440
[debug]#0  0x0000000000000000 in ?? ()
[debug]>>>>>>cb_gdb:

#0  0x0000000000000000 in ?? ()

--- End code ---

And for gdb/mi:

--- Code: ---Active debugger config: GDB/MI:Default
start debugger
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding file: D:\coding\projects\misc\exCpp\bin\Debug\exCpp.exe

[debug]PATH=.;C:\Tools\mingw\4.9.2\x64_seh\bin;C:\Tools\mingw\4.9.2\x64_seh;.;D:\coding\projects\sw\codeblocks\trunk\src\base\tinyxml;D:\coding\lib\wxwidgets\2.8.12\x64_tdm-4.9.2_seh\lib\gcc_dll;D:\coding\projects\sw\codeblocks\trunk\src\devel_64;C:\Tools\tdm\4.9.2\x64_seh\bin;C:\Tools\tdm\4.9.2\x64_seh;C:\Tools\mingw\x64_seh\bin;C:\Tools\mingw\x64_seh;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files\MATLAB\R2011b\runtime\win64;C:\Program Files\MATLAB\R2011b\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Git\cmd;C:\Tools\msys64\bin;C:\Tools\python\2.7\x64;C:\Tools\python\2.7\x64\Scripts;C:\Tools\perl\5.20.1\x64\bin;C:\Tools\perl\5.20.1\x64\site\bin;D:\coding\lib\qt\4.8.6\x64_mingw-4.9.2_seh\bin;D:\coding\lib\opencv\2.4.10\x64_mingw-4.9.2_seh\bin;C:\Program Files\MiKTeX\miktex\bin\x64;C:\Program Files\Doxygen\bin;C:\Program Files (x86)\Graphviz\bin;C:\Program Files (x86)\Nmap;C:\Program Files (x86)\GPAC

GDB path: C:\Tools\mingw\4.9.2\x64_seh\bin\gdb.exe
DEBUGGEE path: D:\coding\projects\misc\exCpp\bin\Debug\exCpp.exe
Command-line: C:\Tools\mingw\4.9.2\x64_seh\bin\gdb.exe -fullname  -quiet --interpreter=mi -args D:\coding\projects\misc\exCpp\bin\Debug\exCpp.exe
Working dir : D:\coding\projects\misc\exCpp\bin\Debug\
Starting debugger:

[debug]Executing command: C:\Tools\mingw\4.9.2\x64_seh\bin\gdb.exe -fullname  -quiet --interpreter=mi -args D:\coding\projects\misc\exCpp\bin\Debug\exCpp.exe

done

[debug]Executor stopped
[debug]Debugger_GDB_MI::CommitBreakpoints
[debug]ActionsMap::Run -> starting action: 00000000151F1210 id: 1
[debug]BreakpointAddAction::m_initial_cmd = 10000000000
[debug]cmd==>10000000000-break-insert -f D:\coding\projects\misc\exCpp\src\main.cpp:13
[debug]ActionsMap::Run -> starting action: 0000000015840890 id: 2
[debug]cmd==>20000000000-exec-arguments
[debug]output==>=thread-group-added,id="i1"
[debug]unparsable_output==>~"Reading symbols from D:\\coding\\projects\\misc\\exCpp\\bin\\Debug\\exCpp.exe..."
[debug]unparsable_output==>~"done.\n"
[debug]unparsable_output==>(gdb)
[debug]output==>10000000000^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004014fa",func="testFunc(int, int)",file="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",fullname="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",line="13",thread-groups=["i1"],times="0",original-location="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp:13"}
[debug]notification event recieved!
[debug]BreakpointAddAction::OnCommandResult: 10000000000
[debug]BreakpointAddAction::breakpoint index is 1
[debug]BreakpointAddAction::Finishing1
[debug]BreakpointAddAction::destructor
[debug]unparsable_output==>(gdb)
[debug]output==>20000000000^done
[debug]unparsable_output==>(gdb)
[debug]ActionsMap::Run -> starting action: 0000000015712B60 id: 3
[debug]RunAction::OnStart -> -exec-run
[debug]cmd==>30000000000-exec-run
[debug]output==>=thread-group-started,id="i1",pid="5740"
[debug]output==>=thread-created,id="1",group-id="i1"
[debug]unparsable_output==>~"[New Thread 5740.0x1254]\n"
[debug]output==>30000000000^running
[debug]output==>*running,thread-id="all"
[debug]unparsable_output==>(gdb)
[debug]output==>=library-loaded,id="C:\\Windows\\SYSTEM32\\ntdll.dll",target-name="C:\\Windows\\SYSTEM32\\ntdll.dll",host-name="C:\\Windows\\SYSTEM32\\ntdll.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\kernel32.dll",target-name="C:\\Windows\\system32\\kernel32.dll",host-name="C:\\Windows\\system32\\kernel32.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\KernelBase.dll",target-name="C:\\Windows\\system32\\KernelBase.dll",host-name="C:\\Windows\\system32\\KernelBase.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!

Found child pid: 5740


[debug]notification event recieved!
[debug]RunAction success, the debugger is !stopped!
[debug]RunAction::Output - type: result
class: running
results:

[debug]Executor started
[debug]notification event recieved!
[debug]notification event recieved!
[debug]notification event recieved!
[debug]notification event recieved!
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\msvcrt.dll",target-name="C:\\Windows\\system32\\msvcrt.dll",host-name="C:\\Windows\\system32\\msvcrt.dll",symbols-loaded="0",thread-group="i1"
[debug]RunAction::destructor
[debug]output==>=library-loaded,id="C:\\Tools\\mingw\\4.9.2\\x64_seh\\bin\\libstdc++-6.dll",target-name="C:\\Tools\\mingw\\4.9.2\\x64_seh\\bin\\libstdc++-6.dll",host-name="C:\\Tools\\mingw\\4.9.2\\x64_seh\\bin\\libstdc++-6.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Tools\\mingw\\4.9.2\\x64_seh\\opt\\bin\\libgcc_s_seh-1.dll",target-name="C:\\Tools\\mingw\\4.9.2\\x64_seh\\opt\\bin\\libgcc_s_seh-1.dll",host-name="C:\\Tools\\mingw\\4.9.2\\x64_seh\\opt\\bin\\libgcc_s_seh-1.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Tools\\mingw\\4.9.2\\x64_seh\\opt\\bin\\libwinpthread-1.dll",target-name="C:\\Tools\\mingw\\4.9.2\\x64_seh\\opt\\bin\\libwinpthread-1.dll",host-name="C:\\Tools\\mingw\\4.9.2\\x64_seh\\opt\\bin\\libwinpthread-1.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\user32.dll",target-name="C:\\Windows\\system32\\user32.dll",host-name="C:\\Windows\\system32\\user32.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\gdi32.dll",target-name="C:\\Windows\\system32\\gdi32.dll",host-name="C:\\Windows\\system32\\gdi32.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\lpk.dll",target-name="C:\\Windows\\system32\\lpk.dll",host-name="C:\\Windows\\system32\\lpk.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!
[debug]notification event recieved!
[debug]notification event recieved!
[debug]notification event recieved!
[debug]notification event recieved!
[debug]notification event recieved!
[debug]notification event recieved!
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\usp10.dll",target-name="C:\\Windows\\system32\\usp10.dll",host-name="C:\\Windows\\system32\\usp10.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\imm32.dll",target-name="C:\\Windows\\system32\\imm32.dll",host-name="C:\\Windows\\system32\\imm32.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\msctf.dll",target-name="C:\\Windows\\system32\\msctf.dll",host-name="C:\\Windows\\system32\\msctf.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\guard64.dll",target-name="C:\\Windows\\system32\\guard64.dll",host-name="C:\\Windows\\system32\\guard64.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\advapi32.dll",target-name="C:\\Windows\\system32\\advapi32.dll",host-name="C:\\Windows\\system32\\advapi32.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!
[debug]notification event recieved!
[debug]notification event recieved!
[debug]output==>=library-loaded,id="C:\\Windows\\SYSTEM32\\sechost.dll",target-name="C:\\Windows\\SYSTEM32\\sechost.dll",host-name="C:\\Windows\\SYSTEM32\\sechost.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\rpcrt4.dll",target-name="C:\\Windows\\system32\\rpcrt4.dll",host-name="C:\\Windows\\system32\\rpcrt4.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\psapi.dll",target-name="C:\\Windows\\system32\\psapi.dll",host-name="C:\\Windows\\system32\\psapi.dll",symbols-loaded="0",thread-group="i1"
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\version.dll",target-name="C:\\Windows\\system32\\version.dll",host-name="C:\\Windows\\system32\\version.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!
[debug]notification event recieved!
[debug]output==>=library-loaded,id="C:\\Windows\\system32\\fltLib.dll",target-name="C:\\Windows\\system32\\fltLib.dll",host-name="C:\\Windows\\system32\\fltLib.dll",symbols-loaded="0",thread-group="i1"
[debug]notification event recieved!
[debug]output==>=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004014fa",func="testFunc(int, int)",file="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",fullname="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",line="13",thread-groups=["i1"],times="1",original-location="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp:13"}
[debug]unparsable_output==>~"\nBreakpoint "
[debug]unparsable_output==>~"1, testFunc (a_arg1=10, a_arg2=2) at D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp:13\n"
[debug]unparsable_output==>~"\032\032D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp:13:185:beg:0x4014fa\n"
[debug]output==>*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x00000000004014fa",func="testFunc",args=[{name="a_arg1",value="10"},{name="a_arg2",value="2"}],file="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",fullname="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",line="13"},thread-id="1",stopped-threads="all"
[debug]unparsable_output==>(gdb)
[debug]notification event recieved!
[debug]notification event recieved!
[debug]Executor stopped
[debug]ActionsMap::Run -> starting action: 00000000156D5570 id: 4
[debug]cmd==>40000000000-stack-info-frame
[debug]cmd==>40000000001-stack-list-frames 0 30
[debug]cmd==>40000000002-stack-list-arguments 1 0 30
[debug]output==>40000000000^done,frame={level="0",addr="0x00000000004014fa",func="testFunc",file="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",fullname="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",line="13"}
[debug]unparsable_output==>(gdb)
[debug]output==>40000000001^done,stack=[frame={level="0",addr="0x00000000004014fa",func="testFunc",file="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",fullname="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",line="13"},frame={level="1",addr="0x0000000000401545",func="main",file="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",fullname="D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp",line="23"}]
[debug]unparsable_output==>(gdb)
[debug]output==>40000000002^done,stack-args=[frame={level="0",args=[{name="a_arg1",value="10"},{name="a_arg2",value="2"}]},frame={level="1",args=[{name="argc",value="1"},{name="argv",value="0x3628e0"}]}]
[debug]unparsable_output==>(gdb)
[debug]GenerateBacktrace::OnCommandOutput: tuple size 2 stack=[frame={level=0,addr=0x00000000004014fa,func=testFunc,file=D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp,fullname=D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp,line=13},frame={level=1,addr=0x0000000000401545,func=main,file=D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp,fullname=D:\\coding\\projects\\misc\\exCpp\\src\\main.cpp,line=23}]
[debug]GenerateBacktrace::OnCommandOutput arguments

--- End code ---

oBFusCATed:
This is definitely a bug and you'll have to debug it unfortunately.

There are two places where a frame command is issued:
1. gdb_commands.h:1185
2. gdb_driver.cpp:609

Put breakpoints there and inspect what happens. Probably you'll have to switch the types to something like uint64_t, because using int and long is unreliable. I guess in your env sizeof(unsigned long)==32==sizeof(int).

p.s. don't look at gdb/mi it has not been updated for a long time.

scarphin:

--- Quote from: oBFusCATed on March 31, 2015, 09:25:48 am ---There are two places where a frame command is issued:
1. gdb_commands.h:1185
2. gdb_driver.cpp:609

--- End quote ---
Ok I replaced the frame number variables to 'size_t' and it works for both 32-bit and 64-bit as 'size_t' corresponds to 'uint32' for 32-bit and 'uint64' for 64-bit.


--- Quote from: oBFusCATed on March 31, 2015, 09:25:48 am ---I guess in your env sizeof(unsigned long)==32==sizeof(int).

--- End quote ---
AFAIK that is the case for mingw and msvc resulting from the Windows' ABI which I believe is quite unfortunate.


--- Quote from: oBFusCATed on March 31, 2015, 09:25:48 am ---p.s. don't look at gdb/mi it has not been updated for a long time.

--- End quote ---
gdb/mi seems to be more stable than it currently looks and I think gdb/mi is the way to go. I may provide patches for added functionality and bug fixes. I don't have much experience with test cases but you've already provided an almost working plugin and many test cases to follow so I may add functionality first and then add test cases (I know it should be the opposite btw). I'll post my patches to the corresponding thread, it's up to you if you value them or not. ;)

I attached a patch demonstrating the necessary changes, thanks for your help.

Navigation

[0] Message Index

[#] Next page

Go to full version