From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCHv2 8/8] gdb/doc: update examples in gdb.Progspace and gdb.Objfile docs
Date: Wed, 10 Jan 2024 15:54:45 +0000 [thread overview]
Message-ID: <e6c4ffdacff6b09efac4a6a643627bee5948e3c8.1704901918.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1704901918.git.aburgess@redhat.com>
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.
---
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 40803274a27..0b240c76dce 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -5416,13 +5416,16 @@
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
@@ -5437,15 +5440,18 @@
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
@@ -5576,17 +5582,21 @@
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:
--
2.25.4
next prev parent reply other threads:[~2024-01-10 15:55 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 11:48 [PATCH 0/6] Python __repr__() methods and new __dict__ attributes Andrew Burgess
2024-01-05 11:48 ` [PATCH 1/6] gdb/python: hoist common invalid object repr code into py-utils.c Andrew Burgess
2024-01-09 19:19 ` Tom Tromey
2024-01-05 11:48 ` [PATCH 2/6] gdb/python: add gdb.InferiorThread.__repr__() method Andrew Burgess
2024-01-05 11:48 ` [PATCH 3/6] gdb/python: add gdb.Frame.__repr__() method Andrew Burgess
2024-01-05 11:48 ` [PATCH 4/6] gdb/python: remove users ability to create gdb.Progspace objects Andrew Burgess
2024-01-05 13:27 ` Eli Zaretskii
2024-01-05 11:48 ` [PATCH 5/6] gdb/python: Add gdb.Inferior.__dict__ attribute Andrew Burgess
2024-01-05 13:33 ` Eli Zaretskii
2024-01-09 20:05 ` Tom Tromey
2024-01-05 11:48 ` [PATCH 6/6] gdb/python: Add gdb.InferiorThread.__dict__ attribute Andrew Burgess
2024-01-05 13:31 ` Eli Zaretskii
2024-01-09 20:11 ` Tom Tromey
2024-01-10 10:38 ` Andrew Burgess
2024-01-10 15:54 ` [PATCHv2 0/8] Python __repr__() methods and new __dict__ attributes Andrew Burgess
2024-01-09 17:32 ` [PATCH] gdb/python: New InferiorThread.ptid_string attribute Andrew Burgess
2024-01-09 18:50 ` Eli Zaretskii
2024-01-09 19:10 ` Tom Tromey
2024-01-12 9:39 ` [PUSHED] " Andrew Burgess
2024-01-10 15:54 ` [PATCH] " Andrew Burgess
2024-01-10 15:54 ` [PATCHv2 1/8] gdb/python: hoist common invalid object repr code into py-utils.c Andrew Burgess
2024-01-10 15:54 ` [PATCHv2 2/8] gdb/python: add gdb.InferiorThread.__repr__() method Andrew Burgess
2024-01-10 15:54 ` [PATCHv2 3/8] gdb/python: add gdb.Frame.__repr__() method Andrew Burgess
2024-01-10 15:54 ` [PATCHv2 4/8] gdb/python: remove users ability to create gdb.Progspace objects Andrew Burgess
2024-01-10 15:54 ` [PATCHv2 5/8] gdb/python: Add gdb.Inferior.__dict__ attribute Andrew Burgess
2024-01-10 15:54 ` [PATCHv2 6/8] gdb/python: Add gdb.InferiorThread.__dict__ attribute Andrew Burgess
2024-01-10 15:54 ` [PATCHv2 7/8] gdb/doc: add some notes on selecting suitable attribute names Andrew Burgess
2024-01-10 16:35 ` Eli Zaretskii
2024-01-11 10:48 ` Andrew Burgess
2024-01-11 10:56 ` Eli Zaretskii
2024-01-10 15:54 ` Andrew Burgess [this message]
2024-01-10 16:36 ` [PATCHv2 8/8] gdb/doc: update examples in gdb.Progspace and gdb.Objfile docs Eli Zaretskii
2024-01-10 18:08 ` [PATCHv2 0/8] Python __repr__() methods and new __dict__ attributes Tom Tromey
2024-01-12 13:44 ` Andrew Burgess
2024-01-12 14:57 ` Tom de Vries
2024-01-12 16:20 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e6c4ffdacff6b09efac4a6a643627bee5948e3c8.1704901918.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).