2013-05-06 Sandra Loosemore <sandra@codesourcery.com>

Andrew Jenner  <andrew@codesourcery.com>
	    Chung-Lin Tang  <cltang@codesourcery.com>
	    Julian Brown  <julian@codesourcery.com>

	Based on the nios2-elf port from Altera Corporation.

	gdb/
	* Makefile.in (ALL_TARGET_OBS): Add nios2-tdep.o and
	nios2-linux-tdep.o.
	(HFILES_NO_SRCDIR): Add nios2-tdep.h.
	(ALLDEPFILES): Add nios2-tdep.c and nios2-linux-tdep.c.
	* configure.tgt: Add nios2*-*-linux* and nios2*-*-* targets.
	* nios2-tdep.h: New.
	* nios2-tdep.c: New.
	* nios2-linux-tdep.c: New.
	* features/Makefile (WHICH): Add nios2-linux.
	(nios2-linux-expedite): Set.
	* features/nios2-cpu.xml: New.
	* features/nios2.xml: New.
	* features/nios2-linux.xml: New.
	* features/nios2.c: New (autogenerated).
	* features/nios2-linux.c: New (autogenerated).
	* regformats/nios2-linux.dat: New (autogenerated).
	* NEWS (Changes since GDB 7.6): Add new Nios II targets
	and commands.

	gdb/doc/
	* gdb.texinfo (Nios II): New section.
	(Nios II Features): New section.
This commit is contained in:
Sandra Loosemore 2013-05-07 01:09:29 +00:00
parent 3b7bacacfd
commit a1217d97c4
16 changed files with 2313 additions and 1 deletions

View file

@ -1,3 +1,29 @@
2013-05-06 Sandra Loosemore <sandra@codesourcery.com>
Andrew Jenner <andrew@codesourcery.com>
Chung-Lin Tang <cltang@codesourcery.com>
Julian Brown <julian@codesourcery.com>
Based on the nios2-elf port from Altera Corporation.
* Makefile.in (ALL_TARGET_OBS): Add nios2-tdep.o and
nios2-linux-tdep.o.
(HFILES_NO_SRCDIR): Add nios2-tdep.h.
(ALLDEPFILES): Add nios2-tdep.c and nios2-linux-tdep.c.
* configure.tgt: Add nios2*-*-linux* and nios2*-*-* targets.
* nios2-tdep.h: New.
* nios2-tdep.c: New.
* nios2-linux-tdep.c: New.
* features/Makefile (WHICH): Add nios2-linux.
(nios2-linux-expedite): Set.
* features/nios2-cpu.xml: New.
* features/nios2.xml: New.
* features/nios2-linux.xml: New.
* features/nios2.c: New (autogenerated).
* features/nios2-linux.c: New (autogenerated).
* regformats/nios2-linux.dat: New (autogenerated).
* NEWS (Changes since GDB 7.6): Add new Nios II targets
and commands.
2013-05-06 Doug Evans <dje@google.com>
* symfile.c: Whitespace cleanup.

View file

@ -571,6 +571,7 @@ ALL_TARGET_OBS = \
mn10300-linux-tdep.o mn10300-tdep.o \
moxie-tdep.o \
mt-tdep.o \
nios2-tdep.o nios2-linux-tdep.o \
nto-tdep.o \
ppc-linux-tdep.o ppcnbsd-tdep.o ppcobsd-tdep.o ppc-sysv-tdep.o \
ppc64-tdep.o rl78-tdep.o \
@ -834,7 +835,7 @@ psymtab.h psympriv.h progspace.h bfin-tdep.h ia64-hpux-tdep.h \
amd64-darwin-tdep.h charset-list.h \
config/djgpp/langinfo.h config/djgpp/nl_types.h darwin-nat.h \
dicos-tdep.h filesystem.h gcore.h gdb_wchar.h hppabsd-tdep.h \
i386-darwin-tdep.h i386-nat.h linux-record.h moxie-tdep.h \
i386-darwin-tdep.h i386-nat.h linux-record.h moxie-tdep.h nios2-tdep.h \
osdata.h procfs.h python/py-event.h python/py-events.h python/py-stopevent.h \
python/python-internal.h python/python.h ravenscar-thread.h record.h \
record-full.h solib-aix.h \
@ -1516,6 +1517,7 @@ ALLDEPFILES = \
mips-tdep.c \
mipsnbsd-nat.c mipsnbsd-tdep.c \
mips64obsd-nat.c mips64obsd-tdep.c \
nios2-tdep.c nios2-linux-tdep.c \
nbsd-nat.c nbsd-tdep.c obsd-tdep.c \
solib-osf.c \
somread.c solib-som.c \

View file

@ -3,6 +3,11 @@
*** Changes since GDB 7.6
* New targets
Nios II ELF nios2*-*-elf
Nios II GNU/Linux nios2*-*-linux
* New commands:
catch rethrow
Like "catch throw", but catches a re-thrown exception.
@ -22,6 +27,10 @@ set remote trace-status-packet
show remote trace-status-packet
Set/show the use of remote protocol qTStatus packet.
set debug nios2
show debug nios2
Control display of debugging messages related to Nios II targets.
* You can now use a literal value 'unlimited' for options that
interpret 0 or -1 as meaning "unlimited". E.g., "set
trace-buffer-size unlimited" is now an alias for "set

View file

@ -396,6 +396,17 @@ mt-*-*)
gdb_target_obs="mt-tdep.o"
;;
nios2*-*-linux*)
# Target: Altera Nios II running Linux
gdb_target_obs="nios2-tdep.o nios2-linux-tdep.o solib-svr4.o \
symfile-mem.o glibc-tdep.o linux-tdep.o"
;;
nios2*-*-*)
# Target: Altera Nios II bare-metal
gdb_target_obs="nios2-tdep.o"
;;
powerpc*-*-freebsd*)
# Target: FreeBSD/powerpc
gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \

View file

@ -1,3 +1,8 @@
2013-05-06 Sandra Loosemore <sandra@codesourcery.com>
* gdb.texinfo (Nios II): New section.
(Nios II Features): New section.
2013-05-06 Joel Brobecker <brobecker@adacore.com>
* gdbint.texinfo (Algorithms): Remove entries documenting

View file

@ -20832,6 +20832,7 @@ all uses of @value{GDBN} with the architecture, both native and cross.
* HPPA:: HP PA architecture
* SPU:: Cell Broadband Engine SPU architecture
* PowerPC::
* Nios II::
@end menu
@node AArch64
@ -21115,6 +21116,24 @@ by joining the even/odd register pairs @code{f0} and @code{f1} for @code{$dl0},
For POWER7 processors, @value{GDBN} provides a set of pseudo-registers, the 64-bit
wide Extended Floating Point Registers (@samp{f32} through @samp{f63}).
@node Nios II
@subsection Nios II
@cindex Nios II architecture
When @value{GDBN} is debugging the Nios II architecture,
it provides the following special commands:
@table @code
@item set debug nios2
@kindex set debug nios2
This command turns on and off debugging messages for the Nios II
target code in @value{GDBN}.
@item show debug nios2
@kindex show debug nios2
Show the current setting of Nios II debugging messages.
@end table
@node Controlling GDB
@chapter Controlling @value{GDBN}
@ -41225,6 +41244,7 @@ registers using the capitalization used in the description.
* i386 Features::
* MIPS Features::
* M68K Features::
* Nios II Features::
* PowerPC Features::
* TIC6x Features::
@end menu
@ -41374,6 +41394,16 @@ This feature is optional. If present, it should contain registers
@samp{fpiaddr}.
@end table
@node Nios II Features
@subsection Nios II Features
@cindex target descriptions, Nios II features
The @samp{org.gnu.gdb.nios2.cpu} feature is required for Nios II
targets. It should contain the 32 core registers (@samp{zero},
@samp{at}, @samp{r2} through @samp{r23}, @samp{et} through @samp{ra}),
@samp{pc}, and the 16 control registers (@samp{status} through
@samp{mpuacc}).
@node PowerPC Features
@subsection PowerPC Features
@cindex target descriptions, PowerPC features

View file

@ -42,6 +42,7 @@ WHICH = aarch64 aarch64-without-fpu \
i386/x32-avx i386/x32-avx-linux \
mips-linux mips-dsp-linux \
mips64-linux mips64-dsp-linux \
nios2-linux \
rs6000/powerpc-32 \
rs6000/powerpc-32l rs6000/powerpc-altivec32l rs6000/powerpc-e500l \
rs6000/powerpc-64l rs6000/powerpc-altivec64l rs6000/powerpc-vsx32l \
@ -73,6 +74,7 @@ mips-expedite = r29,pc
mips-dsp-expedite = r29,pc
mips64-expedite = r29,pc
mips64-dsp-expedite = r29,pc
nios2-linux-expedite = sp,pc
powerpc-expedite = r1,pc
rs6000/powerpc-cell32l-expedite = r1,pc,r0,orig_r3,r4
rs6000/powerpc-cell64l-expedite = r1,pc,r0,orig_r3,r4

View file

@ -0,0 +1,59 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2012-2013 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.nios2.cpu">
<reg name="zero" bitsize="32" type="uint32"/>
<reg name="at" bitsize="32" type="uint32"/>
<reg name="r2" bitsize="32" type="uint32"/>
<reg name="r3" bitsize="32" type="uint32"/>
<reg name="r4" bitsize="32" type="uint32"/>
<reg name="r5" bitsize="32" type="uint32"/>
<reg name="r6" bitsize="32" type="uint32"/>
<reg name="r7" bitsize="32" type="uint32"/>
<reg name="r8" bitsize="32" type="uint32"/>
<reg name="r9" bitsize="32" type="uint32"/>
<reg name="r10" bitsize="32" type="uint32"/>
<reg name="r11" bitsize="32" type="uint32"/>
<reg name="r12" bitsize="32" type="uint32"/>
<reg name="r13" bitsize="32" type="uint32"/>
<reg name="r14" bitsize="32" type="uint32"/>
<reg name="r15" bitsize="32" type="uint32"/>
<reg name="r16" bitsize="32" type="uint32"/>
<reg name="r17" bitsize="32" type="uint32"/>
<reg name="r18" bitsize="32" type="uint32"/>
<reg name="r19" bitsize="32" type="uint32"/>
<reg name="r20" bitsize="32" type="uint32"/>
<reg name="r21" bitsize="32" type="uint32"/>
<reg name="r22" bitsize="32" type="uint32"/>
<reg name="r23" bitsize="32" type="uint32"/>
<reg name="et" bitsize="32" type="uint32"/>
<reg name="bt" bitsize="32" type="uint32"/>
<reg name="gp" bitsize="32" type="uint32"/>
<reg name="sp" bitsize="32" type="data_ptr"/>
<reg name="fp" bitsize="32" type="uint32"/>
<reg name="ea" bitsize="32" type="uint32"/>
<reg name="ba" bitsize="32" type="uint32"/>
<reg name="ra" bitsize="32" type="uint32"/>
<reg name="pc" bitsize="32" type="code_ptr"/>
<reg name="status" bitsize="32" type="uint32"/>
<reg name="estatus" bitsize="32" type="uint32"/>
<reg name="bstatus" bitsize="32" type="uint32"/>
<reg name="ienable" bitsize="32" type="uint32"/>
<reg name="ipending" bitsize="32" type="uint32"/>
<reg name="cpuid" bitsize="32" type="uint32"/>
<reg name="ctl6" bitsize="32" type="uint32"/>
<reg name="exception" bitsize="32" type="uint32"/>
<reg name="pteaddr" bitsize="32" type="uint32"/>
<reg name="tlbacc" bitsize="32" type="uint32"/>
<reg name="tlbmisc" bitsize="32" type="uint32"/>
<reg name="eccinj" bitsize="32" type="uint32"/>
<reg name="badaddr" bitsize="32" type="uint32"/>
<reg name="config" bitsize="32" type="uint32"/>
<reg name="mpubase" bitsize="32" type="uint32"/>
<reg name="mpuacc" bitsize="32" type="uint32"/>
</feature>

View file

@ -0,0 +1,71 @@
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: nios2-linux.xml */
#include "defs.h"
#include "osabi.h"
#include "target-descriptions.h"
struct target_desc *tdesc_nios2_linux;
static void
initialize_tdesc_nios2_linux (void)
{
struct target_desc *result = allocate_target_description ();
struct tdesc_feature *feature;
set_tdesc_architecture (result, bfd_scan_arch ("nios2"));
set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
feature = tdesc_create_feature (result, "org.gnu.gdb.nios2.cpu");
tdesc_create_reg (feature, "zero", 0, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "at", 1, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "et", 24, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "bt", 25, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "gp", 26, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "sp", 27, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "fp", 28, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ea", 29, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ba", 30, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ra", 31, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "pc", 32, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "status", 33, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "estatus", 34, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "bstatus", 35, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ienable", 36, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ipending", 37, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "cpuid", 38, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ctl6", 39, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "exception", 40, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "pteaddr", 41, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "tlbacc", 42, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "tlbmisc", 43, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "eccinj", 44, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "badaddr", 45, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "config", 46, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "mpubase", 47, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "mpuacc", 48, 1, NULL, 32, "uint32");
tdesc_nios2_linux = result;
}

View file

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2012-2013 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
<architecture>nios2</architecture>
<osabi>GNU/Linux</osabi>
<xi:include href="nios2-cpu.xml"/>
</target>

69
gdb/features/nios2.c Normal file
View file

@ -0,0 +1,69 @@
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: nios2.xml */
#include "defs.h"
#include "osabi.h"
#include "target-descriptions.h"
struct target_desc *tdesc_nios2;
static void
initialize_tdesc_nios2 (void)
{
struct target_desc *result = allocate_target_description ();
struct tdesc_feature *feature;
set_tdesc_architecture (result, bfd_scan_arch ("nios2"));
feature = tdesc_create_feature (result, "org.gnu.gdb.nios2.cpu");
tdesc_create_reg (feature, "zero", 0, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "at", 1, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "et", 24, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "bt", 25, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "gp", 26, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "sp", 27, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "fp", 28, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ea", 29, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ba", 30, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ra", 31, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "pc", 32, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "status", 33, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "estatus", 34, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "bstatus", 35, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ienable", 36, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ipending", 37, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "cpuid", 38, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "ctl6", 39, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "exception", 40, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "pteaddr", 41, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "tlbacc", 42, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "tlbmisc", 43, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "eccinj", 44, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "badaddr", 45, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "config", 46, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "mpubase", 47, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "mpuacc", 48, 1, NULL, 32, "uint32");
tdesc_nios2 = result;
}

12
gdb/features/nios2.xml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2013 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
<architecture>nios2</architecture>
<xi:include href="nios2-cpu.xml"/>
</target>

233
gdb/nios2-linux-tdep.c Normal file
View file

@ -0,0 +1,233 @@
/* Target-dependent code for GNU/Linux on Nios II.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
Contributed by Mentor Graphics, 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 "frame.h"
#include "gdb_assert.h"
#include "gdb_string.h"
#include "osabi.h"
#include "solib-svr4.h"
#include "trad-frame.h"
#include "tramp-frame.h"
#include "symtab.h"
#include "regset.h"
#include "regcache.h"
#include "linux-tdep.h"
#include "glibc-tdep.h"
#include "nios2-tdep.h"
#include "features/nios2-linux.c"
/* Core file and register set support. */
/* Map from the normal register enumeration order to the order that
registers appear in core files, which corresponds to the order
of the register slots in the kernel's struct pt_regs. */
static const int reg_offsets[NIOS2_NUM_REGS] =
{
-1, 8, 9, 10, 11, 12, 13, 14, /* r0 - r7 */
0, 1, 2, 3, 4, 5, 6, 7, /* r8 - r15 */
23, 24, 25, 26, 27, 28, 29, 30, /* r16 - r23 */
-1, -1, 19, 18, 17, 21, -1, 16, /* et bt gp sp fp ea ba ra */
21, /* pc */
-1, 20, -1, -1, -1, -1, -1, -1, /* status estatus ... */
-1, -1, -1, -1, -1, -1, -1, -1
};
/* Implement the supply_regset hook for core files. */
static void
nios2_supply_gregset (const struct regset *regset,
struct regcache *regcache,
int regnum, const void *gregs_buf, size_t len)
{
const gdb_byte *gregs = gregs_buf;
int regno;
static const gdb_byte zero_buf[4] = {0, 0, 0, 0};
for (regno = NIOS2_Z_REGNUM; regno <= NIOS2_MPUACC_REGNUM; regno++)
if (regnum == -1 || regnum == regno)
{
if (reg_offsets[regno] != -1)
regcache_raw_supply (regcache, regno,
gregs + 4 * reg_offsets[regno]);
else
regcache_raw_supply (regcache, regno, zero_buf);
}
}
static struct regset nios2_core_regset =
{
NULL,
nios2_supply_gregset,
NULL,
NULL
};
/* Implement the regset_from_core_section gdbarch method. */
static const struct regset *
nios2_regset_from_core_section (struct gdbarch *gdbarch,
const char *sect_name, size_t sect_size)
{
if (strcmp (sect_name, ".reg") == 0)
return &nios2_core_regset;
return NULL;
}
/* Initialize a trad-frame cache corresponding to the tramp-frame.
FUNC is the address of the instruction TRAMP[0] in memory. */
static void
nios2_linux_sigreturn_init (const struct tramp_frame *self,
struct frame_info *next_frame,
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
CORE_ADDR base = func + 16;
int i;
for (i = 0; i < 8; i++)
trad_frame_set_reg_addr (this_cache, i + 8, base + i * 4);
for (i = 0; i < 7; i++)
trad_frame_set_reg_addr (this_cache, i + 1, base + (i + 8) * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_RA_REGNUM, base + 16 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_FP_REGNUM, base + 17 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_SP_REGNUM, base + 18 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_GP_REGNUM, base + 19 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_ESTATUS_REGNUM, base + 20 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_PC_REGNUM, base + 21 * 4);
/* Save a frame ID. */
trad_frame_set_id (this_cache, frame_id_build (base, func));
}
/* Initialize a trad-frame cache corresponding to the tramp-frame.
FUNC is the address of the instruction TRAMP[0] in memory. */
static void
nios2_linux_rt_sigreturn_init (const struct tramp_frame *self,
struct frame_info *next_frame,
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
CORE_ADDR base = func + 41 * 4;
int i;
for (i = 0; i < 23; i++)
trad_frame_set_reg_addr (this_cache, i + 1, base + i * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_RA_REGNUM, base + 23 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_FP_REGNUM, base + 24 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_GP_REGNUM, base + 25 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_PC_REGNUM, base + 27 * 4);
trad_frame_set_reg_addr (this_cache, NIOS2_SP_REGNUM, base + 28 * 4);
/* Save a frame ID. */
trad_frame_set_id (this_cache, frame_id_build (base, func));
}
static struct tramp_frame nios2_linux_sigreturn_tramp_frame =
{
SIGTRAMP_FRAME,
4,
{
{ 0x00800004 | (119 << 6), -1 }, /* movi r2,__NR_sigreturn */
{ 0x003b683a, -1 }, /* trap */
{ TRAMP_SENTINEL_INSN }
},
nios2_linux_sigreturn_init
};
static struct tramp_frame nios2_linux_rt_sigreturn_tramp_frame =
{
SIGTRAMP_FRAME,
4,
{
{ 0x00800004 | (173 << 6), -1 }, /* movi r2,__NR_rt_sigreturn */
{ 0x003b683a, -1 }, /* trap */
{ TRAMP_SENTINEL_INSN }
},
nios2_linux_rt_sigreturn_init
};
/* When FRAME is at a syscall instruction, return the PC of the next
instruction to be executed. */
static CORE_ADDR
nios2_linux_syscall_next_pc (struct frame_info *frame)
{
CORE_ADDR pc = get_frame_pc (frame);
ULONGEST syscall_nr = get_frame_register_unsigned (frame, NIOS2_R2_REGNUM);
/* If we are about to make a sigreturn syscall, use the unwinder to
decode the signal frame. */
if (syscall_nr == 119 /* sigreturn */
|| syscall_nr == 173 /* rt_sigreturn */)
return frame_unwind_caller_pc (frame);
return pc + NIOS2_OPCODE_SIZE;
}
/* Hook function for gdbarch_register_osabi. */
static void
nios2_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
linux_init_abi (info, gdbarch);
/* Shared library handling. */
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
set_solib_svr4_fetch_link_map_offsets (gdbarch,
svr4_ilp32_fetch_link_map_offsets);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
/* Core file support. */
set_gdbarch_regset_from_core_section (gdbarch,
nios2_regset_from_core_section);
/* Linux signal frame unwinders. */
tramp_frame_prepend_unwinder (gdbarch,
&nios2_linux_sigreturn_tramp_frame);
tramp_frame_prepend_unwinder (gdbarch,
&nios2_linux_rt_sigreturn_tramp_frame);
tdep->syscall_next_pc = nios2_linux_syscall_next_pc;
/* Index of target address word in glibc jmp_buf. */
tdep->jb_pc = 10;
}
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_nios2_linux_tdep;
void
_initialize_nios2_linux_tdep (void)
{
gdbarch_register_osabi (bfd_arch_nios2, 0, GDB_OSABI_LINUX,
nios2_linux_init_abi);
initialize_tdesc_nios2_linux ();
}

1637
gdb/nios2-tdep.c Normal file

File diff suppressed because it is too large Load diff

80
gdb/nios2-tdep.h Normal file
View file

@ -0,0 +1,80 @@
/* Target-dependent header for the Nios II architecture, for GDB.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
Contributed by Mentor Graphics, 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/>. */
#ifndef NIOS2_TDEP_H
#define NIOS2_TDEP_H
/* Registers. */
#define NIOS2_Z_REGNUM 0 /* Zero */
#define NIOS2_R2_REGNUM 2 /* used for return value */
#define NIOS2_R3_REGNUM 3 /* used for return value */
/* Used for hidden zero argument to store ptr to struct return value. */
#define NIOS2_R4_REGNUM 4
#define NIOS2_R7_REGNUM 7
#define NIOS2_GP_REGNUM 26 /* Global Pointer */
#define NIOS2_SP_REGNUM 27 /* Stack Pointer */
#define NIOS2_FP_REGNUM 28 /* Frame Pointer */
#define NIOS2_EA_REGNUM 29 /* Exception address */
#define NIOS2_BA_REGNUM 30 /* Breakpoint return address */
#define NIOS2_RA_REGNUM 31 /* Return address */
#define NIOS2_PC_REGNUM 32
/* Control registers. */
#define NIOS2_STATUS_REGNUM 33
#define NIOS2_ESTATUS_REGNUM 34
#define NIOS2_BSTATUS_REGNUM 35
#define NIOS2_IENABLE_REGNUM 36
#define NIOS2_IPENDING_REGNUM 37
#define NIOS2_CPUID_REGNUM 38
#define NIOS2_EXCEPTION_REGNUM 40
#define NIOS2_PTEADDR_REGNUM 41
#define NIOS2_TLBACC_REGNUM 42
#define NIOS2_TLBMISC_REGNUM 43
#define NIOS2_ECCINJ_REGNUM 44
#define NIOS2_BADADDR_REGNUM 45
#define NIOS2_CONFIG_REGNUM 46
#define NIOS2_MPUBASE_REGNUM 47
#define NIOS2_MPUACC_REGNUM 48
/* R4-R7 are used for argument passing. */
#define NIOS2_FIRST_ARGREG NIOS2_R4_REGNUM
#define NIOS2_LAST_ARGREG NIOS2_R7_REGNUM
/* Number of all registers. */
#define NIOS2_NUM_REGS 49
/* Size of an instruction, in bytes. */
#define NIOS2_OPCODE_SIZE 4
/* Target-dependent structure in gdbarch. */
struct gdbarch_tdep
{
/* Assumes FRAME is stopped at a syscall (trap) instruction; returns
the expected next PC. */
CORE_ADDR (*syscall_next_pc) (struct frame_info *frame);
/* Offset to PC value in jump buffer.
If this is negative, longjmp support will be disabled. */
int jb_pc;
};
extern struct target_desc *tdesc_nios2_linux;
extern struct target_desc *tdesc_nios2;
#endif /* NIOS2_TDEP_H */

View file

@ -0,0 +1,53 @@
# DO NOT EDIT: generated from nios2-linux.xml
name:nios2_linux
xmltarget:nios2-linux.xml
expedite:sp,pc
32:zero
32:at
32:r2
32:r3
32:r4
32:r5
32:r6
32:r7
32:r8
32:r9
32:r10
32:r11
32:r12
32:r13
32:r14
32:r15
32:r16
32:r17
32:r18
32:r19
32:r20
32:r21
32:r22
32:r23
32:et
32:bt
32:gp
32:sp
32:fp
32:ea
32:ba
32:ra
32:pc
32:status
32:estatus
32:bstatus
32:ienable
32:ipending
32:cpuid
32:ctl6
32:exception
32:pteaddr
32:tlbacc
32:tlbmisc
32:eccinj
32:badaddr
32:config
32:mpubase
32:mpuacc