From: Yao Qi <qiyaoltc@gmail.com>
To: "Metzger\, Markus T" <markus.t.metzger@intel.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
"Wiederhake\, Tim" <tim.wiederhake@intel.com>,
"xdje42\@gmail.com" <xdje42@gmail.com>,
Joel Brobecker <brobecker@adacore.com>
Subject: Re: GDB 8.0 release/branching 2017-03-20 update
Date: Wed, 22 Mar 2017 17:09:00 -0000 [thread overview]
Message-ID: <86inn1utkp.fsf@gmail.com> (raw)
In-Reply-To: <A78C989F6D9628469189715575E55B2340056710@IRSMSX104.ger.corp.intel.com> (Markus T. Metzger's message of "Wed, 22 Mar 2017 13:58:13 +0000")
"Metzger, Markus T" <markus.t.metzger@intel.com> writes:
Hi, Markus,
Thanks for your input.
>> 1. BtraceInstruction.sal is not necessary. It can be got via
>> gdb.find_pc_line(BtraceInstruction.pc).
>
> I asked Tim to put this into the Instruction object in order to support
> future extensions.
>
> At the moment, we decode from live memory, and there, you're right
> that we can get the SAL from the PC. If we wanted to support exec()
> or dlclose() in the future, the trace would refer to instructions that are
> no longer available in memory and GDB would not know about them.
>
> Having users get the SAL from the Instruction object gives us more
> freedom to model this. We could, for example, decode from binary
> files and leave GDB to represent the current program state. Not sure
> whether this would suffice - probably not. But it sounded like a good
> idea to have users get such information via the Instruction object from
> the beginning. That's also why the Instruction object has a data function
> to get the raw bytes of an instruction rather than having users read
> it from memory.
>
>
>> 2. BtraceInstruction has some attributes (pc, data, decoded, and size,)
>> which are not btrace related.
>> They should be moved to a new class gdb.Instruction and BtraceInstruction
>> extends it.
>>
>> Instruction
>> {
>> pc, data, decode, size;
>> };
>
> That makes sense if we're considering a Python API for GDB's disassembler.
> I would extend it to include SAL for the above reasons so users don't need
> to know from where they got the Instruction object.
IMO, SAL only makes sense to RecordInstruction. I don't see why must put
SAL into Instruction.
>
> And we would extend it for record targets to add the speculative execution
> indication and a means for interleaving decode errors with decoded instructions.
>
Can we also extend Instruction for record target to add SAL there? Then
it becomes,
Instruction
{
pc, data, decode, size;
};
RecordInstruction : Instruction
{
sal;
is_speculative;
};
> I'm wondering how much of this discussion is really a question of sub-classing
> and how much of it is about documentation. Would I even be able to tell the
> difference in my python scripts that use the API?
All the user visible stuff should be covered in this discussion. We
need to mention that "gdb.RecordInstruction extends gdb.Instruction" in
the document, so that we don't have to document gdb.Instruction
attributes again in gdb.RecordInstruction.
>
> The duck typing argument makes sense to me and I'm not familiar enough
> with implementing Python to have an opinion on how this should be done.
> Do we have an expert on this in the GDB community?
>
The duck typing is about writing python code, but I raise my concerns in
this thread from the view of controlling the API *interface* for
different record methods by means of inheritance. With or without
inheritance, the python script still can do duck typing, no problem, but
we will end up having completely different ways of organizing these
interface. Suppose we have three record methods, "btrace", "full" and
"bar", in current approach, we need to document all the attributes for
these three methods, although some of them are in common. Why don't we
put these common attributes into a base class, and only document the
base class *once*?
Further, with such base class, we can guarantee that the client python
scripts only access base class attributes are right even with the new
record method may be added in the future. In current approach, we write
such python code "print(hex(i.pc), i.sal, i.decoded)" just because
BtraceInstruction and FullInstruction *happen* to have these
attributes. What if a new record method "bar" have instruction trace
which doesn't have attribute "decoded"?
>
>> 3. Why does Record have an attribute ptid?
>> Other record method may have process-wide record/trace. I'd like to put
>> common attributes in Record, and extend Record for each specific record
>> method.
>>
>> Record
>> {
>> method, format;
>> instruction_history;
>> };
>
> Agreed. The ptid seems to be an implementation detail. Tim, would you be
> OK to remove it?
>
> I would further put the function-call history into the Record base-class. It is
> merely another view that can be computed from the instruction-history.
> Record targets that don't support this view can return None.
I like this idea.
>
> Also the replay_position is common to all record targets that support reverse/
> replay. And record targets that don't will always remain at the end of the
> recorded trace. I don't see why a record target would not be able to provide
> it. Currently, all record targets support it.
>
> If you and Tim agree with this, we won't need a btrace sub-class, anymore and
> this should be a simple renaming.
Anything can make these APIs more general are great!
--
Yao (齐尧)
next prev parent reply other threads:[~2017-03-22 17:09 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 20:16 Joel Brobecker
2017-03-20 20:21 ` Keith Seitz
2017-03-20 22:39 ` Yao Qi
2017-03-20 22:47 ` Yao Qi
2017-03-20 22:52 ` Joel Brobecker
2017-03-20 23:03 ` Yao Qi
2017-03-21 13:28 ` Joel Brobecker
2017-03-21 7:35 ` Wiederhake, Tim
2017-03-21 13:28 ` Joel Brobecker
2017-03-21 13:07 ` Yao Qi
2017-03-21 13:31 ` Joel Brobecker
2017-03-22 13:58 ` Metzger, Markus T
2017-03-22 17:09 ` Yao Qi [this message]
2017-03-23 16:01 ` Metzger, Markus T
2017-03-23 17:25 ` Yao Qi
2017-03-23 18:17 ` Metzger, Markus T
2017-03-24 14:41 ` Yao Qi
2017-03-27 10:51 ` Metzger, Markus T
2017-03-27 11:19 ` Yao Qi
2017-03-27 12:46 ` Metzger, Markus T
2017-03-27 16:03 ` Yao Qi
2017-03-28 7:16 ` Metzger, Markus T
2017-03-28 13:25 ` Yao Qi
2017-03-28 15:08 ` Metzger, Markus T
2017-03-28 15:49 ` Yao Qi
2017-03-29 6:08 ` Metzger, Markus T
[not found] ` <861stgo072.fsf@gmail.com>
2017-03-29 14:38 ` Metzger, Markus T
2017-03-30 10:50 ` Yao Qi
2017-03-30 11:58 ` Metzger, Markus T
[not found] ` <86h92a4w86.fsf@gmail.com>
2017-03-30 15:55 ` Metzger, Markus T
2017-03-31 13:55 ` Yao Qi
2017-03-31 15:21 ` Metzger, Markus T
2017-03-31 16:02 ` Joel Brobecker
2017-04-06 14:40 ` Wiederhake, Tim
2017-04-07 8:10 ` Yao Qi
2017-04-07 11:53 ` Wiederhake, Tim
2017-04-07 15:19 ` Yao Qi
2017-03-21 14:00 ` Yao Qi
2017-03-21 14:03 ` Pedro Alves
2017-03-27 13:35 ` Antoine Tremblay
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=86inn1utkp.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=tim.wiederhake@intel.com \
--cc=xdje42@gmail.com \
/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