gdb/docs: add parentheses in Python examples using print
This makes the examples work both in Python 2 and 3. gdb/doc/ChangeLog: * python.texi: Add parentheses to print statements/functions. Change-Id: I8571f2ee005acd96c7bb43f9882d19b00b2aa3db
This commit is contained in:
parent
a625a8c9eb
commit
f3bdc2dbb9
2 changed files with 13 additions and 9 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2021-01-25 Marco Barisione <mbarisione@undo.io>
|
||||||
|
|
||||||
|
* python.texi: Add parentheses to print statements/functions.
|
||||||
|
|
||||||
2021-01-25 Andrew Burgess <andrew.burgess@embecosm.com>
|
2021-01-25 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* gdb.texinfo (Specify Location): Move menu to the end of the
|
* gdb.texinfo (Specify Location): Move menu to the end of the
|
||||||
|
|
|
@ -559,7 +559,7 @@ rather recognizes it when thrown from user Python code. Example:
|
||||||
> argv = gdb.string_to_argv (args)
|
> argv = gdb.string_to_argv (args)
|
||||||
> if len (argv) != 0:
|
> if len (argv) != 0:
|
||||||
> raise gdb.GdbError ("hello-world takes no arguments")
|
> raise gdb.GdbError ("hello-world takes no arguments")
|
||||||
> print "Hello, World!"
|
> print ("Hello, World!")
|
||||||
>HelloWorld ()
|
>HelloWorld ()
|
||||||
>end
|
>end
|
||||||
(gdb) hello-world 42
|
(gdb) hello-world 42
|
||||||
|
@ -3100,8 +3100,8 @@ Here is an example:
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
def exit_handler (event):
|
def exit_handler (event):
|
||||||
print "event type: exit"
|
print ("event type: exit")
|
||||||
print "exit code: %d" % (event.exit_code)
|
print ("exit code: %d" % (event.exit_code))
|
||||||
|
|
||||||
gdb.events.exited.connect (exit_handler)
|
gdb.events.exited.connect (exit_handler)
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
@ -3921,7 +3921,7 @@ class HelloWorld (gdb.Command):
|
||||||
super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_USER)
|
super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_USER)
|
||||||
|
|
||||||
def invoke (self, arg, from_tty):
|
def invoke (self, arg, from_tty):
|
||||||
print "Hello, World!"
|
print ("Hello, World!")
|
||||||
|
|
||||||
HelloWorld ()
|
HelloWorld ()
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
@ -4309,7 +4309,7 @@ def clear_objfiles_handler(event):
|
||||||
event.progspace.expensive_computation = None
|
event.progspace.expensive_computation = None
|
||||||
def expensive(symbol):
|
def expensive(symbol):
|
||||||
"""A mock routine to perform an "expensive" computation on 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
|
return 42
|
||||||
def new_objfile_handler(event):
|
def new_objfile_handler(event):
|
||||||
objfile = event.new_objfile
|
objfile = event.new_objfile
|
||||||
|
@ -4654,7 +4654,7 @@ versions. Using it, you could write:
|
||||||
reason = gdb.selected_frame().unwind_stop_reason ()
|
reason = gdb.selected_frame().unwind_stop_reason ()
|
||||||
reason_str = gdb.frame_stop_reason_string (reason)
|
reason_str = gdb.frame_stop_reason_string (reason)
|
||||||
if reason >= gdb.FRAME_UNWIND_FIRST_ERROR:
|
if reason >= gdb.FRAME_UNWIND_FIRST_ERROR:
|
||||||
print "An error occured: %s" % reason_str
|
print ("An error occured: %s" % reason_str)
|
||||||
@end smallexample
|
@end smallexample
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@ -5295,7 +5295,7 @@ example illustrating iterating over a line table.
|
||||||
symtab = gdb.selected_frame().find_sal().symtab
|
symtab = gdb.selected_frame().find_sal().symtab
|
||||||
linetable = symtab.linetable()
|
linetable = symtab.linetable()
|
||||||
for line in 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
|
@end smallexample
|
||||||
|
|
||||||
This will have the following output:
|
This will have the following output:
|
||||||
|
@ -5622,11 +5622,11 @@ method:
|
||||||
@smallexample
|
@smallexample
|
||||||
class MyFinishBreakpoint (gdb.FinishBreakpoint)
|
class MyFinishBreakpoint (gdb.FinishBreakpoint)
|
||||||
def stop (self):
|
def stop (self):
|
||||||
print "normal finish"
|
print ("normal finish")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def out_of_scope ():
|
def out_of_scope ():
|
||||||
print "abnormal finish"
|
print ("abnormal finish")
|
||||||
@end smallexample
|
@end smallexample
|
||||||
@end defun
|
@end defun
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue