Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger: "data breakpoints": break when the command executed matches a certain regex #107

Open
singalen opened this issue May 9, 2020 · 5 comments

Comments

@singalen
Copy link

singalen commented May 9, 2020

I have a huge set of makefiles.
I need to find what creates a certain directory.
I would like to set a breakpoint that triggers:

  • when a command that matches .+mkdir.+problem_directory$ is executed.

The current breakpoints are useful when you know what file and line you want to stop at, but they cannot stop when a certain file is accessed.

@rocky
Copy link
Owner

rocky commented May 9, 2020

Ok. Sounds interesting. You are up for working on it yourself?

@singalen
Copy link
Author

singalen commented May 9, 2020

I made some initial research in the code. This should be doable, but no promises.
The condition should be checked somewhere around start_job_command(), and I need to call enter_debugger() - is this correct?

@rocky
Copy link
Owner

rocky commented May 9, 2020

I'd stay out of src which is mostly GNU Make and work as much as possible in libdebugger

To get started I might modify info targets so that instead of printing everything it filters according to some pattern. But no promises ;-)

@singalen
Copy link
Author

singalen commented May 9, 2020

Sorry, how would it help to create a data breakpoint?
To be clear, I don't want to filter existing breakpoints by condition. I want to have a pure-data breakpoint, that triggers whenever ANY command matches a given regex.

To do this, I need to:

  • create a new breakpoint data structure. Unlike breakpoint_node, it needs to be disconnected from a file location, but to have a command regex;
  • hook up to a code that executes every command in a target and probably in $(shell) too, after variable expansion (I wonder how this plays with .ONESHELL);
  • provide an API for libdebug to either list its regex breakpoints or to match the given command to regex breakpoints;
  • trigger a debugger.

Does this sound reasonable?

@rocky
Copy link
Owner

rocky commented May 9, 2020

Ok - I think I see now. So yes, I think new_job in jobs.c is where you want to change.

And what you write sounds reasonable.

Still though, you would do well to change job.c a little as possible. It's already complicated and ugly enough. If you can just put inside new_job a call to a new routine inside libdebugger to make the additional check and trigger when true.

singalen pushed a commit to singalen/remake that referenced this issue May 11, 2020
singalen pushed a commit to singalen/remake that referenced this issue May 11, 2020
singalen added a commit to singalen/remake that referenced this issue May 28, 2020
singalen added a commit to singalen/remake that referenced this issue Aug 10, 2020
singalen added a commit to singalen/remake that referenced this issue Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants