public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How can I reload a pretty printer?
@ 2023-07-25 16:13 meator
  2023-07-25 16:32 ` Jan Vrany
  0 siblings, 1 reply; 3+ messages in thread
From: meator @ 2023-07-25 16:13 UTC (permalink / raw)
  To: gdb

Hi. When writing a pretty printer, I want to repeatedly test it. This is 
pretty complicated because GDB has no builtin mechanisms to do such 
thing (that I know of) and breakpoint() pretty much can not be used 
because GDB's Python doesn't have access to the capable pty so 
interactive use of PDB is impossible. Even the classic "printf style" 
debugging doesn't work because Python's print() doesn't work 
(gdb.write() has to be used instead).

I need to test the pretty printer often because the official Python 
interface documentation is quite lacking and the interface itself is 
imperfect^1. Accessing the docstrings of the Python interface is 
difficult because the gdb module nor other modules can be imported in 
standalone Python (I've tried to add it to $PYTHONPATH but with no 
success; How are you supposed to access the docstrings?).

Therefore my last solution is to load the pretty printer, try it in gdb, 
modify the pretty printer and repeat. But a pretty printer can be 
sourced only once because the second source call will fail due to the 
fact that the pretty printer is already registered. I have to restart 
GDB every time I modify the pretty printer which is extremely 
impractical. Is there a way to live reload the pretty printer?

1: There is no sane way to call member functions through gdb.Value which 
is kind of important in C++: https://stackoverflow.com/q/22774067/13840624

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: How can I reload a pretty printer?
@ 2023-07-25 16:37 meator
  0 siblings, 0 replies; 3+ messages in thread
From: meator @ 2023-07-25 16:37 UTC (permalink / raw)
  To: gdb

Of course right after I send the email, I find the solution. Passing 
replace=True to register_pretty_printer() solves my problem. I have 
asked the same question on the IRC and was bit impatient. They have 
solved my problems.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-25 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-25 16:13 How can I reload a pretty printer? meator
2023-07-25 16:32 ` Jan Vrany
2023-07-25 16:37 meator

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).