" _mp_num and _mp_den fields if needed)"
)
elif type_specific_kind == "TYPE_SPECIFIC_INT":
- img = ("int_stuff = { bit_size = %d, bit_offset = %d }"
- % (type_specific["int_stuff"]["bit_size"],
- type_specific["int_stuff"]["bit_offset"]))
+ img = "int_stuff = { bit_size = %d, bit_offset = %d }" % (
+ type_specific["int_stuff"]["bit_size"],
+ type_specific["int_stuff"]["bit_offset"],
+ )
else:
img = (
"type_specific = ??? (unknown type_specific_kind: %s)"
def conn_num(c):
return c.num
+
# Takes a gdb.TargetConnection and return a string that is either the
# type, or the type and details (if the details are not None).
def make_target_connection_string(c):
else:
return "%s %s" % (c.type, c.details)
+
# A Python implementation of 'info connections'. Produce output that
# is identical to the output of 'info connections' so we can check
# that aspects of gdb.TargetConnection work correctly.
else:
prefix = " "
- print(fmt % (prefix, c.num, make_target_connection_string(c),
- c.description))
+ print(fmt % (prefix, c.num, make_target_connection_string(c), c.description))
+
def inf_num(i):
return i.num
+
# Print information about each inferior, and the connection it is
# using.
def info_inferiors():
all_inferiors = sorted(gdb.inferiors(), key=inf_num)
for i in gdb.inferiors():
- print("Inferior %d, Connection #%d: %s" %
- (i.num, i.connection_num,
- make_target_connection_string(i.connection)))
+ print(
+ "Inferior %d, Connection #%d: %s"
+ % (i.num, i.connection_num, make_target_connection_string(i.connection))
+ )
def exit_handler(event):
assert isinstance(event, gdb.ExitedEvent)
print("event type: exit")
- if hasattr(event, 'exit_code'):
+ if hasattr(event, "exit_code"):
print("exit code: %d" % (event.exit_code))
else:
print("exit code: not-present")
test_newobj_events()
+
def gdb_exiting_handler(event, throw_error):
assert isinstance(event, gdb.GdbExitingEvent)
if throw_error:
print("event type: gdb-exiting")
print("exit code: %d" % (event.exit_code))
+
class test_exiting_event(gdb.Command):
"""GDB Exiting event."""
def invoke(self, arg, from_tty):
if arg == "normal":
- gdb.events.gdb_exiting.connect(lambda e: gdb_exiting_handler(e,False))
+ gdb.events.gdb_exiting.connect(lambda e: gdb_exiting_handler(e, False))
elif arg == "error":
- gdb.events.gdb_exiting.connect(lambda e: gdb_exiting_handler(e,True))
+ gdb.events.gdb_exiting.connect(lambda e: gdb_exiting_handler(e, True))
else:
raise gdb.GdbError("invalid or missing argument")
print("GDB exiting event registered.")
+
test_exiting_event()