From: Ajit Kumar Agarwal <ajit.kumar.agarwal@xilinx.com>
To: Pedro Alves <palves@redhat.com>,
Michael Eager <eager@eagercon.com>,
Joel Brobecker <brobecker@adacore.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Vinod Kathail <vinodk@xilinx.com>,
Vidhumouli Hunsigida <vidhum@xilinx.com>,
"Nagaraju Mekala" <nmekala@xilinx.com>
Subject: RE: [Patch] Microblaze: Port of Linux gdbserver
Date: Fri, 17 Oct 2014 19:22:00 -0000 [thread overview]
Message-ID: <99de529c620a4bb0a118a9fc39ae6ad0@BY2FFO11FD008.protection.gbl> (raw)
In-Reply-To: <543E7630.5060001@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2755 bytes --]
-----Original Message-----
From: Pedro Alves [mailto:palves@redhat.com]
Sent: Wednesday, October 15, 2014 6:57 PM
To: Ajit Kumar Agarwal; Michael Eager; Joel Brobecker
Cc: gdb-patches@sourceware.org; Vinod Kathail; Vidhumouli Hunsigida; Nagaraju Mekala
Subject: Re: [Patch] Microblaze: Port of Linux gdbserver
On 10/09/2014 07:54 PM, Ajit Kumar Agarwal wrote:
>
> Pedro:
>> > Did this kernel port make it upstream without PTRACE_GETREGSET?
>> > If there's support for that, can you please switch to using it?
>>> >>Please answer all questions.
> Sure. The Kernel code(ptrace.h) for Microblaze doesn't have upstream code without PTRACE_GETREGSET.
>
> Pedro:
>> > PTRACE_GETREGS is supposed to an old way of doing things...
>>> >>And address all comments.
> The Microblaze Kernel code PTRACE_GETREGS is always defined and there is no conditional compilation which is without the PTRACE_GETREGS. So I agree with Pedro comment of not using #ifdef PTRACE_GETREGS and in the patch submitted I have removed if #ifdef PTRACE_GETREGS which is not required.
>>PTRACE_GETREGSET != PTRACE_GETREGS
>>I'm asking for using the PTRACE_GETREGSET instead of PTRACE_GETREGS in new ports. See background here:
>>https://sourceware.org/ml/archer/2010-q3/msg00193.html
The changes are incorporated.
>> +#define microblaze_breakpoint_len 4
>>
>> Use CAPS for macros.
The changes are incorporated.
>>+ (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
>>+
>>+ if (insn == microblaze_breakpoint)
>>Why use the explicit length rather than the macro you just defined?
>>Why not use sizeof (insn)?
The changes are incorporated.
The below patch incorporated all the above feedbacks.
[PATCH] Microblaze: Port of Linux gdbserver
This patch is the port of Linux gdbserver.
Tested with gdb regression testsuite with this patch of
gdbserver.
gdb/:
2014-10-18 Ajit Agarwal <ajitkum@xilinx.com>
* configure.tgt (build_gdbserver): New Definition.
gdb/gdbserver/:
* gdbserver/Makefile.in (microblaze-linux.c): New target.
* gdbserver/configure.srv (microblaze*-*-linux*): New target.
* gdbserver/linux-microblaze-low.c: New file.
Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
Gdb.base gdb testsuite is run and here is the status of gdb testsuite run for gdb.base.
=== gdb Summary ===
# of expected passes 7804
# of unexpected failures 2263
# of unexpected successes 2
# of expected failures 5
# of known failures 22
# of unresolved testcases 29
# of untested testcases 41
# of unsupported tests 125
Thanks & Regards
Ajit
Thanks,
Pedro Alves
[-- Attachment #2: 0001-Microblaze-Port-of-Linux-gdbserver.patch --]
[-- Type: application/octet-stream, Size: 10275 bytes --]
From 188b4f2a25240e4b4d21bf61217c7ee03b051030 Mon Sep 17 00:00:00 2001
From: Ajit Kumar Agarwal <ajitkum@xhdspdgnu.(none)>
Date: Sat, 18 Oct 2014 00:34:39 +0530
Subject: [PATCH] Microblaze: Port of Linux gdbserver
This patch is the port of Linux gdbserver.
Tested with gdb regression testsuite with this patch of
gdbserver.
gdb/:
2014-10-18 Ajit Agarwal <ajitkum@xilinx.com>
* configure.tgt (build_gdbserver): New Definition.
gdb/gdbserver/:
* gdbserver/Makefile.in (microblaze-linux.c): New target.
* gdbserver/configure.srv (microblaze*-*-linux*): New target.
* gdbserver/linux-microblaze-low.c: New file.
Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
---
gdb/configure.tgt | 1 +
gdb/gdbserver/Makefile.in | 4 +
gdb/gdbserver/configure.srv | 6 +
gdb/gdbserver/linux-microblaze-low.c | 237 ++++++++++++++++++++++++++++++++++
4 files changed, 248 insertions(+), 0 deletions(-)
create mode 100644 gdb/gdbserver/linux-microblaze-low.c
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index d362cd9..fc2ad5c 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -344,6 +344,7 @@ microblaze*-linux-*|microblaze*-*-linux*)
gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o microblaze-rom.o \
monitor.o dsrec.o solib-svr4.o symfile-mem.o linux-tdep.o"
gdb_sim=../sim/microblaze/libsim.a
+ build_gdbserver=yes
;;
microblaze*-*-*)
# Target: Xilinx MicroBlaze running standalone
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 8b0318a..84873c1 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -154,6 +154,7 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
$(srcdir)/linux-ia64-low.c $(srcdir)/linux-low.c \
$(srcdir)/linux-m32r-low.c \
$(srcdir)/linux-m68k-low.c $(srcdir)/linux-mips-low.c \
+ $(srcdir)/linux-microblaze-low.c \
$(srcdir)/linux-nios2-low.c \
$(srcdir)/linux-ppc-low.c \
$(srcdir)/linux-s390-low.c \
@@ -366,6 +367,7 @@ clean:
rm -f amd64-mpx.c amd64-mpx-linux.c
rm -f amd64-avx512.c amd64-avx512-linux.c
rm -f i386-mmx.c i386-mmx-linux.c
+ rm -f microblaze-linux.c
rm -f x32.c x32-linux.c
rm -f x32-avx.c x32-avx-linux.c
rm -f x32-avx512.c x32-avx512-linux.c
@@ -636,6 +638,8 @@ mips64-linux.c : $(srcdir)/../regformats/mips64-linux.dat $(regdat_sh)
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/mips64-linux.dat mips64-linux.c
mips64-dsp-linux.c : $(srcdir)/../regformats/mips64-dsp-linux.dat $(regdat_sh)
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/mips64-dsp-linux.dat mips64-dsp-linux.c
+microblaze-linux.c : $(srcdir)/../regformats/microblaze-with-stack-protect.dat $(regdat_sh)
+ $(SHELL) $(regdat_sh) $(srcdir)/../regformats/microblaze-with-stack-protect.dat microblaze-linux.c
nios2-linux.c : $(srcdir)/../regformats/nios2-linux.dat $(regdat_sh)
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/nios2-linux.dat nios2-linux.c
powerpc-32.c : $(srcdir)/../regformats/rs6000/powerpc-32.dat $(regdat_sh)
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index 679fc9f..a7b87aa 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -202,6 +202,12 @@ case "${target}" in
srv_linux_usrregs=yes
srv_linux_thread_db=yes
;;
+ microblaze*-*-linux*) srv_regobj=microblaze-linux.o
+ srv_tgtobj="$srv_linux_obj linux-microblaze-low.o"
+ srv_linux_usrregs=yes
+ srv_linux_regsets=yes
+ srv_linux_thread_db=yes
+ ;;
powerpc*-*-linux*) srv_regobj="powerpc-32l.o"
srv_regobj="${srv_regobj} powerpc-altivec32l.o"
srv_regobj="${srv_regobj} powerpc-cell32l.o"
diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
new file mode 100644
index 0000000..9488b25
--- /dev/null
+++ b/gdb/gdbserver/linux-microblaze-low.c
@@ -0,0 +1,237 @@
+/* GNU/Linux/Microblaze specific low level interface, for the remote server for
+ GDB.
+ Copyright (C) 2014 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 "server.h"
+#include "linux-low.h"
+#include "gdb_proc_service.h"
+
+#include <asm/ptrace.h>
+#include <sys/ptrace.h>
+#include <sys/procfs.h>
+#include <linux/elf.h>
+
+void init_registers_microblaze_with_stack_protect (void);
+extern const struct target_desc *tdesc_microblaze_with_stack_protect;
+
+static int microblaze_regmap[] = {
+ PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3),
+ PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7),
+ PT_GPR(8), PT_GPR(9), PT_GPR(10), PT_GPR(11),
+ PT_GPR(12), PT_GPR(13), PT_GPR(14), PT_GPR(15),
+ PT_GPR(16), PT_GPR(17), PT_GPR(18), PT_GPR(19),
+ PT_GPR(20), PT_GPR(21), PT_GPR(22), PT_GPR(23),
+ PT_GPR(24), PT_GPR(25), PT_GPR(26), PT_GPR(27),
+ PT_GPR(28), PT_GPR(29), PT_GPR(30), PT_GPR(31),
+ PT_PC, PT_MSR, PT_EAR, PT_ESR,
+ PT_FSR, PT_BTR, PT_PVR0, PT_PVR1,
+ PT_PVR2, PT_PVR3, PT_PVR4, PT_PVR5,
+ PT_PVR6, PT_PVR7, PT_PVR8, PT_PVR9,
+ PT_PVR10, PT_PVR11, PT_EDR, PT_PID,
+ PT_ZPR, PT_TLBX, PT_TLBSX, PT_TLBLO,
+ PT_TLBHI, PT_SLR, PT_SHR
+};
+
+#define microblaze_num_regs ARRAY_SIZE (microblaze_regmap)
+#define MICROBLAZE_BREAKPOINT_LEN 4
+
+static int
+microblaze_cannot_store_register (int regno)
+{
+ if (microblaze_regmap[regno] == -1 || regno == 0)
+ return 1;
+
+ return 0;
+}
+
+static int
+microblaze_cannot_fetch_register (int regno)
+{
+ return 0;
+}
+
+static CORE_ADDR
+microblaze_get_pc (struct regcache *regcache)
+{
+ unsigned long pc;
+
+ collect_register_by_name (regcache, "rpc", &pc);
+ return (CORE_ADDR) (pc);
+}
+
+static void
+microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+ unsigned long newpc = pc;
+
+ supply_register_by_name (regcache, "rpc", &newpc);
+}
+
+static const unsigned long microblaze_breakpoint = 0xba0c0018;
+
+static int
+microblaze_breakpoint_at (CORE_ADDR where)
+{
+ unsigned long insn;
+
+ (*the_target->read_memory) (where, (unsigned char *) &insn,
+ MICROBLAZE_BREAKPOINT_LEN);
+
+ if (insn == microblaze_breakpoint)
+ return 1;
+
+ return 0;
+}
+
+static CORE_ADDR
+microblaze_reinsert_addr (struct regcache *regcache)
+{
+ unsigned long pc;
+
+ collect_register_by_name (regcache, "r15", &pc);
+ return pc;
+}
+
+static void
+microblaze_collect_ptrace_register (struct regcache *regcache,
+ int regno, char *buf)
+{
+ int size = register_size (regcache->tdesc, regno);
+
+ memset (buf, 0, sizeof (long));
+
+ if (size < sizeof (long))
+ collect_register (regcache, regno, buf + sizeof (long) - size);
+ else
+ collect_register (regcache, regno, buf);
+}
+
+static void
+microblaze_supply_ptrace_register (struct regcache *regcache,
+ int regno, const char *buf)
+{
+ int i;
+ int size = register_size (regcache->tdesc, regno);
+
+ if (regno == 0)
+ {
+ unsigned long regbuf_0 = 0;
+ /* Clobbering r0 so that it is always 0 as enforced by hardware. */
+ supply_register (regcache, regno, (const char*)®buf_0);
+ }
+ else
+ {
+ if (size < sizeof (long))
+ supply_register (regcache, regno, buf + sizeof (long) - size);
+ else
+ supply_register (regcache, regno, buf);
+ }
+}
+
+/* Provide only a fill function for the general register set. ps_lgetregs
+ will use this for NPTL support. */
+
+static void
+microblaze_fill_gregset (struct regcache *regcache, void *buf)
+{
+ int i;
+
+ for (i = 0; i < microblaze_num_regs; i++)
+ microblaze_collect_ptrace_register (regcache, i,
+ (char *) buf + microblaze_regmap[i]);
+}
+
+static void
+microblaze_store_gregset (struct regcache *regcache, const void *buf)
+{
+ int i;
+
+ for (i = 0; i < microblaze_num_regs; i++)
+ supply_register (regcache, i, (char *) buf + microblaze_regmap[i]);
+}
+
+static struct regset_info microblaze_regsets[] = {
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
+ sizeof (elf_gregset_t), GENERAL_REGS,
+ microblaze_fill_gregset, microblaze_store_gregset },
+ { 0, 0, 0, -1, -1, NULL, NULL },
+ { 0, 0, 0, -1, -1, NULL, NULL }
+};
+
+static struct regsets_info microblaze_regsets_info = {
+ microblaze_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+};
+
+static struct usrregs_info microblaze_usrregs_info = {
+ microblaze_num_regs,
+ microblaze_regmap,
+};
+
+static struct regs_info regs_info = {
+ NULL, /* regset_bitmap */
+ µblaze_usrregs_info,
+ µblaze_regsets_info
+};
+
+static const struct regs_info *
+microblaze_regs_info (void)
+{
+ return ®s_info;
+}
+
+static void
+microblaze_arch_setup (void)
+{
+ current_process ()->tdesc = tdesc_microblaze_with_stack_protect;
+}
+
+struct linux_target_ops the_low_target = {
+ microblaze_arch_setup,
+ microblaze_regs_info,
+ microblaze_cannot_fetch_register,
+ microblaze_cannot_store_register,
+ NULL, /* fetch_register */
+ microblaze_get_pc,
+ microblaze_set_pc,
+ (const unsigned char *) µblaze_breakpoint,
+ MICROBLAZE_BREAKPOINT_LEN,
+ microblaze_reinsert_addr,
+ 0,
+ microblaze_breakpoint_at,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ microblaze_collect_ptrace_register,
+ microblaze_supply_ptrace_register,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+};
+
+void
+initialize_low_arch (void)
+{
+ init_registers_microblaze_with_stack_protect ();
+
+ initialize_regsets_info (µblaze_regsets_info);
+}
--
1.7.1
next prev parent reply other threads:[~2014-10-17 19:22 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-08 13:52 Ajit Kumar Agarwal
2014-10-09 16:29 ` Michael Eager
2014-10-09 18:54 ` Ajit Kumar Agarwal
2014-10-09 23:42 ` Michael Eager
2014-10-13 16:00 ` Ajit Kumar Agarwal
2014-10-13 17:49 ` Michael Eager
2014-10-14 3:03 ` Ajit Kumar Agarwal
2014-10-14 15:07 ` Michael Eager
2014-10-14 15:33 ` Ajit Kumar Agarwal
2014-10-14 15:42 ` Ajit Kumar Agarwal
2014-10-15 13:27 ` Pedro Alves
2014-10-17 19:22 ` Ajit Kumar Agarwal [this message]
2014-12-15 18:02 ` Pedro Alves
2014-12-15 18:13 ` Michael Eager
2014-12-18 8:58 ` Ajit Kumar Agarwal
2014-12-18 16:10 ` Michael Eager
2014-12-18 8:57 ` Ajit Kumar Agarwal
2014-12-18 11:28 ` Pedro Alves
2014-12-18 16:53 ` Ajit Kumar Agarwal
2014-12-18 17:40 ` Pedro Alves
2014-12-19 8:27 ` Ajit Kumar Agarwal
2014-12-19 10:56 ` Pedro Alves
2014-12-19 10:26 ` Ajit Kumar Agarwal
2014-12-19 11:02 ` Pedro Alves
2014-12-19 18:06 ` Ajit Kumar Agarwal
2014-11-26 12:13 ` Ajit Kumar Agarwal
2014-12-15 16:08 ` Ajit Kumar Agarwal
-- strict thread matches above, loose matches on Subject: below --
2014-10-08 14:59 Ajit Kumar Agarwal
2014-09-10 10:14 [Patch, microblaze]: " Ajit Kumar Agarwal
2014-09-10 13:31 ` Michael Eager
2014-09-10 13:46 ` Joel Brobecker
2014-09-10 14:23 ` Ajit Kumar Agarwal
2014-09-10 14:39 ` Michael Eager
2014-09-10 14:59 ` Ajit Kumar Agarwal
2014-09-10 15:12 ` Ajit Kumar Agarwal
2014-09-10 15:27 ` Michael Eager
2014-09-10 15:30 ` Ajit Kumar Agarwal
2014-09-10 15:35 ` Michael Eager
2014-09-10 15:51 ` Ajit Kumar Agarwal
2014-09-10 14:43 ` Joel Brobecker
2014-09-10 15:04 ` Ajit Kumar Agarwal
2014-09-10 15:54 ` Joel Brobecker
2014-09-10 16:10 ` Ajit Kumar Agarwal
2014-09-12 8:01 ` Ajit Kumar Agarwal
2014-09-12 8:39 ` Ajit Kumar Agarwal
2014-09-12 15:38 ` Michael Eager
2014-09-16 6:42 ` Ajit Kumar Agarwal
2014-09-16 12:06 ` Michael Eager
2014-09-17 9:36 ` Ajit Kumar Agarwal
2014-09-17 14:12 ` Michael Eager
2014-09-16 17:04 ` Pedro Alves
2014-09-17 6:16 ` Ajit Kumar Agarwal
2014-09-17 8:15 ` Pedro Alves
2014-09-17 8:20 ` Ajit Kumar Agarwal
2014-09-23 12:49 ` Ajit Kumar Agarwal
2014-09-30 11:43 ` Pedro Alves
2014-09-30 13:27 ` Ajit Kumar Agarwal
2014-09-30 13:37 ` Pedro Alves
2014-09-30 14:21 ` Ajit Kumar Agarwal
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=99de529c620a4bb0a118a9fc39ae6ad0@BY2FFO11FD008.protection.gbl \
--to=ajit.kumar.agarwal@xilinx.com \
--cc=brobecker@adacore.com \
--cc=eager@eagercon.com \
--cc=gdb-patches@sourceware.org \
--cc=nmekala@xilinx.com \
--cc=palves@redhat.com \
--cc=vidhum@xilinx.com \
--cc=vinodk@xilinx.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).