Debugging facility for an individual process.
More...
#include <process_debugger.hpp>
Debugging facility for an individual process.
This class ties the debugger to a specific debuggee process. The process_debugger responds to all debug events that pertain to its debuggee. Clients may receive (and deal with) these events using the add_event_listener() method with a custom base_debug_event_listener.
- Author
- Matt Bisson
- Date
- 5 August, 2014
- Since
- ProcLib 2.0
- Version
- ProcLib 2.0
- Todo:
- This doesn't do much right now. Maybe it should automatically add the (currently) pstack::pstack_event_handler and provide access to process_info, etc?
Create an instance of the debugger with a given process ID.
- Parameters
-
[in] | pid | The numerical ID of a process that is currently active to attach to the debugger. |
- Exceptions
-
proclib::process_debugger::~process_debugger |
( |
| ) |
|
Detach the debugger from the process.
Based on prior calls to set_kill_process_on_exit(), this method may allow the debugged process to continue normal execution, or it may terminate the process.
- Note
- If the debugger could not detach from the process that was previously attached, this method will log the error.
- Postcondition
- All registered listeners will be released, possibly causing deletion.
- Todo:
- Replace this when we have a logging facility.
Add a listener for debugger events sent to this process.
This method inserts a listener for debugger events that are relevent for the process managed by this process_debugger instance. The event handlers are not guaranteed to be fired in any order. Event handlers must not throw exceptions.
Handlers must neither add nor remove listener while handling an event. Doing so results in undefined behavior.
- Parameters
-
[in] | l | The custom listener to register. |
- Returns
- A "token" that uniquely identifies the listener that was successfully added. If the listener was not added, this method returns process_debugger::invalid_event_listener_id.
- Precondition
- An event is not currently being processed.
-
l
has not already been registered with this process_debugger.
- Postcondition
l
will begin receiving debugger events pertaining to this process.
- Todo:
- Deal with double-adds of the same listener
- Todo:
- Need a way to generate an ID
Access the main event handler for this process.
This is mostly useful for the proclib::debug_engine to pass process-specific events to this class (for distribution to listeners registered via add_event_listener()).
- Returns
- A reference to the process's events. It is valid until this instance is destroyed.
Get the ID of the process being debugged here.
- Returns
- The numerical process ID (PID).
Remove an already registered event listener.
This method removes a listener that was previously registered with add_event_listener() by its ID. If the ID was not found, this method does nothing.
- Parameters
-
- Returns
true
if the listener was found and removed; false
if not.
- Precondition
- An event is not currently being processed.
-
A listener with an ID of
id
has already been registered with this process_debugger.
- Postcondition
- The listener with an ID of
id
will no longer receive debugger events pertaining to this process.
- Todo:
- This is not implemented!
void proclib::process_debugger::set_kill_process_on_exit |
( |
bool |
kill_on_exit | ) |
|
Determine the fate of a process after the debugger detaches.
When the debugger detaches from a process or teminates, the process being debugged may either continue normal execution or terminate. The default action is to terminate the debuggee. Typical debugger behavior is to terminate a process that was created by the debugger, and allow a process to which the debugger attached to continue normal execution.
- Parameters
-
[in] | kill_on_exit | If true , the debugger should terminate the debuggee when detaching. Otherwise, the debuggee will continue normal execution. |
- Attention
- This is a global flag for all debuggers. If not called, processes will be set to be killed on exit. This is a member function because you must have connected to at least one debugger before even calling it.
The documentation for this class was generated from the following files: