This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Create avr-linux-tdep.c (add reintroduce gdbarch_gdb_signal_{to,from}_target for that target)
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Pedro Alves <palves at redhat dot com>, Joern Rennecke <joern dot rennecke at embecosm dot com>
- Date: Mon, 12 Aug 2013 16:47:31 -0300
- Subject: [PATCH] Create avr-linux-tdep.c (add reintroduce gdbarch_gdb_signal_{to,from}_target for that target)
Hi,
Given the discussion on:
<http://sourceware.org/ml/gdb-patches/2013-08/msg00290.html>
<http://sourceware.org/ml/gdb-patches/2013-08/msg00296.html>
Here is the patch to add avr-linux-tdep.c. This patch also reimplements
gdbarch_gdb_signal_{to,from}_target for AVR targets running on Linux.
Joern, could you please give it a try (I don't have access to AVR
targets here), and tell me what you think?
Thanks,
--
Sergio
2013-08-12 Sergio Durigan Junior <sergiodj@redhat.com>
* Makefile.in (ALL_TARGET_OBS): Add avr-linux-tdep.o.
(ALLDEPFILES): Add avr-linux-tdep.c.
* avr-linux-tdep.c: New file.
* configure.tgt: Add match for avr-*-*linux*.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 9171940..0be4198 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -548,7 +548,7 @@ ALL_TARGET_OBS = \
armbsd-tdep.o arm-linux-tdep.o arm-symbian-tdep.o \
armnbsd-tdep.o armobsd-tdep.o \
arm-tdep.o arm-wince-tdep.o \
- avr-tdep.o \
+ avr-linux-tdep.o avr-tdep.o \
bfin-linux-tdep.o bfin-tdep.o \
cris-tdep.o \
dicos-tdep.o \
@@ -1473,7 +1473,7 @@ ALLDEPFILES = \
amd64-sol2-tdep.c \
arm-linux-nat.c arm-linux-tdep.c arm-symbian-tdep.c arm-tdep.c \
armnbsd-nat.c armbsd-tdep.c armnbsd-tdep.c armobsd-tdep.c \
- avr-tdep.c \
+ avr-linux-tdep.c avr-tdep.c \
bfin-linux-tdep.c bfin-tdep.c \
bsd-uthread.c bsd-kvm.c \
core-regset.c \
diff --git a/gdb/avr-linux-tdep.c b/gdb/avr-linux-tdep.c
new file mode 100644
index 0000000..e45ddb7
--- /dev/null
+++ b/gdb/avr-linux-tdep.c
@@ -0,0 +1,115 @@
+/* Target-dependent code for Atmel AVR, for GDB.
+
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "defs.h"
+#include "gdbarch.h"
+#include "osabi.h"
+#include "linux-tdep.h"
+
+/* This enum represents the signals' numbers on the AVR
+ architecture. It just contains the signal definitions which are
+ different from the generic implementation.
+
+ It is derived from the file <arch/avr32/include/uapi/asm/signal.h>,
+ from the Linux kernel tree. */
+
+enum
+ {
+ AVR_LINUX_SIGRTMIN = 32,
+ AVR_LINUX_SIGRTMAX = 63,
+ };
+
+/* Implementation of `gdbarch_gdb_signal_from_target', as defined in
+ gdbarch.h. */
+
+static enum gdb_signal
+avr_linux_gdb_signal_from_target (struct gdbarch *gdbarch, int signal)
+{
+ if (signal >= AVR_LINUX_SIGRTMIN && signal <= AVR_LINUX_SIGRTMAX)
+ {
+ int offset = signal - AVR_LINUX_SIGRTMIN;
+
+ if (offset == 0)
+ return GDB_SIGNAL_REALTIME_32;
+ else
+ return (enum gdb_signal) (offset - 1
+ + (int) GDB_SIGNAL_REALTIME_33);
+ }
+ else if (signal > AVR_LINUX_SIGRTMAX)
+ return GDB_SIGNAL_UNKNOWN;
+
+ return linux_gdb_signal_from_target (gdbarch, signal);
+}
+
+/* Implementation of `gdbarch_gdb_signal_to_target', as defined in
+ gdbarch.h. */
+
+static int
+avr_linux_gdb_signal_to_target (struct gdbarch *gdbarch,
+ enum gdb_signal signal)
+{
+ switch (signal)
+ {
+ /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
+ therefore we have to handle it here. */
+ case GDB_SIGNAL_REALTIME_32:
+ return AVR_LINUX_SIGRTMIN;
+
+ /* GDB_SIGNAL_REALTIME_64 is not valid on AVR. */
+ case GDB_SIGNAL_REALTIME_64:
+ return -1;
+ }
+
+ /* GDB_SIGNAL_REALTIME_33 to _63 are continuous.
+ AVR does not have _64. */
+ if (signal >= GDB_SIGNAL_REALTIME_33
+ && signal <= GDB_SIGNAL_REALTIME_63)
+ {
+ int offset = signal - GDB_SIGNAL_REALTIME_33;
+
+ return AVR_LINUX_SIGRTMIN + 1 + offset;
+ }
+
+ return linux_gdb_signal_to_target (gdbarch, signal);
+}
+
+
+
+/* Initialize ABI for AVR. */
+
+static void
+avr_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+ linux_init_abi (info, gdbarch);
+
+ set_gdbarch_gdb_signal_from_target (gdbarch,
+ avr_linux_gdb_signal_from_target);
+ set_gdbarch_gdb_signal_to_target (gdbarch,
+ avr_linux_gdb_signal_to_target);
+}
+
+/* Silence -Wmissing-prototypes. */
+extern initialize_file_ftype _initialize_avr_linux_tdep;
+
+void
+_initialize_avr_linux_tdep (void)
+{
+ gdbarch_register_osabi (bfd_arch_avr, 0, GDB_OSABI_LINUX,
+ avr_linux_init_abi);
+}
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 653ba2b..500c596 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -111,6 +111,12 @@ arm*-*-*)
gdb_sim=../sim/arm/libsim.a
;;
+avr-*-*linux*)
+ # Target: AVR Linux
+ gdb_target_obs="avr-tdep.o avr-linux-tdep.o linux-tdep.o"
+ gdb_sim=../sim/avr/libsim.a
+ ;;
+
avr-*-*)
# Target: AVR
gdb_target_obs="avr-tdep.o"