> argv = gdb.string_to_argv (args)
> if len (argv) != 0:
> raise gdb.GdbError ("hello-world takes no arguments")
-> print "Hello, World!"
+> print ("Hello, World!")
>HelloWorld ()
>end
(gdb) hello-world 42
@smallexample
def exit_handler (event):
- print "event type: exit"
- print "exit code: %d" % (event.exit_code)
+ print ("event type: exit")
+ print ("exit code: %d" % (event.exit_code))
gdb.events.exited.connect (exit_handler)
@end smallexample
super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_USER)
def invoke (self, arg, from_tty):
- print "Hello, World!"
+ print ("Hello, World!")
HelloWorld ()
@end smallexample
event.progspace.expensive_computation = None
def expensive(symbol):
"""A mock routine to perform an "expensive" computation on symbol."""
- print "Computing the answer to the ultimate question ..."
+ print ("Computing the answer to the ultimate question ...")
return 42
def new_objfile_handler(event):
objfile = event.new_objfile
reason = gdb.selected_frame().unwind_stop_reason ()
reason_str = gdb.frame_stop_reason_string (reason)
if reason >= gdb.FRAME_UNWIND_FIRST_ERROR:
- print "An error occured: %s" % reason_str
+ print ("An error occured: %s" % reason_str)
@end smallexample
@end table
symtab = gdb.selected_frame().find_sal().symtab
linetable = symtab.linetable()
for line in linetable:
- print "Line: "+str(line.line)+" Address: "+hex(line.pc)
+ print ("Line: "+str(line.line)+" Address: "+hex(line.pc))
@end smallexample
This will have the following output:
@smallexample
class MyFinishBreakpoint (gdb.FinishBreakpoint)
def stop (self):
- print "normal finish"
+ print ("normal finish")
return True
def out_of_scope ():
- print "abnormal finish"
+ print ("abnormal finish")
@end smallexample
@end defun