Author Topic: GDB debugger plugin, condition breakpoint fetched after first hit  (Read 6205 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6079
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I think it is a bug, right? See the debug logs:
Code
Selecting target: 
Code-completion
Adding source dir: F:\cb_sf_git\trunk\src\
Adding source dir: F:\cb_sf_git\trunk\src\
Adding file: .\codeblocks.exe
Changing directory to: F:/cb_sf_git/trunk/src/devel30
Set variable: PATH=.;F:\cb_sf_git\trunk\src\base\tinyxml;E:\code\wx\wxWidgets-3.0.0\lib\gcc_dll;F:\cb_sf_git\trunk\src\devel30;D:\mingw-builds\473\mingw32\bin;D:\mingw-builds\473\mingw32;E:\code\msys\PortableGit-1.8.5.2-preview20131230\cmd;E:\code\common_bin;D:\opencv246build\build-gcc482-release\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;D:\Program Files\TortoiseSVN\bin;D:\DrmemoryR1652\bin;E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll

[debug]Command-line: E:\code\gdb\mybuild\bin\gdb.exe -nx -fullname  -quiet  -args ./codeblocks.exe
[debug]Working dir : F:\cb_sf_git\trunk\src\devel30

Starting debugger: E:\code\gdb\mybuild\bin\gdb.exe -nx -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.7.50.20140120-cvs
[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 "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.7.50.20140120-cvs

[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 intel
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source E:\code\gdb\mybuild\bin\my.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory F:/cb_sf_git/trunk/src/
[debug]Source directories searched: F:/cb_sf_git/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]> break "F:/cb_sf_git/trunk/src/plugins/codecompletion/parser/parserthread.cpp:510"
[debug]No source file named F:/cb_sf_git/trunk/src/plugins/codecompletion/parser/parserthread.cpp.
[debug]Breakpoint 2 ("F:/cb_sf_git/trunk/src/plugins/codecompletion/parser/parserthread.cpp:510") pending.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: F:\cb_sf_git\trunk\src\devel30\codeblocks.exe --debug-log --no-dde --no-check-associations --multiple-instance --no-splash-screen --verbose -p debug

Child process PID: 1620

[debug][New Thread 1620.0x170]
[debug][New Thread 1620.0xf58]
[debug][New Thread 1620.0x890]
[debug][New Thread 1620.0xe60]
[debug][New Thread 1620.0xe3c]
[debug][New Thread 1620.0xd58]
[debug][New Thread 1620.0xeac]
[debug][New Thread 1620.0xca0]
[debug][Thread 1620.0xca0 exited with code 0]
[debug][New Thread 1620.0x5f0]
[debug][Thread 1620.0x5f0 exited with code 0]
[debug][New Thread 1620.0x88c]
[debug][Thread 1620.0x88c exited with code 0]
[debug][New Thread 1620.0x2e0]
[debug][Thread 1620.0x2e0 exited with code 0]
[debug][New Thread 1620.0x8e8]
[debug][Thread 1620.0x8e8 exited with code 0]
[debug][New Thread 1620.0xecc]
[debug][Thread 1620.0xecc exited with code 0]
[debug][New Thread 1620.0xf38]
[debug][Thread 1620.0xf38 exited with code 0]
[debug][New Thread 1620.0x900]
[debug][Thread 1620.0x900 exited with code 0]
[debug][New Thread 1620.0xe14]
[debug][Thread 1620.0xe14 exited with code 0]
[debug][New Thread 1620.0xb98]
[debug][Thread 1620.0xb98 exited with code 0]
[debug][New Thread 1620.0xe64]
[debug][Thread 1620.0xe64 exited with code 0]
[debug][New Thread 1620.0x918]
[debug][Thread 1620.0x918 exited with code 0]
[debug][New Thread 1620.0xe78]
[debug][New Thread 1620.0x744]
[debug][Thread 1620.0x744 exited with code 0]
[debug][New Thread 1620.0x3c0]
[debug][Thread 1620.0x3c0 exited with code 0]
[debug][Switching to Thread 1620.0xe78]
[debug]Breakpoint 2, ParserThread::Parse (this=0xb67f790) at F:\cb_sf_git\trunk\src\plugins\codecompletion\parser\parserthread.cpp:510
[debug]F:\cb_sf_git\trunk\src\plugins\codecompletion\parser\parserthread.cpp:510:17575:beg:0x53f0ff7
[debug]>>>>>>cb_gdb:

At F:\cb_sf_git\trunk\src\plugins\codecompletion\parser\parserthread.cpp:510

[debug]> condition 2 m_Tokenizer.m_IsReplaceParsing == true
[debug]>>>>>>cb_gdb:
[debug]> bt 30
[debug]#0  ParserThread::Parse (this=0xb67f790) at F:\cb_sf_git\trunk\src\plugins\codecompletion\parser\parserthread.cpp:510
[debug]#1  0x053eb15d in Parser::ParseBuffer (this=0x934dfe8, buffer="#define __DBL_MIN_EXP__ (-1021)\n#define __pentiumpro__ 1\n#define __UINT_LEAST16_MAX__ 65535\n#define __ATOMIC_ACQUIRE 2\n#define __FLT_MIN__ 1.17549435082228750797e-38F\n#define __UINT_LEAST8_TYPE__ unsi"..., isLocal=false, bufferSkipBlocks=false, isTemp=false, filename="", parentIdx=-1, initLine=0) at F:\cb_sf_git\trunk\src\plugins\codecompletion\parser\parser.cpp:708
[debug]#2  0x053fcfbe in ParserThreadedTask::Execute (this=0x8d64e18) at F:\cb_sf_git\trunk\src\plugins\codecompletion\parser\parserthreadedtask.cpp:79
[debug]#3  0x690b0233 in cbThreadPool::cbWorkerThread::Entry (this=0x934cfa8) at F:\cb_sf_git\trunk\src\sdk\cbthreadpool.cpp:216
[debug]#4  0x016b2b66 in wxThread::CallEntry() () from E:\code\wx\wxWidgets-3.0.0\lib\gcc_dll\wxmsw30u_gcc_cb.dll
[debug]#5  0x016b2c67 in wxThreadInternal::DoThreadStart(wxThread*) () from E:\code\wx\wxWidgets-3.0.0\lib\gcc_dll\wxmsw30u_gcc_cb.dll
[debug]#6  0x016b2e55 in wxThreadInternal::WinThreadStart(void*)@4 () from E:\code\wx\wxWidgets-3.0.0\lib\gcc_dll\wxmsw30u_gcc_cb.dll
[debug]#7  0x77c3a3b0 in msvcrt!_endthreadex () from C:\WINDOWS\system32\msvcrt.dll
[debug]#8  0x7c80b729 in KERNEL32!GetModuleFileNameA () from C:\WINDOWS\system32\kernel32.dll
[debug]#9  0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:

Continuing...

[debug]> cont
[debug]Continuing.


If the setting breakpoint command are something like:

Code
break "F:/cb_sf_git/trunk/src/plugins/codecompletion/parser/parserthread.cpp:510" if m_Tokenizer.m_IsReplaceParsing == true 

Then the bug can be fixed.
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.