public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Doug Evans <dje@google.com>
Cc: yao@codesourcery.com, gdb-patches@sourceware.org
Subject: Re: [PATCH 4/6] gdbserver: Delimit debugging output for readability
Date: Thu, 16 Jan 2014 17:22:00 -0000	[thread overview]
Message-ID: <52D81569.3080006@redhat.com> (raw)
In-Reply-To: <21205.55987.69477.892571@ruffy.mtv.corp.google.com>

On 01/15/2014 12:47 AM, Doug Evans wrote:

> Hi.
> While going through the reviews, I found myself wanting something more,
> namely timestamps (like "set debug timestamp on" in gdb).
> 
> This patch adds a check for gettimeofday and doesn't fall back to using one
> in libiberty or gnulib, leaving that for another day.
> 
> It also adds macro FUNCTION_NAME, based on the implementation in gdb_assert.h.
> A subsequent patch will use this when replacing abbreviations with
> function names.
> 
> Unlike gdb, I didn't add an option to enable timestamps, you get them
> automagically with --debug.  I can do that if people want.

I'd like that.  I've had to diff logs (side by side in e.g., kdiff3)
more than once in the past to track tricky stuff, and timestamps
unfortunately make that impossible.

> I had a version of this patch that used indentation to represent
> the heirarchy of debug_level_{enter,exit}.  I left the basic support
> in thinking it might be useful.  I can either remove it or add the indentation,
> but I found myself not really wanting the indentation.

I don't have a strong opinion, as I didn't make use of this
yet, but I think I wouldn't want indentation.  (E.g., maybe printing
a level counter instead of indentation could be better.).

> diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
> index 13b3ff6..3706577 100644
> --- a/gdb/gdbserver/tracepoint.c
> +++ b/gdb/gdbserver/tracepoint.c
> @@ -61,6 +61,8 @@
>  
>  */
>  
> +#ifdef IN_PROCESS_AGENT
> +
>  static void trace_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
>  
>  static void
> @@ -81,6 +83,19 @@ trace_vdebug (const char *fmt, ...)
>        trace_vdebug ((fmt), ##args);		\
>    } while (0)
>  
> +#else
> +
> +#define trace_debug_1(level, fmt, args...)	\
> +  do {						\
> +    if (level <= debug_threads)			\
> +      {						\
> +	debug_printf ((fmt), ##args);		\
> +	debug_printf ("\n");			\
> +      }						\
> +  } while (0)
> +

Please write this in a way that preserves printing PROG
in gdbserver.  When debugging gdbserver and the IPA both
tracing at the same time (fast tracepoints and regular
tracepoints), it's confusing not to have there explicitly
who printed what, because both programs print the
same messages.

> +#endif
> +
>  #define trace_debug(FMT, args...)		\
>    trace_debug_1 (1, FMT, ##args)
>  
> @@ -338,7 +353,7 @@ tracepoint_look_up_symbols (void)
>        if (look_up_one_symbol (symbol_list[i].name, addrp, 1) == 0)
>  	{
>  	  if (debug_threads)
> -	    fprintf (stderr, "symbol `%s' not found\n", symbol_list[i].name);
> +	    debug_printf ("symbol `%s' not found\n", symbol_list[i].name);
>  	  return;
>  	}
>      }
> diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c
> index eff4499..1ce5512 100644
> --- a/gdb/gdbserver/utils.c
> +++ b/gdb/gdbserver/utils.c

Could this new debug support code be put in a new file
instead?  E.g., gdbserver/debug.c ?

Otherwise this all looks good to me.

>  /* Temporary storage using circular buffer.  */
>  #define NUMCELLS 10
>  #define CELLSIZE 50
> diff --git a/gdb/gdbserver/utils.h b/gdb/gdbserver/utils.h
> index 6d3df71..6c781c0 100644
> --- a/gdb/gdbserver/utils.h
> +++ b/gdb/gdbserver/utils.h
> @@ -19,10 +19,44 @@
>  #ifndef UTILS_H
>  #define UTILS_H
>  
> +/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
> +   which contains the name of the function currently being defined.
> +   This is broken in G++ before version 2.6.
> +   C9x has a similar variable called __func__, but prefer the GCC one since
> +   it demangles C++ function names.  */
> +#if (GCC_VERSION >= 2004)
> +#define FUNCTION_NAME __PRETTY_FUNCTION__
> +#else
> +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
> +#define FUNCTION_NAME __func__
> +#endif
> +#endif

It'd be nice if this and gdb_assert.h's version of the same were
shared.  That is, e.g., put this in common/common-utils.h instead,
and make gdb_assert.h define ASSERT_FUNCTION as FUNCTION_NAME
(or eliminate ASSERT_FUNCTION entirely).  Are you planning on
doing it?

-- 
Pedro Alves

  reply	other threads:[~2014-01-16 17:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-17 21:47 Doug Evans
2013-12-18 11:17 ` Pedro Alves
2014-01-15  0:47   ` Doug Evans
2014-01-16 17:22     ` Pedro Alves [this message]
2014-01-16 18:43       ` Doug Evans
2014-01-16 18:54         ` Pedro Alves
2014-01-16 23:28           ` [PATCH 0/3] Add debug_printf and timestamps to gdbserver Doug Evans
2014-01-16 23:31             ` [PATCH 1/3] gdbserver debug_printf+timestamps: FUNCTION_NAME Doug Evans
2014-01-17 12:46               ` Pedro Alves
2014-01-16 23:33             ` [PATCH 2/3] gdbserver debug_printf+timestamps: delim_string_to_char_ptr_vec_append Doug Evans
2014-01-16 23:37             ` [PATCH 3/3, doc RFA] gdbserver debug_printf+timestamps: main patch Doug Evans
2014-01-17  2:58               ` Doug Evans
2014-01-17  7:04               ` Eli Zaretskii
2014-01-17 12:46               ` Pedro Alves
2014-01-17 22:45                 ` Doug Evans
2014-01-18  8:25                   ` Eli Zaretskii
2014-01-20 16:14                   ` Pedro Alves
2014-01-22 23:06                     ` Doug Evans
2014-01-16 18:39     ` [PATCH 4/6] gdbserver: Delimit debugging output for readability Yao Qi
2014-01-16 19:01       ` Doug Evans
2014-01-17  2:32         ` Joel Brobecker
2014-01-17  2:40         ` Joel Brobecker
2014-01-17 12:46         ` Pedro Alves
2014-01-17 12:59         ` Yao Qi
2014-01-20  5:42         ` Tom Tromey
2014-01-20 19:51           ` Doug Evans

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=52D81569.3080006@redhat.com \
    --to=palves@redhat.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@codesourcery.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).