From: Simon Marchi <simon.marchi@polymtl.ca>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/5] gdb/python: new gdb.architecture_names function
Date: Fri, 22 Oct 2021 14:42:17 -0400 [thread overview]
Message-ID: <ccf02cbb-77c8-9d77-856a-f98cb22d6081@polymtl.ca> (raw)
In-Reply-To: <20211022173406.GH19507@embecosm.com>
On 2021-10-22 13:34, Andrew Burgess wrote:
> * Simon Marchi <simon.marchi@polymtl.ca> [2021-10-22 09:02:04 -0400]:
>
>> Hi Andrew,
>>
>> Sorry to reply only after you have merged this. I just have a question
>> about the API.
>
> Not a problem, better to get this sorted if something isn't right.
>
>>
>> On 2021-10-13 17:59, Andrew Burgess wrote:
>>> Add a new function to the Python API, gdb.architecture_names(). This
>>> function returns a list containing all of the supported architecture
>>> names within the current build of GDB.
>>>
>>> The values returned in this list are all of the possible values that
>>> can be returned from gdb.Architecture.name().
>>
>> Did you consider having a `gdb.architectures()` function, that returns a
>> list of gdb.Architecture objects? And then, if you want the names, you
>> use gdb.Architecture.name:
>>
>> for arch in gdb.architectures():
>> print(arch.name)
>
> Except I don't believe this would work. A gdb.Architecture goes 1:1
> with a gdbarch object, and we can have multiple gdbarch objects for
> the same underlying bfd architecture. For example, if two targets
> have the same bfd-architecture, but different target descriptions,
> you'll get different gdbarch objects, and different gdb.Architecture
> objects.
>
> So, in your above code you have to at least filter for duplicates.
>
> Then, as I understand it, gdbarch objects are only created "on
> demand", so in a multi-arch GDB, if I pass an x86 ELF, I don't
> believe a risc-v gdb.Architecture is ever created.
>
> So, in your above code, you'll only see the names of architectures
> that the user has exposed to GDB.
>
> That doesn't mean a gdb.architectures() method wouldn't be useful in
> some other situation, I just don't think it did what I wanted - tell
> me all the architectures this GDB knows about.
Ok, the above makes sense.
> Maybe what I should do is add an architecture_created event, then I
> could do:
>
> def do_something(arch):
> print(arch.name)
>
> for arch in gdb.architectures():
> do_something(arch)
>
> def handler(event):
> do_something(event.architecture)
>
> gdb.events.architecture_created.connect(handler)
I don't think that's necessary.
>> Being able to get the gdb.Architecture objects instead of just the name
>> sounds more flexible / future-proof to me.
>
> I don't think I'm worried that adding this API will be something we
> regret. gdb.Architecture already has a .name method, so being able to
> ask for the set of all possible names doesn't seem unreasonable. For
> that reason, I'd like to keep the existing method, even if you think
> that the above would be a better API...
I'm convinced that what you add is ok. The list of architecture names
isn't the list of all possible gdbarches (and therefore
gdb.Architecture), they are different things.
>> `gdb.breakpoints()`, not `gdb.breakpoint_nums()`. But there is perhaps
>> a technical reason why this doesn't work or isn't a good idea.
>
> The only different I see is that the names can exist before the
> corresponding architectures, and we can have multiple architectures
> per name, it would be like if gdb.breakpoint_nums() only returned the
> numbers 1 -> 10 because we could only have that many breakpoints, but,
> then we could actually have multiple breakpoints for each
> number...... OK, this analogy got weird...
>
> I've added the above additional APIs to my todo list, and I'll try to
> get them implemented.
I don't think it's necessary, I think what you have is ok.
Simon
next prev parent reply other threads:[~2021-10-22 18:42 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 [this message]
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
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=ccf02cbb-77c8-9d77-856a-f98cb22d6081@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=andrew.burgess@embecosm.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).