From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 549 invoked by alias); 4 Oct 2012 10:23:16 -0000 Received: (qmail 540 invoked by uid 22791); 4 Oct 2012 10:23:15 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RCVD_IN_HOSTKARMA_YE,TW_EG X-Spam-Check-By: sourceware.org Received: from va3ehsobe006.messaging.microsoft.com (HELO va3outboundpool.messaging.microsoft.com) (216.32.180.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Oct 2012 10:23:09 +0000 Received: from mail268-va3-R.bigfish.com (10.7.14.238) by VA3EHSOBE010.bigfish.com (10.7.40.12) with Microsoft SMTP Server id 14.1.225.23; Thu, 4 Oct 2012 10:23:08 +0000 Received: from mail268-va3 (localhost [127.0.0.1]) by mail268-va3-R.bigfish.com (Postfix) with ESMTP id 3D0C0158018E for ; Thu, 4 Oct 2012 10:23:08 +0000 (UTC) X-Forefront-Antispam-Report: CIP:59.163.77.177;KIP:(null);UIP:(null);IPV:NLI;H:KCHJEXHC02.kpit.com;RD:59.163.77.177.static.vsnl.net.in;EFVD:NLI X-SpamScore: -3 X-BigFish: VPS-3(zz936eI154dMc8kzz1202h1d1ah1d2ahzz17326ah8275bh8275dhz2dh2a8h668h839h944hd25hf0ah107ah1220h1288h12a5h12a9h12bdh137ah13b6h1441h1155h) Received: from mail268-va3 (localhost.localdomain [127.0.0.1]) by mail268-va3 (MessageSwitch) id 1349346186326891_22325; Thu, 4 Oct 2012 10:23:06 +0000 (UTC) Received: from VA3EHSMHS023.bigfish.com (unknown [10.7.14.247]) by mail268-va3.bigfish.com (Postfix) with ESMTP id 4E67F1D40049 for ; Thu, 4 Oct 2012 10:23:06 +0000 (UTC) Received: from KCHJEXHC02.kpit.com (59.163.77.177) by VA3EHSMHS023.bigfish.com (10.7.99.33) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 4 Oct 2012 10:23:04 +0000 Received: from KCHJEXMB03.kpit.com ([169.254.4.166]) by KCHJEXHC02.kpit.com ([172.10.15.74]) with mapi id 14.01.0289.001; Thu, 4 Oct 2012 15:53:01 +0530 From: Kaushik Phatak To: "gdb-patches@sourceware.org" Subject: [RFA 4/5] New port: CR16: gdbserver Date: Thu, 04 Oct 2012 10:23:00 -0000 Message-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: kpitcummins.com 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 X-SW-Source: 2012-10/txt/msg00064.txt.bz2 Hi, This patch adds gdbserver support for the National Semiconductor cr16 targe= t. This currently still has a limitation related to -fPIC usage and global var= iables. However, I am hoping that major portions of this patch which have been test= ed=20 and are working well get accepted here. Regards, Kaushik 2012-10-04 Kaushik Phatak gdb/Changelog * regformats/reg-cr16.dat: New. gdb/gdbserver/Changelog * Makefile.in (clean): Remove reg-cr16.c. (linux-cr16-low.o, reg-cr16.o): New rules. * configure.srv: Add support for cr16-*-uclinux. * linux-cr16-low.c: New. * linux-low.c (PT_TEXT_ADDR, PT_DATA_ADDR, PT_TEXT_END_ADDR): Defin= e. diff -uprN gdb-7.5/gdb/gdbserver/configure.srv ./gdb-7.5_working/gdb/gdbser= ver/configure.srv --- gdb-7.5/gdb/gdbserver/configure.srv 2012-05-31 01:13:15.000000000 +0530 +++ ./gdb-7.5_working/gdb/gdbserver/configure.srv 2012-10-04 14:18:33.00000= 0000 +0530 @@ -74,6 +74,11 @@ case "${target}" in srv_linux_usrregs=3Dyes srv_linux_thread_db=3Dyes ;; + cr16-*-uclinux*) srv_regobj=3Dreg-cr16.o + srv_tgtobj=3D"linux-low.o linux-cr16-low.o" + srv_linux_usrregs=3Dyes + srv_linux_thread_db=3Dyes + ;; crisv32-*-linux*) srv_regobj=3Dreg-crisv32.o srv_tgtobj=3D"linux-low.o linux-osdata.o linux-crisv32-low.o linux-proc= fs.o" srv_tgtobj=3D"${srv_tgtobj} linux-ptrace.o" diff -uprN gdb-7.5/gdb/gdbserver/linux-cr16-low.c ./gdb-7.5_working/gdb/gdb= server/linux-cr16-low.c --- gdb-7.5/gdb/gdbserver/linux-cr16-low.c 1970-01-01 05:30:00.000000000 +0= 530 +++ ./gdb-7.5_working/gdb/gdbserver/linux-cr16-low.c 2012-10-01 15:28:08.00= 0000000 +0530 @@ -0,0 +1,159 @@ +/* GNU/Linux/CR16 specific low level interface, for the remote server for = GDB. + + Copyright (C) 2010-2012 Free Software Foundation, Inc. + Contributed by Kaushik Phatak (kaushik.pahatk@kpitcummins.com) + KPIT Cummins Infosystems Limited, Pune India.=20=20=20 + 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 "server.h" +#include "linux-low.h" +#include + +/* Defined in auto-generated file reg-cr16.c. */ +void init_registers_cr16 (void); + +/* CR16C */ +/* Locations need to match . */ +#define cr16_num_regs 16 +#define PC_REGNUM 11 + +static int cr16_regmap[] =3D { + 0, 4, 8, 12, + 16, 20, 24, 28, + 32, 36, 40, 44, + 48, 52, 56, 60 +}; + +extern int debug_threads; +static int +cr16_cannot_store_register (int regno) +{ + if (cr16_regmap[regno] =3D=3D -1) + return 1; + + return (regno >=3D cr16_num_regs); +} + +static int +cr16_cannot_fetch_register (int regno) +{ + if (cr16_regmap[regno] =3D=3D -1) + return 1; + + return (regno >=3D cr16_num_regs); +} + +static void +cr16_set_pc (struct regcache *regcache, CORE_ADDR pc) +{ + unsigned long newpc =3D pc; + supply_register_by_name (regcache, "pc", &newpc); +} + +static CORE_ADDR +cr16_get_pc (struct regcache *regcache) +{ + unsigned long pc; + collect_register_by_name (regcache, "pc", &pc); + return pc; +} +=20 +static void +cr16_collect_ptrace_register (struct regcache *regcache, int regno, char *= buf) +{ + unsigned long pc; + + memset (buf, 0, sizeof (long)); + collect_register_by_name (regcache, "pc", &pc); + if(regno =3D=3D PC_REGNUM) + { + pc =3D pc >> 1;=20 + cr16_set_pc(regcache, pc); + } + collect_register (regcache, regno, buf); +} + +static void +cr16_supply_ptrace_register (struct regcache *regcache, + int regno, const char *buf) +{ + unsigned long pc; + supply_register (regcache, regno, buf ); + collect_register_by_name (regcache, "pc", &pc); + + /* For PC, leftshift the output as only top 21 bits are stored + This will make the value human readable for the host */ + if(regno =3D=3D PC_REGNUM)=20 + { + pc =3D pc << 1;=20 + cr16_set_pc(regcache, pc); + } + +} + +static const unsigned short cr16_breakpoint =3D 0xc700; +#define cr16_breakpoint_len 2 + +static int +cr16_breakpoint_at (CORE_ADDR where) +{ + unsigned short insn; + + (*the_target->read_memory) (where, (unsigned char *) &insn, + cr16_breakpoint_len); + if (insn =3D=3D cr16_breakpoint) + { + return 1; + } + /* If necessary, recognize more trap instructions here. GDB only uses t= he + one. */ + return 0; +} + +/* We only place breakpoints in empty marker functions, and thread locking + is outside of the function. So rather than importing software single-s= tep, + we can just run until exit. */ +static CORE_ADDR +cr16_reinsert_addr (void) +{ + struct regcache *regcache =3D get_thread_regcache (current_inferior, 1); + unsigned long pc; + /* R14/Ra is return address register */ + collect_register_by_name (regcache, "ra", &pc); + return pc; +} +struct linux_target_ops the_low_target =3D { + init_registers_cr16, + cr16_num_regs, + cr16_regmap, + NULL, + cr16_cannot_fetch_register, + cr16_cannot_store_register, + NULL, + cr16_get_pc, + cr16_set_pc, + (const unsigned char *) &cr16_breakpoint, + cr16_breakpoint_len, + cr16_reinsert_addr, + 0, + cr16_breakpoint_at, + 0, + 0, + 0, + 0, + cr16_collect_ptrace_register, + cr16_supply_ptrace_register, +}; diff -uprN gdb-7.5/gdb/gdbserver/linux-low.c ./gdb-7.5_working/gdb/gdbserve= r/linux-low.c --- gdb-7.5/gdb/gdbserver/linux-low.c 2012-07-07 17:43:57.000000000 +0530 +++ ./gdb-7.5_working/gdb/gdbserver/linux-low.c 2012-10-01 16:21:48.0000000= 00 +0530 @@ -4809,7 +4810,7 @@ linux_stopped_data_address (void) #if ! (defined(PT_TEXT_ADDR) \ || defined(PT_DATA_ADDR) \ || defined(PT_TEXT_END_ADDR)) -#if defined(__mcoldfire__) +#if defined(__mcoldfire__) || (__CR16__) /* These should really be defined in the kernel's ptrace.h header. */ #define PT_TEXT_ADDR 49*4 #define PT_DATA_ADDR 50*4 diff -uprN gdb-7.5/gdb/gdbserver/Makefile.in ./gdb-7.5_working/gdb/gdbserve= r/Makefile.in --- gdb-7.5/gdb/gdbserver/Makefile.in 2012-07-02 20:59:38.000000000 +0530 +++ ./gdb-7.5_working/gdb/gdbserver/Makefile.in 2012-09-13 14:42:51.0000000= 00 +0530 @@ -126,6 +126,7 @@ SFILES=3D $(srcdir)/gdbreplay.c $(srcdir)/ $(srcdir)/remote-utils.c $(srcdir)/server.c $(srcdir)/target.c \ $(srcdir)/thread-db.c $(srcdir)/utils.c \ $(srcdir)/linux-arm-low.c $(srcdir)/linux-bfin-low.c \ + $(srcdir)/linux-cr16-low.c \ $(srcdir)/linux-cris-low.c $(srcdir)/linux-crisv32-low.c \ ${srcdir}/i386-low.c $(srcdir)/i387-fp.c \ $(srcdir)/linux-ia64-low.c $(srcdir)/linux-low.c \ @@ -307,7 +308,7 @@ clean: rm -f $(IPA_LIB) rm -f reg-arm.c reg-bfin.c i386.c reg-ia64.c reg-m32r.c reg-m68k.c rm -f reg-sh.c reg-sparc.c reg-spu.c amd64.c i386-linux.c - rm -f reg-cris.c reg-crisv32.c amd64-linux.c reg-xtensa.c + rm -f reg-cris.c reg-cr16.c reg-crisv32.c amd64-linux.c reg-xtensa.c rm -f arm-with-iwmmxt.c rm -f arm-with-vfpv2.c arm-with-vfpv3.c arm-with-neon.c rm -f mips-linux.c mips64-linux.c @@ -546,6 +547,7 @@ linux-low.o: linux-low.c $(linux_low_h)=20 linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h) \ $(gdb_proc_service_h) linux-bfin-low.o: linux-bfin-low.c $(linux_low_h) $(server_h) +linux-cr16-low.o: linux-cr16-low.c $(linux_low_h) $(server_h) linux-cris-low.o: linux-cris-low.c $(linux_low_h) $(server_h) linux-crisv32-low.o: linux-crisv32-low.c $(linux_low_h) $(server_h) linux-ia64-low.o: linux-ia64-low.c $(linux_low_h) $(server_h) @@ -593,6 +595,9 @@ arm-with-neon.c : $(srcdir)/../regformat reg-bfin.o : reg-bfin.c $(regdef_h) reg-bfin.c : $(srcdir)/../regformats/reg-bfin.dat $(regdat_sh) $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-bfin.dat reg-bfin.c +reg-cr16.o : reg-cr16.c $(regdef_h) +reg-cr16.c : $(srcdir)/../regformats/reg-cr16.dat $(regdat_sh) + $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-cr16.dat reg-cr16.c reg-cris.o : reg-cris.c $(regdef_h) reg-cris.c : $(srcdir)/../regformats/reg-cris.dat $(regdat_sh) $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-cris.dat reg-cris.c diff -uprN gdb-7.5/gdb/regformats/reg-cr16.dat ./gdb-7.5_working/gdb/regfor= mats/reg-cr16.dat --- gdb-7.5/gdb/regformats/reg-cr16.dat 1970-01-01 05:30:00.000000000 +0530 +++ ./gdb-7.5_working/gdb/regformats/reg-cr16.dat 2012-09-13 14:45:02.00000= 0000 +0530 @@ -0,0 +1,18 @@ +name:cr16 +expedite:psr +32:r0and1 +32:r2and3 +32:r4and5 +32:r6and7 +32:r8and9 +32:r10and11 +32:r12 +32:r13 +32:ra +16:psr +16:pad +32:pc +32:orig_r0and1 +32:intbase +32:usp +32:cfg