public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 5/5] gdb/python: implement the print_insn extension language hook
Date: Fri, 22 Oct 2021 18:47:09 +0100	[thread overview]
Message-ID: <20211022174709.GI19507@embecosm.com> (raw)
In-Reply-To: <835yu0m64y.fsf@gnu.org>

Thanks for the feedback.  I have a couple of questions:

* Eli Zaretskii <eliz@gnu.org> [2021-10-14 10:12:45 +0300]:

> > From: Andrew Burgess <andrew.burgess@embecosm.com>
> > Date: Wed, 13 Oct 2021 22:59:10 +0100
> > 
> > diff --git a/gdb/NEWS b/gdb/NEWS
> > index d001a03145d..fd1952a2f59 100644
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -32,6 +32,12 @@ maint show internal-warning backtrace
> >    internal-error, or an internal-warning.  This is on by default for
> >    internal-error and off by default for internal-warning.
> >  
> > +set style disassembly on|off
> > +show style disassembly
> > +  If GDB is compiled with Python support, and the Python pygments
> > +  module is available, then, when this setting is on, disassembler
> > +  output will have styling applied.
> 
> If this requires Python with a module that is not available by
> default, I think a general style name like "disassembly" would be
> misleading.  I suggest "pygment-disassembly" instead.

I'm not sure I agree with this.  I don't see why we'd want to leak an
implementation detail (that we're using the pygment library) in a
setting name.

Surely, the setting should reflect what the effect is within GDB, and,
as far as possible, the implementation should be hidden from the
user. I'm hoping that some of the clarifications below might make this
more palatable...

> 
> > +@item set style disassembly @samp{on|off}
> > +Enable or disable disassembly styling.  This affects whether
> > +disassembly output, such as the output of the @code{disassemble}
> > +command, is styled.  The default is @samp{on}.  Note that disassembly
> > +styling only works if styling in general is enabled, and if a source
> > +highlighting library is available to @value{GDBN}.
> > +
> > +To highlight disassembly output @value{GDBN} must be compiled with
> > +Python support, and the Python Pygments package must be available,
> 
> So what does the default ON setting mean if pygments module is not
> available, or if GDB was not compiled with Python support?

You're correct, I've reworded this to reflect what actually happens.

First, as this is all implemented in Python, if GDB is compiled
without Python support then this setting (and the underlying feature)
is just not available.

If we do have Python, but not the Pygments library, then this feature
will be off by default, and an attempt to turn it on will give an
error that informs the user that the Python Pygments library is
missing.

Finally, if all the bits are in place, then this feature is on by
default.

> > +@node Disassembly In Python
> > +@cindex Python Instruction Disassembly
> 
> Index entries should begin with a lower-case letter, so that sorting
> of the entries in the produced manual would not depend on the locale.
> 
> > +@defivar DisassembleInfo can_emit_style_escapes
> > +This is @code{True} if the output stream that the disassembler is
> > +currently printing too can support escape sequences use for colors,
>                       ^^^
> Should be "to".
> 
> > +otherwise this attribute is @code{False}.
> 
> Not sure why you are talking about escape sequences: we support
> styling with colors also on terminals without escape sequences.  Does
> this mean this feature _must_ have actual escape sequence support?

I took the name from the internal GDB functions that do the same
check.  Can you point me at the terminal that does syntax highlighting
without using escape sequences, then I can see how this hooks back
into GDB.

Maybe I should rename this function 'supports_styling'? or something
similar?

Everything else I've fixed in my local tree.

Thanks,
Andrew


> 
> > +@defmethod DisassembleInfo memory_error (offset)
> > +This method marks the @code{DisassembleInfo} as having experienced a
> > +@code{gdb.MemoryError} when trying to access memory of @var{offset}
> > +bytes from @code{DisassembleInfo.address}.
> 
> Should this text have a cross-reference to where MemoryError is
> described?
> 
> > +The optional @var{architecture} is either a string, or the value
> > +@code{None}.  If it is a string, then it should be the name of an
> > +architecture known to @value{GDBN}, as returned either from
> > +@code{gdb.Architecture.name()}
> > +(@pxref{gdbpy_architecture_name,,gdb.Architecture.name}), or from
> > +@code{gdb.architecture_names()}
> > +(@pxref{gdb_architecture_names,,gdb.architecture_names}).
> 
> Please remove the parentheses from the references to these methods.
> 
> > +@defun format_address (architecture, address)
> > +Returns @var{address} formatted as a string, in a style suitable for
> > +including in the disassembly output of an instruction, for example a
> > +formatted address might look like:
> > +
> > +@smallexample
> > +0x00001042 <symbol+16>
> > +@end smallexample
> > +
> > +@var{architecture} is a @code{gdb.Architecture} (@pxref{Architectures
> > +In Python}), which is required to format the addresses correctly.
> > +This can be obtained from @code{DisassembleInfo.architecture}.
> 
> This last paragraph should have @noindent before it, since it's a
> continuation the description of format_address.
> 
> > +After calling this function the result in @var{info} @emph{might} have
> > +been updated to include syntax highlighting escape sequences.  If
> > +syntax highlighting is disabled in @value{GDBN}, or the output stream
> > +doesn't support syntax highlighting, then this function will leave
> > +@var{info} unchanged.
> 
> I suggest a cross-reference to commands that enable syntax
> highlighting where you mention it.
> 
> > +This function should return a Python object that supports the buffer
> > +protocol, i.e. a string, an array, or the object returned from
> 
> Please add @: after i.e., to prevent TeX from typesetting that as an
> end of a sentence.
> 
> Thanks.

  reply	other threads:[~2021-10-22 17:47 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 21:59 [PATCH 0/5] Add Python API for the disassembler Andrew Burgess
2021-10-13 21:59 ` [PATCH 1/5] gdb: make disassembler fprintf callback a static member function Andrew Burgess
2021-10-20 20:40   ` Tom Tromey
2021-10-22 12:51     ` Andrew Burgess
2021-10-13 21:59 ` [PATCH 2/5] gdb/python: new gdb.architecture_names function Andrew Burgess
2021-10-14  6:52   ` Eli Zaretskii
2021-10-22 12:51     ` Andrew Burgess
2021-10-20 20:40   ` Tom Tromey
2021-10-22 13:02   ` Simon Marchi
2021-10-22 17:34     ` Andrew Burgess
2021-10-22 18:42       ` Simon Marchi
2021-10-13 21:59 ` [PATCH 3/5] gdb/python: move gdb.Membuf support into a new file Andrew Burgess
2021-10-20 20:42   ` Tom Tromey
2021-10-22 12:52     ` Andrew Burgess
2021-10-13 21:59 ` [PATCH 4/5] gdb: add extension language print_insn hook Andrew Burgess
2021-10-20 21:06   ` Tom Tromey
2021-10-13 21:59 ` [PATCH 5/5] gdb/python: implement the print_insn extension language hook Andrew Burgess
2021-10-14  7:12   ` Eli Zaretskii
2021-10-22 17:47     ` Andrew Burgess [this message]
2021-10-22 18:33       ` Eli Zaretskii
2021-10-22 13:30   ` Simon Marchi
2022-03-23 22:41 ` [PATCHv2 0/3] Add Python API for the disassembler Andrew Burgess
2022-03-23 22:41   ` [PATCHv2 1/3] gdb: add new base class to gdb_disassembler Andrew Burgess
2022-03-23 22:41   ` [PATCHv2 2/3] gdb: add extension language print_insn hook Andrew Burgess
2022-03-23 22:41   ` [PATCHv2 3/3] gdb/python: implement the print_insn extension language hook Andrew Burgess
2022-03-24  7:10     ` Eli Zaretskii
2022-03-24 19:51       ` Andrew Burgess
2022-04-04 22:19   ` [PATCHv3 0/6] Add Python API for the disassembler Andrew Burgess
2022-04-04 22:19     ` [PATCHv3 1/6] gdb: move gdb_disassembly_flag into a new disasm-flags.h file Andrew Burgess
2022-04-05 14:32       ` Tom Tromey
2022-04-06 12:18         ` Andrew Burgess
2022-04-04 22:19     ` [PATCHv3 2/6] gdb: add new base class to gdb_disassembler Andrew Burgess
2022-04-04 22:19     ` [PATCHv3 3/6] gdb: add extension language print_insn hook Andrew Burgess
2022-04-04 22:19     ` [PATCHv3 4/6] gdb/python: implement the print_insn extension language hook Andrew Burgess
2022-04-05 12:04       ` Eli Zaretskii
2022-04-04 22:19     ` [PATCHv3 5/6] gdb: refactor the non-printing disassemblers Andrew Burgess
2022-04-04 22:19     ` [PATCHv3 6/6] gdb: unify two dis_asm_read_memory functions in disasm.c Andrew Burgess
2022-04-25  9:15     ` [PATCHv4 0/5] Add Python API for the disassembler Andrew Burgess
2022-04-25  9:15       ` [PATCHv4 1/5] gdb: add new base class to gdb_disassembler Andrew Burgess
2022-05-03 13:34         ` Simon Marchi
2022-05-03 16:13           ` Andrew Burgess
2022-05-05 17:39           ` Andrew Burgess
2022-04-25  9:15       ` [PATCHv4 2/5] gdb: add extension language print_insn hook Andrew Burgess
2022-05-03 13:42         ` Simon Marchi
2022-04-25  9:15       ` [PATCHv4 3/5] gdb/python: implement the print_insn extension language hook Andrew Burgess
2022-04-25 11:26         ` Eli Zaretskii
2022-05-03 14:55         ` Simon Marchi
2022-05-05 18:17           ` Andrew Burgess
2022-05-24  1:16             ` Simon Marchi
2022-05-24  8:30               ` Andrew Burgess
2022-05-25 10:37                 ` Andrew Burgess
2022-04-25  9:15       ` [PATCHv4 4/5] gdb: refactor the non-printing disassemblers Andrew Burgess
2022-04-25  9:15       ` [PATCHv4 5/5] gdb: unify two dis_asm_read_memory functions in disasm.c Andrew Burgess
2022-05-03 10:12       ` [PATCHv4 0/5] Add Python API for the disassembler Andrew Burgess
2022-05-06 17:17       ` [PATCHv5 " Andrew Burgess
2022-05-06 17:17         ` [PATCHv5 1/5] gdb: add new base class to gdb_disassembler Andrew Burgess
2022-05-06 17:17         ` [PATCHv5 2/5] gdb: add extension language print_insn hook Andrew Burgess
2022-05-06 17:17         ` [PATCHv5 3/5] gdb/python: implement the print_insn extension language hook Andrew Burgess
2022-05-06 18:11           ` Eli Zaretskii
2022-05-18 10:08             ` Andrew Burgess
2022-05-18 12:08               ` Eli Zaretskii
2022-05-23  8:59                 ` Andrew Burgess
2022-05-23 11:23                   ` Eli Zaretskii
2022-05-06 17:17         ` [PATCHv5 4/5] gdb: refactor the non-printing disassemblers Andrew Burgess
2022-05-06 17:17         ` [PATCHv5 5/5] gdb: unify two dis_asm_read_memory functions in disasm.c Andrew Burgess
2022-05-25 10:49         ` [PATCHv6 0/6] Add Python API for the disassembler Andrew Burgess
2022-05-25 10:49           ` [PATCHv6 1/6] gdb/python: convert gdbpy_err_fetch to use gdbpy_ref Andrew Burgess
2022-05-25 10:49           ` [PATCHv6 2/6] gdb: add new base class to gdb_disassembler Andrew Burgess
2022-05-25 10:49           ` [PATCHv6 3/6] gdb: add extension language print_insn hook Andrew Burgess
2022-05-25 10:49           ` [PATCHv6 4/6] gdb/python: implement the print_insn extension language hook Andrew Burgess
2022-05-25 13:32             ` Eli Zaretskii
2022-05-25 10:49           ` [PATCHv6 5/6] gdb: refactor the non-printing disassemblers Andrew Burgess
2022-05-25 10:49           ` [PATCHv6 6/6] gdb: unify two dis_asm_read_memory functions in disasm.c Andrew Burgess
2022-06-15  9:04           ` [PUSHED 0/6] Add Python API for the disassembler Andrew Burgess
2022-06-15  9:04             ` [PUSHED 1/6] gdb/python: convert gdbpy_err_fetch to use gdbpy_ref Andrew Burgess
2022-06-15  9:04             ` [PUSHED 2/6] gdb: add new base class to gdb_disassembler Andrew Burgess
2022-06-15  9:04             ` [PUSHED 3/6] gdb: add extension language print_insn hook Andrew Burgess
2022-06-15  9:04             ` [PUSHED 4/6] gdb/python: implement the print_insn extension language hook Andrew Burgess
2022-06-15  9:04             ` [PUSHED 5/6] gdb: refactor the non-printing disassemblers Andrew Burgess
2022-06-15  9:04             ` [PUSHED 6/6] gdb: unify two dis_asm_read_memory functions in disasm.c 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=20211022174709.GI19507@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=eliz@gnu.org \
    --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).