Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: "Pierre Muller" <muller@ics.u-strasbg.fr>
Subject: Re: [RFA] win32-nat.c: Add dll names if debugevents is on
Date: Sat, 14 Jun 2008 00:16:00 -0000	[thread overview]
Message-ID: <200806132354.59705.pedro@codesourcery.com> (raw)
In-Reply-To: <000001c8cda0$ec693b40$c53bb1c0$@u-strasbg.fr>

A Friday 13 June 2008 23:00:40, Pierre Muller wrote:
> Thanks for the comments

> >While you're at it, would it be useful to also include the dll
> >load base in the output?
>
>   It’s a good idea, that I implemented easily, see below.
> I choose to use the solib struct to be closer to 'info dll' output.
> The only caveat is that it doesn't match the values given by 'info dll'
> later
> because of the 0x1000 offset added to the start of each Dll,
> should I add  this 0x1000?

I've no strong opinion, handle_unload_dll already erros without ...

>   It seems like so_original_name is never empty,
> because if the dll name is not found, the dll is not recorded at all.
>   And I finally realized that my code was wrong because
> so_original_name and so_name are char array, not pointers...
> I nevertheless check both so_name and so_original_name
> in that order, without knowing if one can be set and
> not the other...

See win32_make_so.  so_name is always built from so_original_name.

>
> Here is an updated patch:
>

This patch surely doesn't work.

> @@ -771,6 +774,18 @@ handle_unload_dll (void *dummy)
>         so->next = sodel->next;
>         if (!so->next)
>           solib_end = so;
> +       if (sodel->so_name != "\0")
> +         {
> +           DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n",
> +                          (char *) &(sodel->so_name)));
> +         }
> +       else if (sodel->so_original_name != "\0")
> +         {
> +           DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n",
> +                          (char *) &(sodel->so_original_name)));
> +         }
> +       else
> +         DEBUG_EVENTS (("gdb: Unloading <unknown name> dll.\n"));

<side note>

  Beware that DEBUG_EVENTS is not safe to reguarding dangling else's...

  #define DEBUG_EVENTS(x)	if (debug_events)	printf_unfiltered x

  That should be fixed to something like:

  #define DEBUG_EVENTS(x) \
   do { if (debug_events) printf_unfiltered x ; } while (0)

  Or better, to output to fprintf_unfiltered (gdb_stdlog, ...

  Otherwise, extra braces are indeed required.

</side note>

> +       if (sodel->so_name != "\0")

Anyway, these comparision aren't doing what you think they are.
You are still comparing addresses.  To check for empty string, use
something like:

     if (*sodel->so_name == '\0')


> +           DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n",
> +                          (char *) &(sodel->so_name)));

And should print a char array like you were doing before:
 DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", sodel->so_name));

But, if so_name is built from so_original_name, and you're printing
just so_name in the load event, why extra that churn in the unload event?  
Just:

+         DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n",
+                        sodel->so_name));

Would be enough, I guess.

-- 
Pedro Alves


  reply	other threads:[~2008-06-13 22:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-13 15:28 Pierre Muller
2008-06-13 15:35 ` Pedro Alves
2008-06-13 23:07   ` Pierre Muller
2008-06-14  0:16     ` Pedro Alves [this message]
2008-06-14  3:20       ` [RFA-v3] " Pierre Muller
2008-06-16  1:26         ` Christopher Faylor
2008-06-16  6:38           ` Pedro Alves
2008-06-17  9:51             ` Christopher Faylor
2008-06-17 18:21               ` Christopher Faylor
2008-06-18  1:43               ` Pierre Muller
2008-06-18  7:33                 ` Christopher Faylor
2008-06-18 13:40                   ` Pierre Muller
2008-06-16 11:43           ` Pierre Muller

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=200806132354.59705.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=muller@ics.u-strasbg.fr \
    /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