Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Cc: Pedro Alves <pedro@codesourcery.com>,
	toolchain-devel@blackfin.uclinux.org
Subject: Re: [PATCH v3] gdb: bfin: new port
Date: Wed, 15 Dec 2010 18:16:00 -0000	[thread overview]
Message-ID: <201012151315.26479.vapier@gentoo.org> (raw)
In-Reply-To: <201012151207.12141.vapier@gentoo.org>

[-- Attachment #1: Type: Text/Plain, Size: 4240 bytes --]

On Wednesday, December 15, 2010 12:07:11 Mike Frysinger wrote:
> On Wednesday, December 15, 2010 11:49:32 Pedro Alves wrote:
> > Thanks for the explanations.  This makes it so that the ASTAT.CC bit
> > can easily end up out of sync with the CC register in gdb's
> > regcache then, right?  E.g., "p $cc = 1; p $asat" will still show the
> > $asat.cc as 0, IIUC.  Does the kernel actually store CC on its
> > own slot in the register stack?  I ask because I see it commented out
> > in bfin_regmap in gdbserver.  If $cc was a pseudo-register _managed_ by
> > gdb (computed from ASAT), then this out-of-sync-ness would never happen.
> 
> no, linux does not give CC dedicated space in the signal context.  it does
> look like setting $cc on the command line results in out-of-sync values
> with $astat.  i'll take a look at the pseudo helpers you referenced and
> see if i cant figure out how they work.

what do you think of this ?  seems to work for me:
(gdb) set $cc = 0
(gdb) printf "%x %x\n", $astat, $cc
2002002 0
(gdb) set $cc = 1
(gdb) printf "%x %x\n", $astat, $cc
2002022 1
(gdb) set $astat = 0
(gdb) printf "%x %x\n", $astat, $cc
0 0
(gdb) set $astat = 0x20
(gdb) printf "%x %x\n", $astat, $cc
20 1
-mike

--- a/gdb/bfin-linux-tdep.c
+++ b/gdb/bfin-linux-tdep.c
@@ -88,7 +88,6 @@ static const int bfin_linux_sigcontext_reg_offset[BFIN_NUM_REGS] =
   -1,		/* %retn */
   -1,		/* %rete */
   21 * 4,	/* %pc */
-  -1,		/* %cc */
 };
 
 /* Signal trampolines.  */
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -116,16 +116,12 @@
 /* The maximum bytes we search to skip the prologue.  */
 #define UPPER_LIMIT			40
 
-#define RETS_OFFSET			4
+/* ASTAT bits  */
+#define ASTAT_CC_POS			5
+#define ASTAT_CC			(1 << ASTAT_CC_POS)
 
 /* Initial value: Register names used in BFIN's ISA documentation.  */
 
@@ -683,6 +683,36 @@ bfin_register_name (struct gdbarch *gdbarch, int i)
   return bfin_register_name_strings[i];
 }
 
+static void
+bfin_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+			   int regnum, gdb_byte *buffer)
+{
+  gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
+
+  if (regnum != BFIN_CC_REGNUM)
+    internal_error (__FILE__, __LINE__,
+		    _("invalid register number %d"), regnum);
+
+  regcache_raw_read (regcache, BFIN_ASTAT_REGNUM, buf);
+  buffer[1] = buffer[2] = buffer[3] = 0;
+  buffer[0] = !!(buf[0] & ASTAT_CC);
+}
+
+static void
+bfin_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
+			    int regnum, const gdb_byte *buffer)
+{
+  gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
+
+  if (regnum != BFIN_CC_REGNUM)
+    internal_error (__FILE__, __LINE__,
+		    _("invalid register number %d"), regnum);
+
+  regcache_raw_read (regcache, BFIN_ASTAT_REGNUM, buf);
+  buf[0] = (buf[0] & ~ASTAT_CC) | ((buffer[0] & 1) << ASTAT_CC_POS);
+  regcache_raw_write (regcache, BFIN_ASTAT_REGNUM, buf);
+}
+
 static CORE_ADDR
 bfin_frame_base_address (struct frame_info *this_frame, void **this_cache)
 {
@@ -783,7 +813,9 @@ bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->bfin_abi = abi;
 
   set_gdbarch_num_regs (gdbarch, BFIN_NUM_REGS);
-  set_gdbarch_num_pseudo_regs (gdbarch, 0);
+  set_gdbarch_pseudo_register_read (gdbarch, bfin_pseudo_register_read);
+  set_gdbarch_pseudo_register_write (gdbarch, bfin_pseudo_register_write);
+  set_gdbarch_num_pseudo_regs (gdbarch, BFIN_NUM_PSEUDO_REGS);
   set_gdbarch_sp_regnum (gdbarch, BFIN_SP_REGNUM);
   set_gdbarch_pc_regnum (gdbarch, BFIN_PC_REGNUM);
   set_gdbarch_ps_regnum (gdbarch, BFIN_ASTAT_REGNUM);
--- a/gdb/bfin-tdep.h
+++ b/gdb/bfin-tdep.h
@@ -74,13 +74,14 @@ enum gdb_regnum {
   BFIN_RETN_REGNUM,
   BFIN_RETE_REGNUM,
 
-  /* Pseudo Registers */
+  /* Pseudo Registers managed remotely.  */
   BFIN_PC_REGNUM,
-  BFIN_CC_REGNUM,
 
-  /* LAST ENTRY SHOULD NOT BE CHANGED.  */
-  BFIN_NUM_REGS			/* The number of all registers.  */
+  /* Pseudo Registers managed locally.  */
+  BFIN_CC_REGNUM
 };
+#define BFIN_NUM_REGS (BFIN_PC_REGNUM + 1)
+#define BFIN_NUM_PSEUDO_REGS (1)
 
 /* The ABIs for Blackfin.  */
 enum bfin_abi

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2010-12-15 18:16 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-09  9:29 [PATCH v2] " Mike Frysinger
2010-12-09  9:31 ` [PATCH v2] gdbserver: " Mike Frysinger
2010-12-13 18:44   ` Pedro Alves
2010-12-13 19:24     ` Mike Frysinger
2010-12-14  9:37     ` Andrew Stubbs
2010-12-14 15:10       ` Mike Frysinger
2010-12-14 16:31         ` Pedro Alves
2010-12-14 16:58           ` Mike Frysinger
2010-12-14 17:16             ` Andrew Stubbs
2010-12-14 17:26               ` Mike Frysinger
2010-12-15 11:54                 ` Andrew Stubbs
2010-12-15 12:55                   ` [toolchain-devel] " Mike Frysinger
2010-12-15 13:17                     ` Andrew Stubbs
2010-12-14 17:40             ` Pedro Alves
2010-12-14 17:48               ` Mike Frysinger
2010-12-14 18:06                 ` Pedro Alves
2010-12-14 18:21                   ` Mike Frysinger
2010-12-15 16:54                     ` Mike Frysinger
2010-12-14  6:03 ` [PATCH v2] gdb: " Joel Brobecker
2010-12-14 16:14   ` Mike Frysinger
2010-12-14 20:43 ` [PATCH v3] " Mike Frysinger
2010-12-14 21:31   ` Pedro Alves
2010-12-14 22:01     ` Mike Frysinger
2010-12-15 13:02       ` Mike Frysinger
2010-12-15 16:53         ` Pedro Alves
2010-12-15 17:08           ` Mike Frysinger
2010-12-15 18:01             ` Pedro Alves
2010-12-15 18:38               ` Mike Frysinger
2010-12-15 18:42                 ` Pedro Alves
2010-12-15 18:16             ` Mike Frysinger [this message]
2010-12-15 18:25               ` Pedro Alves
2010-12-14 21:48   ` [PATCH v3] gdbserver: " Mike Frysinger
2010-12-14 23:03     ` Ralf Corsepius
2010-12-15  0:15       ` Mike Frysinger

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=201012151315.26479.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    --cc=toolchain-devel@blackfin.uclinux.org \
    /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