Discussion:
Incorrect behavior in case of watchpoint
Aleksey Midenkov
2017-08-21 11:54:41 UTC
Permalink
I've set watchpoint with command `watch -l` and it was saved in
KDevelop session. Now it doesn't start debug session because it ends
up in endless loop:

(gdb) 2106-break-watch "-location m_part_spec.start_part"
2106^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2107-break-watch "-location m_part_spec.start_part"
2107^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2108-break-watch "-location m_part_spec.start_part"
2108^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2109-break-watch "-location m_part_spec.start_part"
2109^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2110-break-watch "-location m_part_spec.start_part"
2110^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
...

Though I've managed to delete breakpoint from Breakpoints tab and start again.
Aleix Pol
2017-09-01 11:55:00 UTC
Permalink
Post by Aleksey Midenkov
I've set watchpoint with command `watch -l` and it was saved in
KDevelop session. Now it doesn't start debug session because it ends
(gdb) 2106-break-watch "-location m_part_spec.start_part"
2106^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2107-break-watch "-location m_part_spec.start_part"
2107^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2108-break-watch "-location m_part_spec.start_part"
2108^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2109-break-watch "-location m_part_spec.start_part"
2109^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2110-break-watch "-location m_part_spec.start_part"
2110^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
...
Though I've managed to delete breakpoint from Breakpoints tab and start again.
Hey Aetf,
Any idea why that could be?

Aleix

PS: Aleksey, can you make sure this is reported in bugs.kde.org?
Aetf
2017-09-01 16:32:53 UTC
Permalink
Hi,

I'm afraid I don't have much time for this at the moment. Actually this has
been on my todo list for a while... I'll take a look at it soon.

Cheers,
Aetf
Post by Aleksey Midenkov
Post by Aleksey Midenkov
I've set watchpoint with command `watch -l` and it was saved in
KDevelop session. Now it doesn't start debug session because it ends
(gdb) 2106-break-watch "-location m_part_spec.start_part"
2106^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2107-break-watch "-location m_part_spec.start_part"
2107^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2108-break-watch "-location m_part_spec.start_part"
2108^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2109-break-watch "-location m_part_spec.start_part"
2109^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2110-break-watch "-location m_part_spec.start_part"
2110^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
...
Though I've managed to delete breakpoint from Breakpoints tab and start
again.
Hey Aetf,
Any idea why that could be?
Aleix
PS: Aleksey, can you make sure this is reported in bugs.kde.org?
Aleix Pol
2017-09-04 11:47:54 UTC
Permalink
Post by Aetf
Hi,
I'm afraid I don't have much time for this at the moment. Actually this has
been on my todo list for a while... I'll take a look at it soon.
Cheers,
Aetf
Post by Aleix Pol
Post by Aleksey Midenkov
I've set watchpoint with command `watch -l` and it was saved in
KDevelop session. Now it doesn't start debug session because it ends
(gdb) 2106-break-watch "-location m_part_spec.start_part"
2106^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2107-break-watch "-location m_part_spec.start_part"
2107^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2108-break-watch "-location m_part_spec.start_part"
2108^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2109-break-watch "-location m_part_spec.start_part"
2109^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2110-break-watch "-location m_part_spec.start_part"
2110^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
...
Though I've managed to delete breakpoint from Breakpoints tab and start again.
Hey Aetf,
Any idea why that could be?
Aleix
PS: Aleksey, can you make sure this is reported in bugs.kde.org?
Hi Aetf,
Maybe you can give us some pointers in case someone else can/wants to fix it?

Aleix
Aetf
2017-09-04 21:55:20 UTC
Permalink
Hi,

I can see a few issues here.

1. BreakpointModel gets updated when user creating watch points directly
using command. The location reported by GDB includes the "-location " part,
but since we are quoting the entire string, GDB interprets the entire
string as an option, rather than only the "-location" part.
2. Even though we recognize the location and only quote remaining
expression, GDB/MI which is the protocol we use to communicate with GDB
actually doesn't support "-l/-location" option. see [1]
3. When starts new session, KDevelop tries to automatically reapply all
break/watch points saved in BreakpointModel. But the command fails due to
above reason. However there shouldn't be an endless loop. Once the command
fails, it should set the error message in the Breakpoint toolview and
continue. But maybe I'm just missing something.

The fix would be
1. In mibreakpointcontroller.cpp:358, detect and quote only the expression
part, this is easy.
2. Find a way to emulate the "-location" option. Possible solutions:
2.1 Take the address of the expression when watch point got set and
save that in BreakpointModel. But addresses are likely to change between
runs
2.2 Simply remove "-location" part and set it as a normal watch point.
But likely at the very begining of the program, the expression is out of
scope.
2.3 Skip it. IMHO even normal watchpoints should be skipped. As they
rely on expressions that are hardly valid at this time.
3. Desired behavior should be display the error in Breakpoint toolview,
rather than entering an endless loop. However I didn't find which part of
the code is causing the loop after a quick of the codebase. And the desired
behavior is already implemented. This will need more investigate.

[1]
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Breakpoint-Commands.html#GDB_002fMI-Breakpoint-Commands

Cheers,
Aetf
Post by Aleix Pol
Post by Aetf
Hi,
I'm afraid I don't have much time for this at the moment. Actually this
has
Post by Aetf
been on my todo list for a while... I'll take a look at it soon.
Cheers,
Aetf
Post by Aleix Pol
Post by Aleksey Midenkov
I've set watchpoint with command `watch -l` and it was saved in
KDevelop session. Now it doesn't start debug session because it ends
(gdb) 2106-break-watch "-location m_part_spec.start_part"
2106^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2107-break-watch "-location m_part_spec.start_part"
2107^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2108-break-watch "-location m_part_spec.start_part"
2108^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2109-break-watch "-location m_part_spec.start_part"
2109^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2110-break-watch "-location m_part_spec.start_part"
2110^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
...
Though I've managed to delete breakpoint from Breakpoints tab and
start
Post by Aetf
Post by Aleix Pol
Post by Aleksey Midenkov
again.
Hey Aetf,
Any idea why that could be?
Aleix
PS: Aleksey, can you make sure this is reported in bugs.kde.org?
Hi Aetf,
Maybe you can give us some pointers in case someone else can/wants to fix it?
Aleix
Aetf
2017-09-04 23:01:18 UTC
Permalink
PS: Reported on bug tracker: https://bugs.kde.org/show_bug.cgi?id=384368
Post by Aetf
Hi,
I can see a few issues here.
1. BreakpointModel gets updated when user creating watch points directly
using command. The location reported by GDB includes the "-location " part,
but since we are quoting the entire string, GDB interprets the entire
string as an option, rather than only the "-location" part.
2. Even though we recognize the location and only quote remaining
expression, GDB/MI which is the protocol we use to communicate with GDB
actually doesn't support "-l/-location" option. see [1]
3. When starts new session, KDevelop tries to automatically reapply all
break/watch points saved in BreakpointModel. But the command fails due to
above reason. However there shouldn't be an endless loop. Once the
command fails, it should set the error message in the Breakpoint toolview
and continue. But maybe I'm just missing something.
The fix would be
1. In mibreakpointcontroller.cpp:358, detect and quote only the expression
part, this is easy.
2.1 Take the address of the expression when watch point got set and
save that in BreakpointModel. But addresses are likely to change between
runs
2.2 Simply remove "-location" part and set it as a normal watch point.
But likely at the very begining of the program, the expression is out of
scope.
2.3 Skip it. IMHO even normal watchpoints should be skipped. As they
rely on expressions that are hardly valid at this time.
3. Desired behavior should be display the error in Breakpoint toolview,
rather than entering an endless loop. However I didn't find which part of
the code is causing the loop after a quick of the codebase. And the desired
behavior is already implemented. This will need more investigate.
[1]
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Breakpoint-Commands.html#GDB_002fMI-Breakpoint-Commands
Cheers,
Aetf
Post by Aleix Pol
Post by Aetf
Hi,
I'm afraid I don't have much time for this at the moment. Actually this
has
Post by Aetf
been on my todo list for a while... I'll take a look at it soon.
Cheers,
Aetf
Post by Aleix Pol
Post by Aleksey Midenkov
I've set watchpoint with command `watch -l` and it was saved in
KDevelop session. Now it doesn't start debug session because it ends
(gdb) 2106-break-watch "-location m_part_spec.start_part"
2106^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2107-break-watch "-location m_part_spec.start_part"
2107^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2108-break-watch "-location m_part_spec.start_part"
2108^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2109-break-watch "-location m_part_spec.start_part"
2109^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
(gdb) 2110-break-watch "-location m_part_spec.start_part"
2110^error,msg="-break-watch: Unknown option ``location
m_part_spec.start_part''"
...
Though I've managed to delete breakpoint from Breakpoints tab and
start
Post by Aetf
Post by Aleix Pol
Post by Aleksey Midenkov
again.
Hey Aetf,
Any idea why that could be?
Aleix
PS: Aleksey, can you make sure this is reported in bugs.kde.org?
Hi Aetf,
Maybe you can give us some pointers in case someone else can/wants to fix it?
Aleix
Loading...