Bug 18727

Summary: Add if to catch syscall to automate getting condition id
Product: gdb Reporter: Ciro Santilli <ciro.santilli>
Component: breakpointsAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: enhancement CC: tromey
Priority: P2    
Version: HEAD   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Ciro Santilli 2015-07-28 09:58:28 UTC
I want to set a condition on a `catch syscall`, e.g.: break whenever write is called with a given string to stdout http://stackoverflow.com/questions/8235436/how-can-i-monitor-whats-being-put-into-the-standard-out-buffer-and-break-when-a

    catch syscall write
    condition 2 $rdi == 1 && strcmp((char *)$rsi, "a\n") == 0

The problem is that I wasn't able to automate getting the breakpoint number, `2` in this example.

I currently need to manually read the number from stdout at creation time, or `info breakpoints`.

With break, I can just use `break WHERE if COND`, which does not depend on the explicit breakpoint number.

If it is not currently possible, would you consider a patch that adds `if` to `catch syscall`?

Other possibilities include:

- make condition target the last `catch` by default, much like commands
- store the ID of the last set catchpoint in a magic convenience var
Comment 1 Tom Tromey 2018-04-01 17:59:38 UTC
Could you try the "$bpnum" convenience variable?
Comment 2 Ciro Santilli 2018-04-01 20:09:58 UTC
:-)