From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Pedro Alves <palves@redhat.com>,
Joern Rennecke <joern.rennecke@embecosm.com>
Subject: [PATCH] Create avr-linux-tdep.c (add reintroduce gdbarch_gdb_signal_{to,from}_target for that target)
Date: Mon, 12 Aug 2013 19:47:00 -0000 [thread overview]
Message-ID: <m3wqnqvgh8.fsf@redhat.com> (raw)
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);
+}
+
+\f
+
+/* 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"
next reply other threads:[~2013-08-12 19:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-12 19:47 Sergio Durigan Junior [this message]
2013-08-12 21:19 ` Joern Rennecke
2013-08-12 21:49 ` Sergio Durigan Junior
2013-08-13 14:16 ` Pedro Alves
2013-08-13 16:00 ` Sergio Durigan Junior
2013-08-25 4:51 ` Mike Frysinger
2013-08-25 19:42 ` Sergio Durigan Junior
2013-08-26 3:41 ` Mike Frysinger
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=m3wqnqvgh8.fsf@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=joern.rennecke@embecosm.com \
--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