public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/doc: update examples in gdb.Progspace and gdb.Objfile docs
@ 2024-01-12 13:44 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2024-01-12 13:44 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7ccdf9c0fb4b57739bf3028d5d4b40bf63fd9c65

commit 7ccdf9c0fb4b57739bf3028d5d4b40bf63fd9c65
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Wed Jan 10 15:43:06 2024 +0000

    gdb/doc: update examples in gdb.Progspace and gdb.Objfile docs
    
    This commit updates the Python example code in the gdb.Progspace and
    gdb.Objfile sections of the docs.  Changes made:
    
      1. Use @value{GDBP} for the GDB prompt rather than
      hard-coding (gdB),
    
      2. Use @group...@end group to split the example code into
      unbreakable chunks, and
    
      3. Add parenthesis to the Python print() calls in the examples.  In
      Python 2 it was OK to drop the parenthesis, but now GDB is Python 3
      only, example code should include the parenthesis.
    
    Approved-By: Eli Zaretskii <eliz@gnu.org>
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/doc/python.texi | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index ed85989e5a5..97fcc460ea0 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -5423,13 +5423,16 @@ with the program space because we can't predict when the desired objfile
 will be loaded.
 
 @smallexample
-(gdb) python
+(@value{GDBP}) python
+@group
 def clear_objfiles_handler(event):
     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 ...")
     return 42
+@end group
+@group
 def new_objfile_handler(event):
     objfile = event.new_objfile
     progspace = objfile.progspace
@@ -5444,15 +5447,18 @@ def new_objfile_handler(event):
 gdb.events.clear_objfiles.connect(clear_objfiles_handler)
 gdb.events.new_objfile.connect(new_objfile_handler)
 end
-(gdb) file /tmp/hello
+@end group
+@group
+(@value{GDBP}) file /tmp/hello
 Reading symbols from /tmp/hello...
 Computing the answer to the ultimate question ...
-(gdb) python print gdb.current_progspace().expensive_computation
+(@value{GDBP}) python print(gdb.current_progspace().expensive_computation)
 42
-(gdb) run
+(@value{GDBP}) run
 Starting program: /tmp/hello
 Hello.
 [Inferior 1 (process 4242) exited normally]
+@end group
 @end smallexample
 
 @node Objfiles In Python
@@ -5583,17 +5589,21 @@ In this contrived example we record the time when @value{GDBN}
 loaded the objfile.
 
 @smallexample
-(gdb) python
+@group
+(@value{GDBP}) python
 import datetime
 def new_objfile_handler(event):
     # Set the time_loaded attribute of the new objfile.
     event.new_objfile.time_loaded = datetime.datetime.today()
 gdb.events.new_objfile.connect(new_objfile_handler)
 end
-(gdb) file ./hello
+@end group
+@group
+(@value{GDBP}) file ./hello
 Reading symbols from ./hello...
-(gdb) python print gdb.objfiles()[0].time_loaded
+(@value{GDBP}) python print(gdb.objfiles()[0].time_loaded)
 2014-10-09 11:41:36.770345
+@end group
 @end smallexample
 
 A @code{gdb.Objfile} object has the following methods:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-12 13:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12 13:44 [binutils-gdb] gdb/doc: update examples in gdb.Progspace and gdb.Objfile docs Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).