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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
break "filename:line" will not work in the futher gdb
« on: March 25, 2012, 04:25:25 am »
Hi, OBF, see this post:
http://sourceware.org/ml/gdb-patches/2012-03/msg00823.html

I have some discussion with gdb developers, and after the line specification rewrite, the command break "filename:line" will not work anymore, can we use this command with out "quotes" like:

Code
break "filename":line
or
break filename:line

I think it was easy to change in debugger plugin, right?
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: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #1 on: March 25, 2012, 05:00:53 am »
It this the only place I have to change? in file: gdb_commands.h
Code
class GdbCmd_AddBreakpoint : public DebuggerCmd
{
        DebuggerBreakpoint::Pointer m_BP;
    public:
        /** @param bp The breakpoint to set. */
        GdbCmd_AddBreakpoint(DebuggerDriver* driver, DebuggerBreakpoint::Pointer bp)
            : DebuggerCmd(driver),
            m_BP(bp)
        {
            // gdb doesn't allow setting the bp number.
            // instead, we must read it back in ParseOutput()...
            m_BP->index = -1;

            if (m_BP->enabled)
            {
                if (m_BP->type == DebuggerBreakpoint::bptCode)//m_BP->func.IsEmpty())
                {
                    wxString out = m_BP->filename;
                    // we add one to line,  because scintilla uses 0-based line numbers, while gdb uses 1-based
                    if (!m_BP->temporary)
                        m_Cmd << _T("break ");
                    else
                        m_Cmd << _T("tbreak ");
                    m_Cmd << _T('"') << out << _T(":") << wxString::Format(_T("%d"), m_BP->line) << _T('"');
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 #2 on: March 25, 2012, 11:22:21 am »
Probably.
What version of gdb has this feature? 7.4?
« Last Edit: March 25, 2012, 11:24:26 am by oBFusCATed »
(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: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #3 on: March 26, 2012, 02:33:12 am »
Probably.
I just remove the double-quote in the break command, and now setting bp works OK under c::b, but it looks like the removing bp works badly, maybe, the parsing output method should be changed also.
Quote
What version of gdb has this feature? 7.4?
This new feature is tested by one gdb developer(in his git gdb branch), I think it will be merged to the main trunk some days later. gdb 7.4 has already released(they won't add any new feature in the 7.4 branch), so I believe it will happen in gdb 7.5.

EDIT: As the change will break many IDE front end, I think there will be further discussions in gdb maillist.


« Last Edit: March 26, 2012, 03:33:31 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 #4 on: March 26, 2012, 06:34:21 am »
If it is not an official release, you're on your own, sorry. No time to support random gdb-testing-versions.
(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: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #5 on: March 26, 2012, 07:58:26 am »
If it is not an official release, you're on your own, sorry. No time to support random gdb-testing-versions.
Ok, never mind.
I will follow the discussions in gdb maillist, and response if the break command has changed.
Thanks.

PS: I'm looking forward to test/try your gdb mi plugin when they are ready.  :)
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 #6 on: March 26, 2012, 09:33:22 am »
You can get it for here: svn://cmpt.benbmp.org/cb_gdb_mi
It should be relatively usable.
(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 thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: break "filename:line" will not work in the futher gdb
« Reply #7 on: March 26, 2012, 12:06:23 pm »
Does "filename":line not make a lot more sense anyway, even now? That's assuming the current version supports that, of course.

If the present version supports this variant, I don't see why we should not use it. A line number should not contain anything that needs quoting, only a filename might. Insofar, only quoting the filename is a kind of sensible approach.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #8 on: March 26, 2012, 01:36:12 pm »
Does "filename":line not make a lot more sense anyway, even now? That's assuming the current version supports that, of course.

If the present version supports this variant, I don't see why we should not use it. A line number should not contain anything that needs quoting, only a filename might. Insofar, only quoting the filename is a kind of sensible approach.
The gdb developer Keith strongly suggest that the line number should not be quoted.
This feature "filename":line does not exist in the current gdb CVS or 7.4 branch, but I guess they still need some test. (Currently, the new line specification has already pass all the gdb build-in tests)

Change our debugger branch code is quite simple. For the
Code
break filename:line
Here is the patch:
Code
Index: E:/code/cb/cb_debugger_branch/src/plugins/debuggergdb/gdb_commands.h
===================================================================
--- E:/code/cb/cb_debugger_branch/src/plugins/debuggergdb/gdb_commands.h (revision 7909)
+++ E:/code/cb/cb_debugger_branch/src/plugins/debuggergdb/gdb_commands.h (working copy)
@@ -131,7 +131,7 @@
 // Breakpoint 1 at 0x4013d6: file main.cpp, line 8.
 static wxRegEx reBreakpoint(_T("Breakpoint ([0-9]+) at (0x[0-9A-Fa-f]+)"));
 // 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\\."));
+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
@@ -448,7 +448,7 @@
                         m_Cmd << _T("break ");
                     else
                         m_Cmd << _T("tbreak ");
-                    m_Cmd << _T('"') << out << _T(":") << wxString::Format(_T("%d"), m_BP->line) << _T('"');
+                    m_Cmd << out << _T(":") << wxString::Format(_T("%d"), m_BP->line);
                 }
                 else if (m_BP->type == DebuggerBreakpoint::bptData)
                 {
This patch works under both the official gdb or the gdb-line-spec-branch.

For
Code
break "filename":line
It should also be quite easy to implement. :)

To my point: I think mostly quote is not needed. (I exclude the case that file name does not contain spaces  :), I'm not sure gdb support this)
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 #9 on: March 26, 2012, 01:40:16 pm »
The quote was added because some people have their projects inside paths containing "code::blocks" and this is regarded as method/function specification.
(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: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #10 on: March 26, 2012, 01:50:01 pm »
The quote was added because some people have their projects inside paths containing "code::blocks" and this is regarded as method/function specification.
Ok, thanks, here is the new test from command line(under c::b debugger plugin)

Code
[debug]> break "E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain1.cpp":29
[debug]No source file named E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain1.cpp.
[debug]Breakpoint 6 ("E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain1.cpp":29) pending.
[debug]>>>>>>cb_gdb:

No source file named E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain1.cpp.
Breakpoint 6 ("E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain1.cpp":29) pending.
> break "E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain.cpp":35

[debug]> break "E:/code/cb/test_code/DebugDLLTest/TestDLL/dllmain.cpp":35
[debug]Breakpoint 7 at 0x684c1814: file E:\code\cb\test_code\DebugDLLTest\TestDLL\dllmain.cpp, line 35.
[debug]>>>>>>cb_gdb:

Breakpoint 7 at 0x684c1814: file E:\code\cb\test_code\DebugDLLTest\TestDLL\dllmain.cpp, line 35.


So, I'm now trying to adjust the reg. :)
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 #11 on: March 26, 2012, 02:08:00 pm »
So, I'm now trying to adjust the reg. :)
Good luck...
(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: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #12 on: March 26, 2012, 03:18:02 pm »
So, I'm now trying to adjust the reg. :)
Good luck...
Thanks, Done. Here is the new regular expression and patch:
Code
Index: E:/code/cb/cb_debugger_branch/src/plugins/debuggergdb/gdb_commands.h
===================================================================
--- E:/code/cb/cb_debugger_branch/src/plugins/debuggergdb/gdb_commands.h (revision 7909)
+++ E:/code/cb/cb_debugger_branch/src/plugins/debuggergdb/gdb_commands.h (working copy)
@@ -131,7 +131,7 @@
 // Breakpoint 1 at 0x4013d6: file main.cpp, line 8.
 static wxRegEx reBreakpoint(_T("Breakpoint ([0-9]+) at (0x[0-9A-Fa-f]+)"));
 // 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\\."));
+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
@@ -448,7 +448,7 @@
                         m_Cmd << _T("break ");
                     else
                         m_Cmd << _T("tbreak ");
-                    m_Cmd << _T('"') << out << _T(":") << wxString::Format(_T("%d"), m_BP->line) << _T('"');
+                    m_Cmd << _T('"') << out << _T("\":") << wxString::Format(_T("%d"), m_BP->line);
                 }
                 else if (m_BP->type == DebuggerBreakpoint::bptData)
                 {
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: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #13 on: March 27, 2012, 04:03:15 am »
FYI:
The command:
Code
break "filename:line" 
is reserved for compatibility.

In the future, the gdb bp pending response will have quote balance.

See:Re: [RFA 1/2] Linespec rewrite (update 2)
« Last Edit: March 27, 2012, 04:52:58 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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5921
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: break "filename:line" will not work in the futher gdb
« Reply #14 on: April 06, 2012, 02:13:35 am »
Again. The new linespec feature is now in GDB CVS HEAD, which means it will be official in GDB 7.5 (It also support using filename with spaces). I think we need to adjust the regex a little to support the new pattern and also keep the old GDB compatible. This should be easy.  :)
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.