Author Topic: break "filename:line" will not work in the futher gdb  (Read 28249 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: break "filename:line" will not work in the futher gdb
« Reply #15 on: April 06, 2012, 09:09:18 am »
This should be easy.  :)
Are you sure? I doubt pretty much.
But anyway patches welcome, but you have to test them a lot. Path with space, path with ::, linux, windows, etc...
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #16 on: April 07, 2012, 02:53:15 pm »
I have build gdb cvs 2012-04-07, I use PCX's gcc 4.6.3.
also I change the break command send from c::b to
Code
break "filename":line

I have a cbp project which I put in a folder name contains spaces, You can see the debug log:

Quote
Starting debugger: E:\code\gcc\myPCXMinGW463\bin\gdb.exe -nx -fullname  -quiet  -args E:/code/cb/TEST_C~1/SPACEF~1/hi/bin/Debug/hi.exe
done

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

Setting breakpoints

[debug]Reading symbols from E:\code\cb\TEST_C~1\SPACEF~1\hi\bin\Debug\hi.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.4.50.20120407-cvs
[debug]Copyright (C) 2012 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]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.4.50.20120407-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 debugevents on
[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]> source E:\code\gcc\myPCXMinGW463\bin\my.gdb

[debug]>>>>>>cb_gdb:>>>>>>cb_gdb:
[debug]> directory E:/code/cb/TEST_C~1/SPACEF~1/hi/
[debug]Source directories searched: E:/code/cb/TEST_C~1/SPACEF~1/hi;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "E:/code/cb/test_code/space folder/hi/main.cpp":7
[debug]Breakpoint 2 at 0x4013de: file E:\code\cb\test_code\space folder\hi\main.cpp, line 7.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: E:\code\cb\TEST_C~1\SPACEF~1\hi\bin\Debug\hi.exe
[debug]gdb: windows_init_thread_list

Child process PID: 3796

[debug][New Thread 3796.0x2e4]
[debug]Breakpoint 2, main () at E:\code\cb\test_code\space folder\hi\main.cpp:7
[debug]E:\code\cb\test_code\space folder\hi\main.cpp:7:62:beg:0x4013de
[debug]>>>>>>cb_gdb:

At E:\code\cb\test_code\space folder\hi\main.cpp:7

[debug]> set debugevents off
[debug]>>>>>>cb_gdb:
[debug]> next
[debug]E:\code\cb\test_code\space folder\hi\main.cpp:8:99:beg:0x401402
[debug]>>>>>>cb_gdb:


You can see, the breakpoint hit correctly, and next command also works OK.

PS: I have not quite familiar with Linux, so I can only test under Windows.
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: break "filename:line" will not work in the futher gdb
« Reply #17 on: April 07, 2012, 03:21:18 pm »
What about gdb7.4 (non-cvs) and gdb7.3/2/1 or 6.8 (don't care too much btw)?
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #18 on: April 08, 2012, 09:28:54 am »
First Patch:
https://developer.berlios.de/patch/?func=detailpatch&patch_id=3274&group_id=5358

This will let C::B support gdb(cvs, 7.5), and preserve the old gdb ( gdb7.4-gdb6.8 )  compatibility.

See my explanation in gdb maillist:
http://sourceware.org/ml/gdb-patches/2012-03/msg00899.html
« Last Edit: April 08, 2012, 10:57:06 am by ollydbg »
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: break "filename:line" will not work in the futher gdb
« Reply #19 on: April 08, 2012, 10:02:31 am »
Please add a line which demonstrates what kind of lines matches the new regex, because I'm not really sure.

Also your patch doesn't change the setting of breakpoints, why?

p.s. I guess you wanted to use preserve instead of deserve?
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #20 on: April 08, 2012, 10:54:51 am »
Please add a line which demonstrates what kind of lines matches the new regex, because I'm not really sure.
Here is what gdb7.4-gdb6.8 returned:
Code
[debug]> break "E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/token.cpp:64"
[debug]No source file named E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/token.cpp.
[debug]Breakpoint 2 ("E:/code/cb/cb_trunk/src/plugins/codecompletion/parser/token.cpp:64) pending.

Here is gdb cvs(7.5) returned:
Code
[debug]> break "E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain.cpp:29"
[debug]No source file named E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain.cpp.
[debug]Breakpoint 4 ("E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain.cpp:29") pending.

You see, the gdb cvs has a quote before right-parenthesis, but gdb7.4-gdb6.8 does not.

Quote
Also your patch doesn't change the setting of breakpoints, why?
I don't think the old gdb( 7.4-6.8 ) will works under command like
Code
break "filename":line
So, I don't change the bp command send from c::b.

Quote
p.s. I guess you wanted to use preserve instead of deserve?
Thanks, It should be "preserve". (My English is not quite good :))
« Last Edit: April 08, 2012, 11:00:01 am by ollydbg »
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: break "filename:line" will not work in the futher gdb
« Reply #21 on: April 08, 2012, 11:06:29 am »
Code
[debug]Breakpoint 4 ("E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain.cpp:29") pending.
Put this line in the patch as a comment and commit it.

Also this line: "Breakpoint ([0-9]+)[ \\t]\\(\\\"(.+):([0-9]+)(\"?)\\)[ \\t]pending\\." looks a bit better to me.
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #22 on: April 08, 2012, 11:09:22 am »
Code
[debug]Breakpoint 4 ("E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain.cpp:29") pending.
Put this line in the patch as a comment and commit it.

Also this line:
Code
"Breakpoint ([0-9]+)[ \\t]\\(\\\"(.+):([0-9]+)(\"?)\\)[ \\t]pending\\." 
looks a bit better to me.

OK, I will refine my patch and commit it, thanks fore the review.

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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #23 on: April 08, 2012, 11:19:32 am »
@OBF:
Do you think that all

Code
\\\"
should be turned to
Code
\"

You can see there is one instance before the position I changed.
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: break "filename:line" will not work in the futher gdb
« Reply #24 on: April 08, 2012, 11:22:35 am »
I'm not really sure about the number of \ in this. This is a copy paste from the second line in the regex testbed plugin.
The thing I want in there is (\"?), so it is clear that the " is optional.
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #25 on: April 08, 2012, 01:46:56 pm »
I'm not really sure about the number of \ in this. This is a copy paste from the second line in the regex testbed plugin.
The thing I want in there is (\"?), so it is clear that the " is optional.

I did further test, and I can confirm that
Code
\\\"
can be replaced by
Code
\"
, everything works OK.
This is because
Code
"
is not a special character in regular expression.

I will commit the patch below if there is no objections in a few days.
Code
Index: E:/code/cb/cb_trunk/src/plugins/debuggergdb/gdb_commands.h
===================================================================
--- E:/code/cb/cb_trunk/src/plugins/debuggergdb/gdb_commands.h (revision 7925)
+++ E:/code/cb/cb_trunk/src/plugins/debuggergdb/gdb_commands.h (working copy)
@@ -130,8 +130,11 @@
 static wxRegEx reBT4(_T("#([0-9]+)[ \\t]+(.+)[ \\t]in[ \\t](.+)")); // case #11
 // Breakpoint 1 at 0x4013d6: file main.cpp, line 8.
 static wxRegEx reBreakpoint(_T("Breakpoint ([0-9]+) at (0x[0-9A-Fa-f]+)"));
+// GDB7.4 and before will return:
 // Breakpoint 1 ("/home/jens/codeblocks-build/codeblocks-1.0svn/src/plugins/debuggergdb/gdb_commands.h:125) pending.
-static wxRegEx rePendingBreakpoint(_T("Breakpoint ([0-9]+)[ \t]\\(\\\"(.+):([0-9]+)\\)[ \t]pending\\."));
+// GDB7.5 and later will return:
+// Breakpoint 4 ("E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain.cpp:29") pending.
+static wxRegEx rePendingBreakpoint(_T("Breakpoint ([0-9]+)[ \t]\\(\"(.+):([0-9]+)(\"?)\\)[ \t]pending\\."));
 // Hardware assisted breakpoint 1 at 0x4013d6: file main.cpp, line 8.
 static wxRegEx reHWBreakpoint(_T("Hardware assisted breakpoint ([0-9]+) at (0x[0-9A-Fa-f]+)"));
 // Hardware watchpoint 1: expr
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: break "filename:line" will not work in the futher gdb
« Reply #26 on: April 08, 2012, 02:14:55 pm »
Go on...
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #27 on: April 09, 2012, 03:32:10 am »
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.