Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Multi-process + multi-arch: GDB
Date: Fri, 09 Nov 2012 05:26:00 -0000	[thread overview]
Message-ID: <CAMe9rOq22--bcnnDBcvDZddC_nEN_LK9866TXLe-W+=Zs=H-cA@mail.gmail.com> (raw)
In-Reply-To: <20121109015149.13597.39322.stgit@brno.lan>

On Thu, Nov 8, 2012 at 5:51 PM, Pedro Alves <palves@redhat.com> wrote:
> This patch was part of a series I had posted back in
> <http://sourceware.org/ml/gdb-patches/2012-04/msg00202.html>.  I've
> been distracted from that work since then, but since questions similar
> or related to "how can we have more than one gdbarch" showed up on the
> python architecture thread, I remembered I could push this part in
> without the rest.  The rest of the series depends on this (and will
> need further porting work, since we have more gdbserver ports in the
> tree now, and at least a couple more pending...), but this can go in
> first and independently.  It fixes the issue for native targets.
>
> I had a chance of chatting with Ulrich at FOSDEM earlier in the year,
> and he also thought this was a good direction, so I'm putting it in.
>
> Although GDB currently supports debugging multiple inferiors
> simultaneously, GDB is not prepared to handle the case of debugging
> programs of different architectures (gdbarch's) simultaneously.  A
> simple example is debugging both a 32-bit and a 64-bit program
> simultaneously on x86_64 (think following forks, and 32-bit and/or
> 64-bit children being spawned), though more complicated examples could
> be multi-core setups with processors on the same target (e.g.,
> x86_64 + ARM isn't uncommon these days).
>
> E.g., loading both a 64-bit inferior and a 32-bit inferior into GDB
> shows (from the test in the patch):
>
>  (gdb) file test64
>  Reading symbols from test64...done.
>  (gdb) delete breakpoints
>  (gdb) break main
>  Breakpoint 1 at 0x40053a: file main.c, line 40.
>  (gdb) run
>  Starting program: test64
>
>  Breakpoint 1, main () at main.c:40
>  40        bar();
>  (gdb) add-inferior
>  Added inferior 2
>  inferior 2
>  [Switching to inferior 2 [<null>] (<noexec>)]
>  (gdb) file test32
>  warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  Architecture of file not recognized.
>
> The "Architecture of file not recognized" warning is misleading.  The
> real issue is that target_gdbarch and the target description are
> globals.  So instead of fetching the target description for the 32-bit
> process that was created for the `test32' program, the target
> description that was previously fetched for inferior 1 (64-bit) is
> assumed, and then things (rightfully) break, as it doesn't really
> match inferior 2.
>
> This patch makes target_gdbarch (and the associated description) be
> per-inferior instead.
>
> The new test fails without the rest of the patch.
>
> I've made the adjustment Yao pointed out in the old thread.
>
> (Re)tested on x86_64 Fedora 17, and checked in.
>
> gdb/
> 2012-11-09  Pedro Alves  <palves@redhat.com>
>
>         * gdbarch.sh (target_gdbarch) <gdbarch.h>: Reimplement as macro.
>         (get_target_gdbarch) <gdbarch.h>: New function.
>         (startup_gdbarch) <gdbarch.h>: Declare.
>         <gdbarch.c> (target_gdbarch): Delete.
>         <gdbarch.c> (deprecated_target_gdbarch_select_hack): Set the
>         current inferior's gdbarch.
>         <gdbarch.c> (get_target_gdbarch): New function.
>         * inferior.c: Include target-descriptions.h.
>         (free_inferior): Free target description info.
>         (add_inferior_with_spaces): Set the inferior's initial
>         architecture.
>         (clone_inferior_command): Copy the original inferior's target
>         description if it was user specified.
>         (initialize_inferiors): Add comment.
>         * inferior.h (struct target_desc_info): Forward declare.
>         (struct inferior) <gdbarch>: New field.
>         * linux-nat.c: Include target-descriptions.h.
>         (linux_child_follow_fork): Copy the parent's architecture and
>         target description to the child.
>         * target-descriptions.c: Include inferior.h.
>         (struct target_desc_info): New structure, holding the equivalents
>         of ...
>         (target_desc_fetched, current_target_desc)
>         (target_description_filename): ... these removed globals.
>         (get_tdesc_info, target_desc_info_from_user_p)
>         (copy_inferior_target_desc_info, target_desc_info_free): New.
>         (target_desc_fetched, current_target_desc)
>         (target_description_filename): Reimplemented as convenience
>         macros.
>         (tdesc_filename_cmd_string): New global.
>         (set_tdesc_filename_cmd): Copy the string manipulated by the "set
>         tdescs filename ..." commands to the per-inferior equivalent.
>         (show_tdesc_filename_cmd): Get the value to show from the
>         per-inferior description filename.
>         (_initilize_target_descriptions): Change the "set/show tdesc
>         filename" commands' variable.
>         * target-descriptions.h (struct target_desc, struct target_desc_info)
>         (struct inferior): Forward declare.
>         (target_find_description, target_clear_description)
>         (target_current_description): Adjust comments.
>         (copy_inferior_target_desc_info, target_desc_info_free)
>         (target_desc_info_from_user_p). Declare.
>

Does it fix

http://www.sourceware.org/bugzilla/show_bug.cgi?id=14306

-- 
H.J.


  reply	other threads:[~2012-11-09  5:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-09  1:52 Pedro Alves
2012-11-09  5:26 ` H.J. Lu [this message]
2012-11-09 10:07   ` Pedro Alves
2012-11-09 18:24 ` Tom Tromey
2012-11-09 18:30   ` Pedro Alves
2012-11-09 18:32     ` Tom Tromey
2012-11-09 18:47       ` Pedro Alves
2012-11-09 19:08         ` Tom Tromey
2012-11-09 19:14           ` Pedro Alves
2012-11-09 19:18             ` Tom Tromey
2012-11-09 19:40           ` should deprecated_target_gdbarch_select_hack be un-deprecated? Pedro Alves
2012-11-13 21:17             ` Tom Tromey
2012-11-14 13:54               ` Pedro Alves
2012-11-14 15:34                 ` Tom Tromey
2012-11-10 16:25           ` [PATCH] Multi-process + multi-arch: GDB Michael Eager
2012-11-13 20:50             ` Tom Tromey
2012-11-14 13:48               ` Pedro Alves

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='CAMe9rOq22--bcnnDBcvDZddC_nEN_LK9866TXLe-W+=Zs=H-cA@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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