Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Feb 2009 18:22:50 +0000 (UTC)
From:      Rafal Jaworowski <raj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r188941 - in head: . gnu/usr.bin/gdb gnu/usr.bin/gdb/gdbserver
Message-ID:  <200902231822.n1NIMoPN032186@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: raj
Date: Mon Feb 23 18:22:49 2009
New Revision: 188941
URL: http://svn.freebsd.org/changeset/base/188941

Log:
  Initial gdbserver support for PowerPC.
  
  Obtained from:	Juniper Networks, Semihalf

Added:
  head/gnu/usr.bin/gdb/gdbserver/fbsd-ppc-low.c   (contents, props changed)
  head/gnu/usr.bin/gdb/gdbserver/reg-ppc.c   (contents, props changed)
Modified:
  head/ObsoleteFiles.inc
  head/gnu/usr.bin/gdb/Makefile
  head/gnu/usr.bin/gdb/gdbserver/Makefile

Modified: head/ObsoleteFiles.inc
==============================================================================
--- head/ObsoleteFiles.inc	Mon Feb 23 18:22:06 2009	(r188940)
+++ head/ObsoleteFiles.inc	Mon Feb 23 18:22:49 2009	(r188941)
@@ -1674,7 +1674,7 @@ OLD_FILES+=usr/lib/libpam_ssh.a
 OLD_FILES+=usr/lib/libpam_ssh_p.a
 OLD_FILES+=usr/bin/help
 OLD_FILES+=usr/bin/sccs
-.if ${TARGET_ARCH} != "arm" && ${TARGET_ARCH} != "i386"
+.if ${TARGET_ARCH} != "arm" && ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "powerpc"
 OLD_FILES+=usr/bin/gdbserver
 .endif
 OLD_FILES+=usr/bin/ssh-keysign

Modified: head/gnu/usr.bin/gdb/Makefile
==============================================================================
--- head/gnu/usr.bin/gdb/Makefile	Mon Feb 23 18:22:06 2009	(r188940)
+++ head/gnu/usr.bin/gdb/Makefile	Mon Feb 23 18:22:49 2009	(r188941)
@@ -2,7 +2,7 @@
 
 SUBDIR=	doc libgdb gdb gdbtui kgdb
 
-.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "arm"
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "powerpc"
 SUBDIR+=gdbserver
 .endif
 

Modified: head/gnu/usr.bin/gdb/gdbserver/Makefile
==============================================================================
--- head/gnu/usr.bin/gdb/gdbserver/Makefile	Mon Feb 23 18:22:06 2009	(r188940)
+++ head/gnu/usr.bin/gdb/gdbserver/Makefile	Mon Feb 23 18:22:49 2009	(r188941)
@@ -22,6 +22,10 @@ SRCS+= fbsd-i386-low.c i387-fp.c reg-i38
 SRCS+= fbsd-arm-low.c reg-arm.c
 .endif
 
+.if ${MACHINE_ARCH} == "powerpc"
+SRCS+= fbsd-ppc-low.c reg-ppc.c
+.endif
+
 #CFLAGS+=	-I${.CURDIR}/../arch/${MACHINE_ARCH}
 CFLAGS+=	-I${GDBDIR}/gdb/gdbserver
 CFLAGS+=	-I${GDBDIR}/gdb/regformats

Added: head/gnu/usr.bin/gdb/gdbserver/fbsd-ppc-low.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/gnu/usr.bin/gdb/gdbserver/fbsd-ppc-low.c	Mon Feb 23 18:22:49 2009	(r188941)
@@ -0,0 +1,156 @@
+/* FreeBSD/PowerPC specific low level interface, for the remote server for
+   GDB.
+   Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002
+   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 2 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, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "server.h"
+#include "fbsd-low.h"
+
+#include <sys/procfs.h>
+#include <sys/ptrace.h>
+
+#define ppc_num_regs 71
+
+/* Currently, don't check/send MQ.  */
+static int ppc_regmap[] =
+ { 0, 4, 8, 12, 16, 20, 24, 28,
+   32, 36, 40, 44, 48, 52, 56, 60,
+   64, 68, 72, 76, 80, 84, 88, 92,
+   96, 100, 104, 108, 112, 116, 120, 124,
+#if 0
+  /*
+   * XXX on FreeBSD the gdbserver for PowerPC was only tested with FPU-less
+   * cores i.e. e500. Let's leave the original FPR references around in case
+   * someone picks up and brings support for AIM-like FPU machines.
+   */
+  PT_FPR0*4,     PT_FPR0*4 + 8, PT_FPR0*4+16,  PT_FPR0*4+24,
+  PT_FPR0*4+32,  PT_FPR0*4+40,  PT_FPR0*4+48,  PT_FPR0*4+56,
+  PT_FPR0*4+64,  PT_FPR0*4+72,  PT_FPR0*4+80,  PT_FPR0*4+88,
+  PT_FPR0*4+96,  PT_FPR0*4+104,  PT_FPR0*4+112,  PT_FPR0*4+120,
+  PT_FPR0*4+128, PT_FPR0*4+136,  PT_FPR0*4+144,  PT_FPR0*4+152,
+  PT_FPR0*4+160,  PT_FPR0*4+168,  PT_FPR0*4+176,  PT_FPR0*4+184,
+  PT_FPR0*4+192,  PT_FPR0*4+200,  PT_FPR0*4+208,  PT_FPR0*4+216,
+  PT_FPR0*4+224,  PT_FPR0*4+232,  PT_FPR0*4+240,  PT_FPR0*4+248,
+#endif
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1,
+   144, -1, 132, 128, 140, 136, -1
+ };
+
+static int
+ppc_cannot_store_register (int regno)
+{
+  /* Some kernels do not allow us to store fpscr.  */
+  if (regno == find_regno ("fpscr"))
+    return 2;
+
+  return 0;
+}
+
+static int
+ppc_cannot_fetch_register (int regno)
+{
+  return 0;
+}
+
+static CORE_ADDR
+ppc_get_pc (void)
+{
+  unsigned long pc;
+
+  collect_register_by_name ("pc", &pc);
+  return (CORE_ADDR) pc;
+}
+
+static void
+ppc_set_pc (CORE_ADDR pc)
+{
+  unsigned long newpc = pc;
+
+  supply_register_by_name ("pc", &newpc);
+}
+
+/* Correct in either endianness.  Note that this file is
+   for PowerPC only, not PowerPC64.
+   This instruction is "twge r2, r2", which GDB uses as a software
+   breakpoint.  */
+static const unsigned long ppc_breakpoint = 0x7d821008;
+#define ppc_breakpoint_len 4
+
+static int
+ppc_breakpoint_at (CORE_ADDR where)
+{
+  unsigned long insn;
+
+  (*the_target->read_memory) (where, (char *) &insn, 4);
+  if (insn == ppc_breakpoint)
+    return 1;
+  /* If necessary, recognize more trap instructions here.  GDB only uses the
+     one.  */
+  return 0;
+}
+
+static void
+ppc_fill_gregset (void *buf)
+{
+  int i;
+
+  for (i = 0; i < ppc_num_regs; i++)
+	if (ppc_regmap[i] != -1)
+		collect_register (i, ((char *) buf) + ppc_regmap[i]);
+
+}
+
+static void
+ppc_store_gregset (const void *buf)
+{
+  int i;
+
+  for (i = 0; i < ppc_num_regs; i++)
+	if (ppc_regmap[i] != -1)
+		supply_register (i, ((char *) buf) + ppc_regmap[i]);
+
+}
+
+struct regset_info target_regsets[] = {
+  { PT_GETREGS, PT_SETREGS, sizeof (struct reg),
+    GENERAL_REGS,
+    ppc_fill_gregset, ppc_store_gregset },
+  { 0, 0, -1, -1, NULL, NULL }
+};
+
+struct fbsd_target_ops the_low_target = {
+  ppc_num_regs,
+  ppc_regmap,
+  ppc_cannot_fetch_register,
+  ppc_cannot_store_register,
+  ppc_get_pc,
+  ppc_set_pc,
+  (const char *) &ppc_breakpoint,
+  ppc_breakpoint_len,
+  NULL,
+  0,
+  ppc_breakpoint_at,
+};

Added: head/gnu/usr.bin/gdb/gdbserver/reg-ppc.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/gnu/usr.bin/gdb/gdbserver/reg-ppc.c	Mon Feb 23 18:22:49 2009	(r188941)
@@ -0,0 +1,113 @@
+/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
+
+/* A register protocol for GDB, the GNU debugger.
+   Copyright 2001, 2002 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 2 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, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This file was created with the aid of ``regdat.sh'' and ``../../../../contrib/gdb/gdb/regformats/reg-ppc.dat''.  */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "regdef.h"
+#include "regcache.h"
+
+struct reg regs_ppc[] = {
+  { "r0", 0, 32 },
+  { "r1", 32, 32 },
+  { "r2", 64, 32 },
+  { "r3", 96, 32 },
+  { "r4", 128, 32 },
+  { "r5", 160, 32 },
+  { "r6", 192, 32 },
+  { "r7", 224, 32 },
+  { "r8", 256, 32 },
+  { "r9", 288, 32 },
+  { "r10", 320, 32 },
+  { "r11", 352, 32 },
+  { "r12", 384, 32 },
+  { "r13", 416, 32 },
+  { "r14", 448, 32 },
+  { "r15", 480, 32 },
+  { "r16", 512, 32 },
+  { "r17", 544, 32 },
+  { "r18", 576, 32 },
+  { "r19", 608, 32 },
+  { "r20", 640, 32 },
+  { "r21", 672, 32 },
+  { "r22", 704, 32 },
+  { "r23", 736, 32 },
+  { "r24", 768, 32 },
+  { "r25", 800, 32 },
+  { "r26", 832, 32 },
+  { "r27", 864, 32 },
+  { "r28", 896, 32 },
+  { "r29", 928, 32 },
+  { "r30", 960, 32 },
+  { "r31", 992, 32 },
+  { "f0", 1024, 64 },
+  { "f1", 1088, 64 },
+  { "f2", 1152, 64 },
+  { "f3", 1216, 64 },
+  { "f4", 1280, 64 },
+  { "f5", 1344, 64 },
+  { "f6", 1408, 64 },
+  { "f7", 1472, 64 },
+  { "f8", 1536, 64 },
+  { "f9", 1600, 64 },
+  { "f10", 1664, 64 },
+  { "f11", 1728, 64 },
+  { "f12", 1792, 64 },
+  { "f13", 1856, 64 },
+  { "f14", 1920, 64 },
+  { "f15", 1984, 64 },
+  { "f16", 2048, 64 },
+  { "f17", 2112, 64 },
+  { "f18", 2176, 64 },
+  { "f19", 2240, 64 },
+  { "f20", 2304, 64 },
+  { "f21", 2368, 64 },
+  { "f22", 2432, 64 },
+  { "f23", 2496, 64 },
+  { "f24", 2560, 64 },
+  { "f25", 2624, 64 },
+  { "f26", 2688, 64 },
+  { "f27", 2752, 64 },
+  { "f28", 2816, 64 },
+  { "f29", 2880, 64 },
+  { "f30", 2944, 64 },
+  { "f31", 3008, 64 },
+  { "pc", 3072, 32 },
+  { "ps", 3104, 32 },
+  { "cr", 3136, 32 },
+  { "lr", 3168, 32 },
+  { "ctr", 3200, 32 },
+  { "xer", 3232, 32 },
+  { "fpscr", 3264, 32 },
+};
+
+const char *expedite_regs_ppc[] = { "r1", "pc", 0 };
+
+void
+init_registers ()
+{
+    set_register_cache (regs_ppc,
+			sizeof (regs_ppc) / sizeof (regs_ppc[0]));
+    gdbserver_expedite_regs = expedite_regs_ppc;
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902231822.n1NIMoPN032186>