From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26465 invoked by alias); 12 Aug 2013 19:47:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26452 invoked by uid 89); 12 Aug 2013 19:47:40 -0000 X-Spam-SWARE-Status: No, score=-7.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 12 Aug 2013 19:47:39 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7CJlajk000969 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 12 Aug 2013 15:47:36 -0400 Received: from psique (ovpn-113-52.phx2.redhat.com [10.3.113.52]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r7CJlWnL011991 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 12 Aug 2013 15:47:34 -0400 From: Sergio Durigan Junior To: GDB Patches Cc: Pedro Alves , Joern Rennecke Subject: [PATCH] Create avr-linux-tdep.c (add reintroduce gdbarch_gdb_signal_{to,from}_target for that target) X-URL: http://www.redhat.com Date: Mon, 12 Aug 2013 19:47:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-08/txt/msg00321.txt.bz2 Hi, Given the discussion on: 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 * 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 . */ + +#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 , + 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 , + 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"