Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Markus Metzger <markus.t.metzger@intel.com>
Cc: gdb-patches@sourceware.org, markus.t.metzger@gmail.com
Subject: Re: [patch v9 19/23] record, btrace: add record-btrace target
Date: Tue, 05 Mar 2013 20:13:00 -0000	[thread overview]
Message-ID: <20130305201300.GS2386@host2.jankratochvil.net> (raw)
In-Reply-To: <1362416770-19750-20-git-send-email-markus.t.metzger@intel.com>

On Mon, 04 Mar 2013 18:06:06 +0100, Markus Metzger wrote:
> Add a target for branch trace recording.  This will replace the btrace
> commands added earlier in the patch series.
> 
> The target implements the new record sub-commands
> "record instruction-history" and
> "record function-call-history".
> 
> The target does not support reverse execution or navigation in the
> recorded execution log.
> 
> 2013-03-04  Markus Metzger  <markus.t.metzger@intel.com>
> 
> 	* Makefile.in (SFILES): Add record-btrace.c
> 	(COMMON_OBS): Add record-btrace.o
> 	* record-btrace.c: New.
> 	* objfiles.c: Include btrace.h.
> 	(free_objfile): call btrace_free_objfile.
[...]
> --- /dev/null
> +++ b/gdb/record-btrace.c
[...]
> +/* The to_open method of target record-btrace.  */
> +
> +static void
> +record_btrace_open (char *args, int from_tty)
> +{
> +  struct cleanup *disable_chain;
> +  struct thread_info *tp;
> +
> +  DEBUG ("open");
> +
> +  if (RECORD_IS_USED)
> +    error (_("The process is already being recorded."));
> +
> +  if (!target_has_execution)
> +    error (_("The program is not being run."));
> +
> +  if (!target_supports_btrace ())
> +    error (_("Target does not support branch tracing."));
> +
> +  gdb_assert (record_btrace_thread_observer == NULL);
> +
> +  disable_chain = make_cleanup (null_cleanup, NULL);
> +  ALL_THREADS (tp)
> +    if (args == NULL || *args == 0 || number_is_in_list (args, tp->num))
> +      {
> +	btrace_enable (tp);
> +
> +	(void) make_cleanup (record_btrace_disable_callback, tp);

Needless cast.  If it is required by your GCC warnings compatible with current
GDB codebase where it makes sense please propose them.


> +      }
> +
> +  record_btrace_auto_enable ();
> +
> +  push_target (&record_btrace_ops);
> +
> +  observer_notify_record_changed (current_inferior (),  1);
> +
> +  discard_cleanups (disable_chain);
> +}
[...]
> +/* Print the source line information for a function call history line.  */
> +
> +static void
> +btrace_func_history_src_line (struct ui_out *uiout, struct btrace_func *bfun)
> +{
> +  struct minimal_symbol *msym;
> +  struct symbol *sym;
> +  const char *filename;
> +
> +  msym = bfun->msym;
> +  sym = bfun->sym;
> +
> +  filename = NULL;
> +  if (sym != NULL)
> +    filename = symtab_to_filename_for_display (sym->symtab);


> +  else if (msym != NULL)
> +    filename = msym->filename;

No filename from minimal_symbol.

It prints for me bogus 'interp.c' there:

0	 genops.c:456-486	 __GI__IO_default_xsputn
1	 vfprintf.c:1635-1662	 _IO_vfprintf_internal
2	 interp.c	 strchrnul
3	 vfprintf.c:1662-1666	 _IO_vfprintf_internal

One can always find line number information two ways.

here you use the symbol's line.  But sometimes it is not available:
	(gdb) p strchrnul
	$3 = {<text variable, no debug info>} 0x7ffff6311480 <strchrnul>

On the other hand line number information (sal - source-and-line) may be
available even for such symbol:
	(gdb) info line strchrnul
	Line 26 of "/usr/src/debug/glibc-2.17-c758a686/sysdeps/x86_64/strchrnul.S" starts at address 0x7ffff6311480 <strchrnul> and ends at 0x7ffff6311484 <strchrnul+4>.

When you display ranges of lines I would find more natural to use the sal's
filename, it would also provide more rich info for the .S files.

It can be also filed as a PR so it does not block gdb-7.6; I wanted to get the
user interface final for the release.


> +
> +  if (filename == NULL || *filename == 0)
> +    return;
> +
> +  ui_out_field_string (uiout, "file", filename);
> +
> +  if (bfun->lend == 0)
> +    return;
> +
> +  ui_out_text (uiout, ":");
> +  ui_out_field_int (uiout, "min line", bfun->lbegin);
> +
> +  if (bfun->lend == bfun->lbegin)
> +    return;
> +
> +  ui_out_text (uiout, "-");
> +  ui_out_field_int (uiout, "max line", bfun->lend);
> +}
> +
> +/* Disassemble a section of the recorded function trace.  */
> +
> +static void
> +btrace_func_history (struct btrace_thread_info *btinfo, struct ui_out *uiout,
> +		     unsigned int begin, unsigned int end,
> +		     enum record_print_flag flags)
> +{
> +  struct btrace_func *bfun;
> +  unsigned int idx;
> +
> +  DEBUG ("ftrace (0x%x): [%u; %u[", flags, begin, end);
> +
> +  for (idx = begin; VEC_iterate (btrace_func_s, btinfo->ftrace, idx, bfun)
> +	 && idx < end; ++idx)
> +    {
> +      /* Print the function index.  */
> +      ui_out_field_uint (uiout, "index", idx);
> +      ui_out_text (uiout, "\t ");

Why here

> +
> +      if ((flags & record_print_insn_range) != 0)
> +	{
> +	  btrace_func_history_insn_range (uiout, bfun);
> +	  ui_out_text (uiout, "\t");
> +	}
> +
> +      if ((flags & record_print_src_line) != 0)
> +	{
> +	  btrace_func_history_src_line (uiout, bfun);
> +	  ui_out_text (uiout, "\t ");

and here is trailing space (' ')?

BTW maybe you could also align the columns by auto-sizing them, GDB does
auto-sizing (each place on its own, no utility for it) of various text tables
output.

0        ./common/common-utils.c:124     xstrprintf
1        ./cli/cli-decode.c:450-451      add_setshow_cmd_full
2        ./common/common-utils.c:116-121         xstrprintf
3        ./common/common-utils.c:128-130         xstrvprintf
4                vasprintf@plt
5        vasprintf.c:39-50       _IO_vasprintf
6                memmove@plt
7        malloc.c:2849-2875      __GI___libc_malloc
8        mcheck.c:206-223        mallochook
9                memmove@plt

This is just a future RFE.


> +	}
> +
> +      if (bfun->sym != NULL)
> +	ui_out_field_string (uiout, "function", SYMBOL_PRINT_NAME (bfun->sym));
> +      else if (bfun->msym != NULL)
> +	ui_out_field_string (uiout, "function", SYMBOL_PRINT_NAME (bfun->msym));
> +      ui_out_text (uiout, "\n");
> +    }
> +}
[...]


Thanks; those issues could be also left as future PRs/RFEs.


Thanks,
Jan


  reply	other threads:[~2013-03-05 20:13 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-04 17:07 [patch v9 00/23] branch tracing support for Atom Markus Metzger
2013-03-04 17:07 ` [patch v9 07/23] gdbserver, btrace: add generic btrace support Markus Metzger
2013-03-05 20:08   ` Jan Kratochvil
2013-03-06  9:15     ` Metzger, Markus T
2013-03-06 13:22   ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 10/23] remote, btrace: add branch tracing protocol to Qbtrace packet Markus Metzger
2013-03-05 20:09   ` Jan Kratochvil
2013-03-06  9:19     ` Metzger, Markus T
2013-03-04 17:07 ` [patch v9 02/23] linux, btrace: perf_event based branch tracing Markus Metzger
2013-03-05 20:06   ` Jan Kratochvil
2013-03-06 10:11   ` Mark Kettenis
2013-03-06 10:29     ` Metzger, Markus T
2013-03-04 17:07 ` [patch v9 04/23] xml, btrace: define btrace xml document style Markus Metzger
2013-03-05 20:07   ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 03/23] linux, i386, amd64: enable btrace for 32bit and 64bit linux native Markus Metzger
2013-03-05 20:06   ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 08/23] gdbserver, linux, btrace: add btrace support for linux-low Markus Metzger
2013-03-05 20:09   ` Jan Kratochvil
2013-03-06  9:17     ` Metzger, Markus T
2013-03-06 13:33   ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 01/23] thread, btrace: add generic branch trace support Markus Metzger
2013-03-05 20:06   ` Jan Kratochvil
2013-03-05 22:02     ` Tom Tromey
2013-03-06 21:11   ` Doug Evans
2013-03-07  7:50     ` Metzger, Markus T
2013-03-07 22:57       ` Doug Evans
2013-03-04 17:07 ` [patch v9 05/23] remote, btrace: add branch trace remote ops Markus Metzger
2013-03-05 20:07   ` Jan Kratochvil
2013-03-06  9:00     ` Metzger, Markus T
2013-03-04 17:07 ` [patch v9 16/23] record: default target methods Markus Metzger
2013-03-05 20:10   ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 22/23] testsuite, gdb.btrace: add btrace tests Markus Metzger
2013-03-04 19:47   ` Jan Kratochvil
2013-03-05  6:39     ` Metzger, Markus T
2013-03-05 20:14   ` Jan Kratochvil
2013-03-06 15:32     ` christian.himpel
2013-03-06 16:35       ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 06/23] btrace, doc: document remote serial protocol Markus Metzger
2013-03-04 18:08   ` Eli Zaretskii
2013-03-05 20:08   ` Jan Kratochvil
2013-03-06  9:06     ` Metzger, Markus T
2013-03-06  9:50       ` Jan Kratochvil
2013-03-06 10:01         ` Metzger, Markus T
2013-03-06 12:07           ` Jan Kratochvil
2013-03-06 12:13             ` Metzger, Markus T
2013-03-06 12:17               ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 11/23] target: add add_deprecated_target_alias Markus Metzger
2013-03-05 20:09   ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 20/23] record-btrace, disas: omit pc prefix Markus Metzger
2013-03-05 20:13   ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 19/23] record, btrace: add record-btrace target Markus Metzger
2013-03-05 20:13   ` Jan Kratochvil [this message]
2013-03-06  9:57     ` Metzger, Markus T
2013-03-06 13:35       ` Jan Kratochvil
2013-03-06 14:01         ` Metzger, Markus T
2013-03-06 16:28   ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 09/23] btrace, x86: disable on some processors Markus Metzger
2013-03-05 20:09   ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 17/23] record: add "record instruction-history" command Markus Metzger
2013-03-04 18:14   ` Eli Zaretskii
2013-03-05 20:11   ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 14/23] record-full.c: rename record_ in record_full_ Markus Metzger
2013-03-05 20:10   ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 15/23] record-full.h: rename record_ into record_full_ Markus Metzger
2013-03-05 20:10   ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 13/23] record: make it build again Markus Metzger
2013-03-05 20:10   ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 21/23] doc, record: document record changes Markus Metzger
2013-03-04 18:13   ` Eli Zaretskii
2013-03-05 20:13   ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 18/23] record: add "record function-call-history" command Markus Metzger
2013-03-04 18:07   ` Eli Zaretskii
2013-03-05 20:12   ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 23/23] btrace, remote: drop qbtrace packet Markus Metzger
2013-03-04 18:15   ` Eli Zaretskii
2013-03-05 20:15   ` Jan Kratochvil
2013-03-04 17:10 ` [patch v9 12/23] record: split record Markus Metzger
2013-03-05 20:09   ` Jan Kratochvil
2013-03-06 12:43 ` Crash of GDB with gdbserver btrace enabled [Re: [patch v9 00/23] branch tracing support for Atom] Jan Kratochvil
2013-03-06 14:40   ` Metzger, Markus T
2013-03-06 15:31     ` Metzger, Markus T
2013-03-06 17:06       ` Jan Kratochvil
2013-03-06 18:08         ` Metzger, Markus T
2013-03-07  9:06           ` Jan Kratochvil
2013-03-07  9:41             ` Metzger, Markus T
2013-03-07 10:00               ` Metzger, Markus T
2013-03-07 10:14                 ` Jan Kratochvil
2013-03-07 10:33                   ` Metzger, Markus T
2013-03-07 12:07                     ` Jan Kratochvil
2013-03-07 12:33                       ` Metzger, Markus T
2013-03-07 14:45                         ` Jan Kratochvil
2013-03-07 15:22                           ` Metzger, Markus T
2013-03-07 15:46                             ` Jan Kratochvil
2013-03-07 15:12                         ` Pedro Alves
2013-03-07 15:33                           ` Metzger, Markus T
2013-03-07 15:39                             ` Jan Kratochvil
2013-03-07 15:41                             ` Pedro Alves
     [not found]                           ` <20130318170643.GA15625@host2.jankratochvil.net>
     [not found]                             ` <514758DA.2060905@redhat.com>
2013-03-20 15:52                               ` [commit] [patch] Code cleanup: Remove parameter quitting [Re: Crash of GDB with gdbserver btrace enabled] Jan Kratochvil
     [not found]                               ` <20130318192604.GA2786@host2.jankratochvil.net>
     [not found]                                 ` <51477828.30000@redhat.com>
2013-03-26  0:15                                   ` Jan Kratochvil
2013-04-03 18:05                                     ` Pedro Alves
2013-03-07 10:08               ` Crash of GDB with gdbserver btrace enabled [Re: [patch v9 00/23] branch tracing support for Atom] Jan Kratochvil
2013-03-06 15:41   ` Jan Kratochvil

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=20130305201300.GS2386@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@gmail.com \
    --cc=markus.t.metzger@intel.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