Author Topic: Frame issue with the debugger plugin  (Read 39910 times)

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Frame issue with the debugger plugin
« on: March 30, 2015, 01:48:23 pm »
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Frame issue with the debugger plugin
« Reply #1 on: March 30, 2015, 09:20:50 pm »
Post the full debugger log. Screenshots doesn't help much.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Frame issue with the debugger plugin
« Reply #2 on: March 31, 2015, 12:28:44 am »
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 ?? ()

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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Frame issue with the debugger plugin
« Reply #3 on: March 31, 2015, 09:25:48 am »
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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Frame issue with the debugger plugin
« Reply #4 on: March 31, 2015, 02:11:42 pm »
There are two places where a frame command is issued:
1. gdb_commands.h:1185
2. gdb_driver.cpp:609
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.

I guess in your env sizeof(unsigned long)==32==sizeof(int).
AFAIK that is the case for mingw and msvc resulting from the Windows' ABI which I believe is quite unfortunate.

p.s. don't look at gdb/mi it has not been updated for a long time.
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Frame issue with the debugger plugin
« Reply #5 on: March 31, 2015, 02:43:01 pm »
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.
I don't intend to do any work on the gdb/mi plugin before I can find some time to design a regression test system.
If there is not such system adding new features is extremely hard, because it is pretty easy to break old features.
Then you can fix the old feature, but you then break something else and you're running in circles wasting time.

This is the reason, I've left the plugin in a non-compilable state, so people are not wasting time trying to use it.
I have some more important tasks to finish first and probably then I'll try to continue working on it.

For the current patches, you can put them on github as a pull request, so they are not forgotten, but I don't intend to integrate them because of the aforementioned reasons.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Frame issue with the debugger plugin
« Reply #6 on: March 31, 2015, 02:45:23 pm »
About the gdb/cli patch:

Can you replace the wxstring::format with the usage of operator<< and see if it works correctly?
The reason I'm asking this is that the different format specifiers can have different meanings on different OSes, so I think that operator<< will be safer.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Frame issue with the debugger plugin
« Reply #7 on: March 31, 2015, 04:10:08 pm »
I too didn't like the format specifier defaulting to '%llu' for both 32-bit and 64-bit platforms but it looks like 'wxString' doesn't have an 'operator<<' defined for 'long long' type:
http://docs.wxwidgets.org/trunk/classwx_string.html#concat

What do you suggest?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Frame issue with the debugger plugin
« Reply #8 on: March 31, 2015, 09:13:22 pm »
Use:
1. stringstream, not sure if it really good idea
2. SCNu64 defined in inttypes.h  -> str.Format(wxT("frame %" SCNu64), number) I'm not sure how portable is this
3. Use uint32_t for the frame number

If I were you I'd try 2 and 3 and if I couldn't make it will do it with 1.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Frame issue with the debugger plugin
« Reply #9 on: March 31, 2015, 09:39:50 pm »
1- Me neither!
2- Will that be more portable than 'llu'?
3- That doesn't work already.

I think it will be best to stick with 'llu' for now until cb gets upgraded to a higher wxwidgets version in which wxstring has an operator<< for 'long long' type. Or conditional compilation?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Frame issue with the debugger plugin
« Reply #10 on: March 31, 2015, 11:44:08 pm »
2. Yes, it should be more portable. Otherwise why they'll add a macro. Probably it is not implemented by vc++, but we don't care much about it anyway.
3. This will require more changes. Probably track where the original value for the frame index is taken from and see why it is a long instead of uint32.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Frame issue with the debugger plugin
« Reply #11 on: April 01, 2015, 12:10:51 am »
3. This will require more changes. Probably track where the original value for the frame index is taken from and see why it is a long instead of uint32.
Well, I think that is what needs to be done. I think I spoke too soon that it worked, it's broken again for no obvious reason. Another issue, looking at the wxstring documentation, it has an 'operator<<' defined for a 'wxlonglong_t' type. From my understanding of 'wxlonglong_t' definition, it is defined as 'long long' for 64-bit compilers matching the definition of 'size_t'. That means 'operator<<' with an argument of 'size_t' should work correctly on a wxstring object. Can you please point me to the piece of code where the frame info is parsed, is it 'GDB_driver::ParseOutput'?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Frame issue with the debugger plugin
« Reply #12 on: April 07, 2015, 12:22:50 am »
Have you tried using a debugger to trace where bad value is generated from?

It is perfectly possible to debug cb, while debugging another application. It is a little odd, but works:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Frame issue with the debugger plugin
« Reply #13 on: April 07, 2015, 01:15:41 am »
Yes, many times but I quit after getting errors like:
Code
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
I don't know if it's CB related or something else but I can't deal with it. If you want to see the debug log:
Code
Active debugger config: GDB/CDB debugger:GDB
Building to ensure sources are up-to-date
Selecting target:
Debugger
Adding source dir: D:\coding\projects\sw\codeblocks\trunk\src\
Adding source dir: D:\coding\projects\sw\codeblocks\trunk\src\
Adding file: .\codeblocks.exe
Changing directory to: D:/coding/projects/sw/codeblocks/trunk/src/devel_64
Set variable: PATH=.;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\4.9.2\x64_seh\bin;C:\Tools\mingw\x64_seh\bin;C:\Tools\mingw\x64_seh;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;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\tdm\4.9.2\x64_seh\bin\gdb.exe -fullname -quiet  -args ./codeblocks.exe
[debug]Working dir : D:\coding\projects\sw\codeblocks\trunk\src\devel_64

Starting debugger: C:\Tools\tdm\4.9.2\x64_seh\bin\gdb.exe -fullname -quiet  -args ./codeblocks.exe
done

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

Setting breakpoints

[debug]Reading symbols from ./codeblocks.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 disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory D:/coding/projects/sw/codeblocks/trunk/src/
[debug]Source directories searched: D:/coding/projects/sw/codeblocks/trunk/src;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> set args --debug-log --no-dde --no-check-associations --multiple-instance --no-splash-screen --verbose -p debug
[debug]>>>>>>cb_gdb:
[debug]> source D:\coding\lib\pprinters\wx28.gdb
[debug]>>>>>>cb_gdb:
[debug]> break "D:/coding/projects/sw/codeblocks/trunk/src/plugins/debuggergdb/gdb_driver.cpp:779"
[debug]No source file named D:/coding/projects/sw/codeblocks/trunk/src/plugins/debuggergdb/gdb_driver.cpp.
[debug]Breakpoint 2 ("D:/coding/projects/sw/codeblocks/trunk/src/plugins/debuggergdb/gdb_driver.cpp:779") pending.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: D:\coding\projects\sw\codeblocks\trunk\src\devel_64\codeblocks.exe --debug-log --no-dde --no-check-associations --multiple-instance --no-splash-screen --verbose -p debug

Child process PID: 4820

[debug][New Thread 4820.0x14c4]
[debug][New Thread 4820.0x4e4]
[debug][New Thread 4820.0xf30]
[debug][New Thread 4820.0x794]
[debug][New Thread 4820.0x15f8]
[debug][New Thread 4820.0x1718]
[debug][New Thread 4820.0x1748]
[debug][New Thread 4820.0x156c]
[debug][New Thread 4820.0x2bc]
[debug][New Thread 4820.0x1320]
[debug][Thread 4820.0x1320 exited with code 0]
[debug][New Thread 4820.0x1508]
[debug][Thread 4820.0x1508 exited with code 0]
[debug][New Thread 4820.0x1654]
[debug][Thread 4820.0x1654 exited with code 0]
[debug][New Thread 4820.0x4b8]
[debug][Thread 4820.0x4b8 exited with code 0]
[debug][New Thread 4820.0x13c0]
[debug][Thread 4820.0x13c0 exited with code 0]
[debug][New Thread 4820.0x1120]
[debug][Thread 4820.0x1120 exited with code 0]
[debug][New Thread 4820.0x1158]
[debug][Thread 4820.0x1158 exited with code 0]
[debug][New Thread 4820.0x1500]
[debug][Thread 4820.0x1500 exited with code 0]
[debug][New Thread 4820.0x1698]
[debug][Thread 4820.0x1698 exited with code 0]
[debug][New Thread 4820.0x16d8]
[debug][Thread 4820.0x16d8 exited with code 0]
[debug][New Thread 4820.0x11a0]
[debug][Thread 4820.0x11a0 exited with code 0]
[debug][New Thread 4820.0xcec]
[debug][Thread 4820.0xcec exited with code 0]
[debug][New Thread 4820.0xca8]
[debug][Thread 4820.0xca8 exited with code 0]
[debug][New Thread 4820.0xfdc]
[debug][Thread 4820.0xfdc exited with code 0]
[debug][New Thread 4820.0x110c]
[debug][Thread 4820.0x110c exited with code 0]
[debug][New Thread 4820.0x1150]
[debug][Thread 4820.0x1150 exited with code 0]
[debug][New Thread 4820.0x330]
[debug][Thread 4820.0x330 exited with code 0]
[debug][New Thread 4820.0x17ac]
[debug][Thread 4820.0x17ac exited with code 0]
[debug][New Thread 4820.0xc5c]
[debug][Thread 4820.0xc5c exited with code 0]
[debug][New Thread 4820.0x1528]
[debug][New Thread 4820.0xbc8]
[debug][Thread 4820.0xbc8 exited with code 0]
[debug][New Thread 4820.0x1358]
[debug][New Thread 4820.0x1098]
[debug][Thread 4820.0x1098 exited with code 0]
[debug][New Thread 4820.0x103c]
[debug][Thread 4820.0x103c exited with code 0]
[debug][New Thread 4820.0x1674]
[debug][Thread 4820.0x1674 exited with code 0]
[debug][Thread 4820.0x15f8 exited with code 0]
[debug][New Thread 4820.0x14ec]
[debug]Breakpoint 2, GDB_driver::ParseOutput (this=0x161122d0, output="Reading symbols from D:/coding/projects/misc/exCpp/bin/Debug/exCpp.exe...done.") at D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779
[debug]D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779:27381:beg:0xafee15b
[debug]>>>>>>cb_gdb:

At D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779

[debug]> info args
[debug]this = 0x161122d0
[debug]output = "Reading symbols from D:/coding/projects/misc/exCpp/bin/Debug/exCpp.exe...done."
[debug]>>>>>>cb_gdb:
[debug]> bt 30
[debug]#0  GDB_driver::ParseOutput (this=0x161122d0, output="Reading symbols from D:/coding/projects/misc/exCpp/bin/Debug/exCpp.exe...done.") at D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779
[debug]#1  0x000000000afdecf2 in DebuggerGDB::ParseOutput (this=0x70a6880, output="Reading symbols from D:/coding/projects/misc/exCpp/bin/Debug/exCpp.exe...done.") at D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\debuggergdb.cpp:1691
[debug]#2  0x000000000afdfc91 in DebuggerGDB::OnGDBOutput (this=0x70a6880, event=...) at D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\debuggergdb.cpp:1826
[debug]#3  0x0000000062786541 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#4  0x0000000062786603 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#5  0x00000000627869b7 in wxEvtHandler::ProcessEvent(wxEvent&) () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#6  0x000000006278645e in wxEvtHandler::ProcessPendingEvents() () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#7  0x00000000627016d9 in wxAppConsole::ProcessPendingEvents() () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#8  0x0000000062b553e0 in wxIdleWakeUpModule::MsgHookProc(int, unsigned long long, long long) () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#9  0x00000000770d797c in USER32!GetKeyboardLayoutList () from C:\Windows\system32\user32.dll
[debug]#10 0x00000000770df5fb in USER32!SystemParametersInfoW () from C:\Windows\system32\user32.dll
[debug]#11 0x00000000770e4895 in USER32!IsProcessDPIAware () from C:\Windows\system32\user32.dll
[debug]#12 0x00000000773411f5 in ntdll!KiUserCallbackDispatcher () from C:\Windows\SYSTEM32\ntdll.dll
[debug]#13 0x00000000770eef0a in USER32!GetClipboardData () from C:\Windows\system32\user32.dll
[debug]#14 0x00000000770d5466 in USER32!LockWindowStation () from C:\Windows\system32\user32.dll
[debug]#15 0x00000000055e90f0 in ?? ()
[debug]Backtrace stopped: previous frame inner to this frame (corrupt stack?)
[debug]>>>>>>cb_gdb:

Continuing...

[debug]> cont
[debug]Continuing.
[debug]Breakpoint 2, GDB_driver::ParseOutput (this=0x161122d0, output="(gdb) >>>>>>cb_gdb:") at D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779
[debug]> info frame
[debug]D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779:27381:beg:0xafee15b
[debug]>>>>>>cb_gdb:

At D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779

[debug]> info args
[debug]Stack level 0, frame at 0x22f5c0:
[debug] rip = 0xafee15b in GDB_driver::ParseOutput (D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779); saved rip = 0xafdecf2
[debug] called by frame at 0x22f5f0
[debug] source language c++.
[debug] Arglist at 0x22f120, args: this=0x161122d0, output="(gdb) >>>>>>cb_gdb:"
[debug]> bt 30
[debug] Locals at 0x22f120, Previous frame's sp is 0x22f5c0
[debug] Saved registers:
[debug]  rbx at 0x22f598, rsi at 0x22f5a0, rdi at 0x22f5a8, rbp at 0x22f5b0, rip at 0x22f5b8, xmm15 at 0x22f5b8
[debug]>>>>>>cb_gdb:this = 0x161122d0
[debug]output = "(gdb) >>>>>>cb_gdb:"
[debug]>>>>>>cb_gdb:#0  GDB_driver::ParseOutput (this=0x161122d0, output="(gdb) >>>>>>cb_gdb:") at D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\gdb_driver.cpp:779
[debug]#1  0x000000000afdecf2 in DebuggerGDB::ParseOutput (this=0x70a6880, output="(gdb) >>>>>>cb_gdb:") at D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\debuggergdb.cpp:1691
[debug]#2  0x000000000afdfc91 in DebuggerGDB::OnGDBOutput (this=0x70a6880, event=...) at D:\coding\projects\sw\codeblocks\trunk\src\plugins\debuggergdb\debuggergdb.cpp:1826
[debug]#3  0x0000000062786541 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#4  0x0000000062786603 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#5  0x00000000627869b7 in wxEvtHandler::ProcessEvent(wxEvent&) () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#6  0x000000006278645e in wxEvtHandler::ProcessPendingEvents() () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#7  0x00000000627016d9 in wxAppConsole::ProcessPendingEvents() () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#8  0x0000000062b553e0 in wxIdleWakeUpModule::MsgHookProc(int, unsigned long long, long long) () from D:\coding\projects\sw\codeblocks\trunk\src\devel_64\wxmsw28u_gcc_custom.dll
[debug]#9  0x00000000770d797c in USER32!GetKeyboardLayoutList () from C:\Windows\system32\user32.dll
[debug]#10 0x00000000770df5fb in USER32!SystemParametersInfoW () from C:\Windows\system32\user32.dll
[debug]#11 0x00000000770e4895 in USER32!IsProcessDPIAware () from C:\Windows\system32\user32.dll
[debug]#12 0x00000000773411f5 in ntdll!KiUserCallbackDispatcher () from C:\Windows\SYSTEM32\ntdll.dll
[debug]#13 0x00000000770eef0a in USER32!GetClipboardData () from C:\Windows\system32\user32.dll
[debug]#14 0x00000000770d5466 in USER32!LockWindowStation () from C:\Windows\system32\user32.dll
[debug]#15 0x00000000055e90f0 in ?? ()
[debug]Backtrace stopped: previous frame inner to this frame (corrupt stack?)
[debug]>>>>>>cb_gdb:

And I'm still not sure where to check for the faulty code as I didn't get an answer to my question:
Can you please point me to the piece of code where the frame info is parsed, is it 'GDB_driver::ParseOutput'?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Frame issue with the debugger plugin
« Reply #14 on: April 07, 2015, 01:48:21 am »
Yes, many times but I quit after getting errors like:
Code
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
I don't know if it's CB related or something else but I can't deal with it. If you want to see the debug log:
This is definitely an GDB issue. GDB tries to unwind frame through
Code
USER32!LockWindowStation () from C:\Windows\system32\user32.dll
But it failed.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.