From: Yao Qi <qiyaoltc@gmail.com>
To: "Wiederhake\, Tim" <tim.wiederhake@intel.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
"Metzger\, Markus T" <markus.t.metzger@intel.com>,
"palves\@redhat.com" <palves@redhat.com>,
"xdje42\@gmail.com" <xdje42@gmail.com>
Subject: Re: [PATCH v6 9/9] Add documentation for new record Python bindings.
Date: Tue, 07 Mar 2017 11:53:00 -0000 [thread overview]
Message-ID: <86wpc1uwtz.fsf@gmail.com> (raw)
In-Reply-To: <9676A094AF46E14E8265E7A3F4CCE9AF942666@irsmsx105.ger.corp.intel.com> (Tim Wiederhake's message of "Mon, 6 Mar 2017 08:56:42 +0000")
"Wiederhake, Tim" <tim.wiederhake@intel.com> writes:
>> I read them again this morning, and have a design question in general, why
>> are they specific to btrace?
>> (...)
>> Can add a base class like RecordInstruction, which have some basic attributes
>> for all record methods, and BtraceInstruction extends it to add more btrace
>> specific attributes.
>
> Unfortunately, the interfaces to the "full" and "btrace" recording differ quite
> much. So even for "common" attributes, the code for the base class instruction
> and function segment objects would have to "if (method == ...)" through all
> recording methods, cluttering it, making it harder to maintain and
> potentially
Do you have a concrete example? If you have to "if (method == ...)" in
python code (outside of gdb), there is something wrong on design in
python code. I believe there are some design patterns for this kind of
issue "if (method == ...)".
> cause trouble if we introduce another recording format in the future when
> functions in the base class suddenly are not implemented for all methods
> anymore.
>
> My idea was to make use of Python's philosophy of duck-typing. Having specific
> (C wrapper) objects for each recording method solves the problem of how to
> obtain the requested data from the recording "back end". If we name respective
> functions and attributes the same in these classes, we "quack like a duck" and
> create the same common interface for the user from Python's perspective.
>
but you can't have a common interface because the python api is btrace
specific. Suppose we have gdb.FullInstruction for "full", what
attributes do we have? .number and .pc maybe? With the python api
design like this, how can I write a python code to trace data regardless
of which method is being used? Ideal design in my mind is like this (I
hope concrete example like this helps discussion)
class RecordInstruction(object)
# fields .pc and .number
class FullRecordInstruction(RecordInstruction)
class BtraceInstruction(RecordInstruction)
# field .error
Client python code can get a list of RecordInstruction to process,
without being aware which method is used.
Use gdb.find_pc_line (pc) to get gdb.Symtab_and_line, so we don't need
to have BtraceInstruction.sal.
BtraceInstruction .data, .decoded, .size, and .is_speculative, shouldn't
be in BtraceInstruction. They are about instruction. We need to put
them into a separate class, like gdb.Instruction, and add some function
to get gdb.Instruction from pc.
I'll give comments to BtraceFunctionCall later.
--
Yao (齐尧)
next prev parent reply other threads:[~2017-03-07 11:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 12:38 [PATCH v6 0/9] Python bindings for btrace recordings Tim Wiederhake
2017-02-13 12:38 ` [PATCH v6 5/9] Add method to query current recording method to target_ops Tim Wiederhake
2017-02-13 12:38 ` [PATCH v6 9/9] Add documentation for new record Python bindings Tim Wiederhake
2017-02-13 14:48 ` Eli Zaretskii
2017-03-03 11:10 ` Yao Qi
2017-03-06 8:56 ` Wiederhake, Tim
2017-03-07 11:53 ` Yao Qi [this message]
[not found] ` <9676A094AF46E14E8265E7A3F4CCE9AF942A2E@irsmsx105.ger.corp.intel.com>
2017-03-17 16:50 ` Yao Qi
2017-02-13 12:38 ` [PATCH v6 3/9] btrace: Use binary search to find instruction Tim Wiederhake
2017-02-13 12:38 ` [PATCH v6 6/9] python: Create Python bindings for record history Tim Wiederhake
2017-02-13 12:38 ` [PATCH v6 2/9] btrace: Export btrace_decode_error function Tim Wiederhake
2017-02-13 12:38 ` [PATCH v6 1/9] btrace: Count gaps as one instruction explicitly Tim Wiederhake
2017-02-13 12:38 ` [PATCH v6 4/9] Add record_start and record_stop functions Tim Wiederhake
[not found] ` <1486989450-11313-8-git-send-email-tim.wiederhake@intel.com>
2017-02-13 17:03 ` [PATCH v6 7/9] python: Implement btrace Python bindings for record history Doug Evans
2017-02-13 17:12 ` Doug Evans
[not found] ` <1486989450-11313-9-git-send-email-tim.wiederhake@intel.com>
2017-02-13 17:17 ` [PATCH v6 8/9] python: Add tests for record Python bindings Doug Evans
2017-02-13 17:18 ` [PATCH v6 0/9] Python bindings for btrace recordings Doug Evans
2017-02-14 10:20 ` Wiederhake, Tim
2017-02-14 16:22 ` Doug Evans
2017-02-15 7:35 ` Wiederhake, Tim
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=86wpc1uwtz.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=palves@redhat.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