Discussion:
[Bug gdb/23443] New: Syntax error for watch -l and print
ftfish at gmail dot com
2018-07-24 08:12:51 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23443

Bug ID: 23443
Summary: Syntax error for watch -l and print
Product: gdb
Version: 8.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: ftfish at gmail dot com
Target Milestone: ---

Hi all,

I encountered a syntax error problem while debugging with `watch -l`.
The problem seems to happen when a class in a namespace has the same
name as the namespace.
A minimal working example:

# main.cpp
#include <iostream>

using namespace std;

namespace NS {

enum T {a, b, c};

class NS {
T field = b;
public:
void test() {
cout << field << endl;
}
};

}

int main()
{
NS::NS x;
x.test();

return 0;
}


# log
(gdb) b NS::NS::test
Breakpoint 1 at 0x40089c: file main.cpp, line 13.
(gdb) run
Starting program: /test/a.out

Breakpoint 1, NS::NS::test (this=0x7fffffffcb5c) at main.cpp:13
13 cout << field << endl;
(gdb) watch -l field
A syntax error in expression, near `) 0x00007fffffffcb5c'.
(gdb) p field
$1 = NS::b
(gdb) p &field
$2 = (NS::T *) 0x7fffffffcb5c
(gdb) watch *(NS::T *) 0x7fffffffcb5c
A syntax error in expression, near `) 0x7fffffffcb5c'.
(gdb) p *(NS::T *) 0x7fffffffcb5c
A syntax error in expression, near `) 0x7fffffffcb5c'.
(gdb) watch *(::NS::T *) 0x7fffffffcb5c
Hardware watchpoint 2: *(::NS::T *) 0x7fffffffcb5c
(gdb) p *(::NS::T *) 0x7fffffffcb5c
$3 = NS::b
(gdb) ptype NS
type = class NS::NS {
private:
NS::T field;

public:
void test(void);
}
(gdb) ptype ::NS
type = namespace NS
(gdb) watch -l this->field
A syntax error in expression, near `) 0x00007fffffffcb5c'.
(gdb)


GDB 8.1
C++ Compiler: gcc-7.2.1 linuxx86_64
OS: SUSE Linux Enterprise 12 SP2, 64bit
Compiler arguments: g++ -g main.cpp

Any help/pointer is appreciated. To me it seems a bug because `watch`
works but `watch -l` does not.

Thanks
Joe
--
You are receiving this mail because:
You are on the CC list for the bug.
ftfish at gmail dot com
2018-07-24 08:18:43 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23443

Joe <ftfish at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE

--- Comment #1 from Joe <ftfish at gmail dot com> ---
Sorry, double post due to a bad gateway error.

*** This bug has been marked as a duplicate of bug 23444 ***
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...