Toolbox package¶
Catchpointing¶
-
toolbox.
catchable
= <mcgdb.toolbox.Catchable object>¶
Target subpackage¶
My gdb module¶
Module with usefil extensions to GDB's default Python functionalities.
-
class
mcgdb.toolbox.my_gdb.
AllInfBreakpoint
(spec, internal=True)[source]¶ Bases:
gdb.Breakpoint
Subclass of gdb.Breakpoint that spreads itself to all the existing and future inferiors.
Set them with command break_spread (communication.cli.my_gdb.cmd_AllInfBreakpoint).
-
breakpoints
= []¶
-
-
class
mcgdb.toolbox.my_gdb.
DefaultTaskManager
[source]¶ Bases:
object
Internal function. Default task manager implementation, simply relying on GDB's inferior+threads.
-
class
mcgdb.toolbox.my_gdb.
Prompt
(old_prompt)[source]¶ Bases:
object
Internal function. Extended prompt.
Variables: - hooks -- set of callable, triggered before returning the local prompt.
- prompts -- set of callable, applied recursively (next_prompt(previous)) to compte the prompt displayed by GDB.
Parameters: old_prompt -- the inner most prompt, (eg (gdb) or None)
-
class
mcgdb.toolbox.my_gdb.
SiblingBreakpoint
(referent)[source]¶ Bases:
gdb.Breakpoint
Copy of breakpoint referent in another program space. Registers itself in referent.siblings list.
Parameters: referent (AllInfBreakpoint) -- the original breakpoint. Variables: inf_id -- the inferior in which this breakpoint was set.
-
class
mcgdb.toolbox.my_gdb.
StrongNextBreakpoint
(spec, keyword=None)[source]¶ Bases:
gdb.Breakpoint
Internal function. Breakpoint extension used to implent strong_next command. :param keyword: optional description (mnemonic) of the strong_next startpoint. :type keyword: str
-
mcgdb.toolbox.my_gdb.
attach
(pid, name=None, comeback=False, silent=False)[source]¶ Tries to attach GDB to pid process.
Parameters: - comeback -- if true, switch back to the initial inferior. Otherwise, stay on the newly attached inferior.
- silent -- print information on screen or not. Default: False.
Returns: the newly attached inferior object, or None if it failed.
Return type: gdb.Inferior
-
mcgdb.toolbox.my_gdb.
attach_all
(pids)[source]¶ Tries to attach GDB to the processes described by [pids].
Parameters: pids (list) -- list of PIDs Returns: the newly attached inferior objects, or [] if all failed. Return type: list(gdb.Inferior)
-
mcgdb.toolbox.my_gdb.
current_infthr
()[source]¶ Returns GDB's currently selected inferior+thread.
List them with command info infthreads (communication.cli.my_gdb.cmd_info_infthread).
Returns: #1 GDB's selected inferior Returns: #2 GDB's selected thread
-
mcgdb.toolbox.my_gdb.
defaultPrompt
(old)[source]¶ Internal function. Returns GDB's default prompt: (gdb) :param old: unused
-
mcgdb.toolbox.my_gdb.
delete_bp
(num)[source]¶ Deprecated function. Wrapper around GDB's delete command. Use Breakpoint.delete instead.
-
mcgdb.toolbox.my_gdb.
get_current_executable
()[source]¶ Returns: the name of the current executable, if any. Return type: str
-
mcgdb.toolbox.my_gdb.
kill_current_inferior
(silent=True)[source]¶ Wrapper around GDB's kill command.
Parameters: silent -- print information on screen or not. Default: True Returns: the GDB's kill string if silent was True.
-
mcgdb.toolbox.my_gdb.
new_inferior
(silent=False)[source]¶ Wrapper around GDB's add-inferior command.
Parameters: silent -- print information on screen or not. Default: True Returns: the newly created inferior object, or None if it failed. Return type: gdb.Inferior
-
mcgdb.toolbox.my_gdb.
num_to_inf_obj
(num)[source]¶ Returns: the inferior whose identifier is num, None otherwise. Return type: gdb.Inferior
-
mcgdb.toolbox.my_gdb.
parse_newprocess
(where)[source]¶ Parses the PID of a new process in where.
Parameters: where -- GDB process creation string Raises: gdb.Error -- if the where doesn't contain the GDB's process creation pattern. Returns: the PID found Return type: int
-
mcgdb.toolbox.my_gdb.
pid_to_inf_obj
(pid)[source]¶ Returns: the inferior whose PID is pid, None otherwise. Return type: gdb.Inferior
-
mcgdb.toolbox.my_gdb.
print_and_execute
(command, to_string=False)[source]¶ Logs the command and pass it to GDB for execution. :param to_string: passed to gdb.execute. Default: False :returns: The execution string if to_string was True, None otherwise.
-
mcgdb.toolbox.my_gdb.
remove_inferior
(inf, silent=True)[source]¶ Wrapper around GDB's add-inferior command.
Parameters: silent -- print information on screen or not. Default: True Returns: the GDB's remove string if silent was True.
-
mcgdb.toolbox.my_gdb.
safe_finish
(to_string=True)[source]¶ Tries to stop the selected thread first of al, then execute GDB's finish command.
Returns: the output of the finish command.
-
mcgdb.toolbox.my_gdb.
signal_handler
(signal, frame)[source]¶ Handler for C^c process interuption. Pushes a stop request in mcGDB.
Connect it with signal.signal(signal.SIGINT, signal_handler).
Parameters: - signal -- not used
- frame -- not used
-
mcgdb.toolbox.my_gdb.
strong_next
(keyword=None)[source]¶ Internal function. Performes a "strong next" on the currently selected inferior: steps forward, and if we're one step deeper in the callstack, sets a StrongNextBreakpoint on the return point of the frame.
This function is usefull the next commands goes over a runtime function call that switches the current user-level thread. As GDB is not aware of that, it gets lost in its next and the execution never stops again.
Set it with command sn (communication.cli.my_gdb.cmd_sn).
Parameters: keyword -- A message to be displayed when the strop next finishes. Returns: True if a simple step was not enough to complete the next command.
-
mcgdb.toolbox.my_gdb.
switch_to_inferior
(inferior, silent=True)[source]¶ Switches to another inferior.
Parameters: - inferior -- the inferior to switch to.
- silent -- print information on screen or not. Default: True
Returns: True if we did the switch.
-
mcgdb.toolbox.my_gdb.
switch_to_infthr
(infthr, silent=True)[source]¶ Switches to another inferior+thread.
Parameters: - infthr -- the inferior+thread to switch to.
- silent -- print information on screen or not. Default: True
Returns: True if we did the switch.
Paje module¶
Module proving Paje trace generation capabilities.
-
class
mcgdb.toolbox.paje.
Event
(bp, params, do_finish=False, before=False)[source]¶ Bases:
object
Internal function.
-
mcgdb.toolbox.paje.
after
(bp, params)[source]¶ Creates finish function call event bp with parameters params.
Parameters: - bp -- Breakpoint that generated the event.
- params (dict) -- dictionnary of the parameters of the event.
-
mcgdb.toolbox.paje.
before
(bp, params, do_finish)[source]¶ Creates an function call event bp with parameters params.
Parameters: - bp -- Breakpoint that generated the event.
- params (dict) -- dictionnary of the parameters of the event.
- do_finish -- True we can expect an after event.
Python utils module¶
Module with Python utility functions.
-
mcgdb.toolbox.python_utils.
Dicted
(clazz)[source]¶ Adds dictionnary capabilities to the class. See
dicted_example
.
-
class
mcgdb.toolbox.python_utils.
Events
[source]¶ Bases:
object
Internal function.
-
bp_stop
= <mcgdb.toolbox.python_utils.Observer object>¶
-
cont
= <mcgdb.toolbox.python_utils.Observer object>¶
-
-
mcgdb.toolbox.python_utils.
Listed
(clazz)[source]¶ Adds a listing capability to the class. See
listed_example
.
-
mcgdb.toolbox.python_utils.
Numbered
(clazz)[source]¶ Gives a unique number identifier to class instances. See
numbered_example
.
-
class
mcgdb.toolbox.python_utils.
SimpleClass
(*args, **kws)[source]¶ Bases:
dict
Internal function. A simple class / advanced dictionnary class that provided its elements through named parameters.
-
last_number
= 0¶
-
-
mcgdb.toolbox.python_utils.
Switchable
(clazz)[source]¶ Adds generic switching capability to the class. See
switchable_example
.
-
mcgdb.toolbox.python_utils.
colored
(string, color)[source]¶ Internal function. Colorize a string.
Parameters: - string -- the text to colorize.
- color -- the color to apply to the text.
Returns: the colored string if we managed to, or the original string.
-
mcgdb.toolbox.python_utils.
deprecated
(decoratee)¶
-
class
mcgdb.toolbox.python_utils.
dicted_example
[source]¶ Bases:
object
-
dict_
= {}¶
-
classmethod
init_dict
(key, self)¶ Add the current object to its class dictionnary (in __init__).
Parameters: - key -- Unique id of this object instance.
- self -- Object instance put in the dict.
-
classmethod
key_to_value
(key)¶ Get object identified with key key.
Parameters: key -- key to lookup.
-
-
mcgdb.toolbox.python_utils.
error
(msg)[source]¶ Raise a GDB error.
Parameters: msg -- Reason of the error.
-
mcgdb.toolbox.python_utils.
fct_decorator
(decoratee)¶
-
mcgdb.toolbox.python_utils.
generator
(decoratee)¶
-
mcgdb.toolbox.python_utils.
hugly
(decoratee)¶
-
mcgdb.toolbox.python_utils.
internal
(decoratee)¶
-
class
mcgdb.toolbox.python_utils.
numbered_example
(*args, **kws)[source]¶ Bases:
object
-
last_number
= 0¶
-
-
mcgdb.toolbox.python_utils.
print_args
(function)[source]¶ Decorator. Prints all the arguments of the decorated function.
-
class
mcgdb.toolbox.python_utils.
switchable_example
[source]¶ Bases:
object
-
is_current
()¶ Virtual method. :returns: True if the entity is active in the context.
-
switch
(force=False)¶ Virtual method. Switch context to this entity.
-
-
mcgdb.toolbox.python_utils.
virtual
(decoratee)¶