Bug 18727 - Add if to catch syscall to automate getting condition id
Summary: Add if to catch syscall to automate getting condition id
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: HEAD
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-28 09:58 UTC by Ciro Santilli
Modified: 2018-04-01 20:09 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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
:-)