Disable gdbserver on host != target configurations (Re: [PATCH] Move gdbserver to top level)

Message ID 304aa527-cc62-14ab-b607-4a7019b3083e@redhat.com
State New, archived
Headers

Commit Message

Pedro Alves Feb. 11, 2020, 1:48 p.m. UTC
  On 2/10/20 1:15 PM, Andreas Schwab wrote:
> On Feb 10 2020, Pedro Alves wrote:
> 
>> On 2/10/20 9:52 AM, Andreas Schwab wrote:
>>> Should gdbserver be disabled automatically when building with a cross
>>> compiler?
>>
>> I'm confused.  Why would we want to do that?
> 
> Actually what I mean is, when building a cross toolchain, host !=
> target.

Ah, yes.  In that case gdbserver is not going to be useful to
debug the target.

This patch below works for me.

From 0299b2ba691937a69b1d0b69b830794584f894ff Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 11 Feb 2020 13:47:28 +0000
Subject: [PATCH] Disable gdbserver on host != target configurations

If we're building a cross toolchain, hosted on $host targetting
$target, it's useless to build gdbserver, since it runs on $host and
debugs $host programs, not $target programs.

We used to have, gdb/configure.ac:

 # We only build gdbserver automatically in a native configuration, and
 # only if the user did not explicitly disable its build.
 if test "$gdb_native" = "yes" -a "$enable_gdbserver" != "no"; then
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

and gdb_native is set like this in gdb/configure.ac:

 if test "${target}" = "${host}"; then
   gdb_native=yes
 else
   gdb_native=no
 fi

But that was lost in the top-level move.

This patch restores the old behavior of not building gdbserver in the
non-native case.

gdbserver/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* configure.srv: Set UNSUPPORTED if $target != $host.
---
 gdbserver/configure.srv | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)


base-commit: c675ec1e76bc6cbf47031cd89dda9d9a3ce4993c
  

Comments

Tom Tromey Feb. 11, 2020, 3:25 p.m. UTC | #1
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> gdbserver/ChangeLog:
Pedro> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

Pedro> 	* configure.srv: Set UNSUPPORTED if $target != $host.

Thanks for doing this.  I like this approach, because it keeps the
decision confined to gdbserver.

Please push it.

Tom
  

Patch

diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
index 2e83cbdc07f..3bdddaabb20 100644
--- a/gdbserver/configure.srv
+++ b/gdbserver/configure.srv
@@ -33,7 +33,13 @@  ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-vsx32l-
 # these files over and over again.
 srv_linux_obj="linux-low.o nat/linux-osdata.o nat/linux-procfs.o nat/linux-ptrace.o nat/linux-waitpid.o nat/linux-personality.o nat/linux-namespaces.o fork-child.o nat/fork-inferior.o"
 
-# Input is taken from the "${host}" variable.
+# Input is taken from the "${host}" and "${target}" variables.
+
+# GDBserver can only debug native programs.
+if test "${target}" != "${host}"; then
+  UNSUPPORTED=1
+  exit 0
+fi
 
 case "${host}" in
   aarch64*-*-linux*)	srv_tgtobj="linux-aarch64-low.o"