public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Tim Wiederhake <tim.wiederhake@intel.com>
Cc: gdb-patches@sourceware.org,  markus.t.metzger@intel.com,
	 palves@redhat.com,  xdje42@gmail.com
Subject: Re: [PATCH v6 9/9] Add documentation for new record Python bindings.
Date: Fri, 03 Mar 2017 11:10:00 -0000	[thread overview]
Message-ID: <86tw7apqf6.fsf@gmail.com> (raw)
In-Reply-To: <1486989450-11313-10-git-send-email-tim.wiederhake@intel.com>	(Tim Wiederhake's message of "Mon, 13 Feb 2017 13:37:30 +0100")

Tim Wiederhake <tim.wiederhake@intel.com> writes:

Hi Tim,
I read them again this morning, and have a design question in general,
why are they specific to btrace?

> +The attributes and methods of instruction objects depend on the current
> +recording method.  Currently, only btrace instructions are supported.
> +
> +A @code{gdb.BtraceInstruction} object has the following attributes:
> +
> +@defvar BtraceInstruction.number
> +An integer identifying this instruction.  @var{number} corresponds to
> +the numbers seen in @code{record instruction-history}
> +(@pxref{Process Record and Replay}).
> +@end defvar
> +

Why is it btrace specific?  Instructions in history of any record
methods can have a number or id, isn't?

> +@defvar BtraceInstruction.error
> +An integer identifying the error code for gaps in the history.
> +@code{None} for regular instructions.
> +@end defvar

> +
> +@defvar BtraceInstruction.sal
> +A @code{gdb.Symtab_and_line} object representing the associated symtab
> +and line of this instruction.  May be @code{None} if the instruction
> +is a gap.
> +@end defvar
> +
> +@defvar BtraceInstruction.pc
> +An integer representing this instruction's address.  May be @code{None}
> +if the instruction is a gap or the debug symbols could not be read.
> +@end defvar

Again, is it btrace specific?  Any instruction will have an address,
regardless of debug symbol.

Secondly, we have BtraceInstruction.pc, do we still need
BtraceInstruction.sal?  The sal can be got from other python api,
although these api may not exist.

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.

> +
> +@defvar BtraceInstruction.data
> +A buffer with the raw instruction data.  May be @code{None} if the
> +instruction is a gap.
> +@end defvar
> +
> +@defvar BtraceInstruction.decoded
> +A human readable string with the disassembled instruction.  Contains the
> +error message for gaps.
> +@end defvar
> +
> +@defvar BtraceInstruction.size
> +The size of the instruction in bytes.  Will be @code{None} if the
> +instruction is a gap.
> +@end defvar
> +
> +@defvar BtraceInstruction.is_speculative
> +A boolean indicating whether the instruction was executed
> +speculatively.  Will be @code{None} for gaps.
> +@end defvar

Why are these four attributes about Btrace or even record?  To me, they
are about instruction decode or disassembly.

> +
> +The attributes and methods of function call objects depend on the
> +current recording format.  Currently, only btrace function calls are
> +supported.
> +
> +A @code{gdb.BtraceFunctionCall} object has the following attributes:
> +
> +@defvar BtraceFunctionCall.number
> +An integer identifying this function call.  @var{number} corresponds to
> +the numbers seen in @code{record function-call-history}
> +(@pxref{Process Record and Replay}).
> +@end defvar
> +
> +@defvar BtraceFunctionCall.symbol
> +A @code{gdb.Symbol} object representing the associated symbol.  May be
> +@code{None} if the function call is a gap or the debug symbols could
> +not be read.
> +@end defvar
> +
> +@defvar BtraceFunctionCall.level
> +An integer representing the function call's stack level.  May be
> +@code{None} if the function call is a gap.
> +@end defvar
> +
> +@defvar BtraceFunctionCall.instructions
> +A list of @code{gdb.BtraceInstruction} objects associated with this function
> +call.
> +@end defvar
> +
> +@defvar BtraceFunctionCall.up
> +A @code{gdb.BtraceFunctionCall} object representing the caller's
> +function segment.  If the call has not been recorded, this will be the
> +function segment to which control returns.  If neither the call nor the
> +return have been recorded, this will be @code{None}.
> +@end defvar
> +
> +@defvar BtraceFunctionCall.prev_sibling
> +A @code{gdb.BtraceFunctionCall} object representing the previous
> +segment of this function call.  May be @code{None}.
> +@end defvar
> +
> +@defvar BtraceFunctionCall.next_sibling
> +A @code{gdb.BtraceFunctionCall} object representing the next segment of
> +this function call.  May be @code{None}.
> +@end defvar
> +

Sorry, I don't understand BtraceFunctionCall, can you give an example?
BtraceFunctionCall.symbol and .level indicates it represents a function
call rather than a function.  In the following example,

f2 () { f1 (); }
f3 () { f1 (); }

main () { f2 (); f3 (); }

Here are my understandings,

 - There are two BtraceFunctionCall objects bf1 and bf2 for f1, the first
   one, bf1, is about the call in f2 and the second one, bf2, is about the
   call in f3.
 - bf2.up is about the call in f2, and bf3.up is about the call in f3.
 - bf2.next_sibling == bf3 and bf3.prev_sibling == b2

Are they correct?

-- 
Yao (齐尧)

  parent reply	other threads:[~2017-03-03 11:10 UTC|newest]

Thread overview: 21+ 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 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 [this message]
2017-03-06  8:56     ` Wiederhake, Tim
2017-03-07 11:53       ` Yao Qi
2017-03-07 17:23         ` Wiederhake, Tim
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 1/9] btrace: Count gaps as one instruction explicitly 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 2/9] btrace: Export btrace_decode_error function Tim Wiederhake
2017-02-13 12:38 ` [PATCH v6 4/9] Add record_start and record_stop functions Tim Wiederhake
2017-02-13 12:38 ` [PATCH v6 6/9] python: Create Python bindings for record history 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 " 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=86tw7apqf6.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).