Skip to content

Commit

Permalink
* sysdeps/unix/sysv/linux/alpha/register-dump.h (regnames): Align. (…
Browse files Browse the repository at this point in the history
…linefeed): Remove. (register_dump): Rewrite to generate into a flat buffer instead of into iovecs.

2004-11-04  Richard Henderson  <rth@redhat.com>

	* sysdeps/unix/sysv/linux/alpha/register-dump.h (regnames): Align.
	(linefeed): Remove.
	(register_dump): Rewrite to generate into a flat buffer instead
	of into iovecs.
  • Loading branch information
Richard Henderson committed Nov 4, 2004
1 parent c4d7bd3 commit a129c4f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2004-11-04 Richard Henderson <rth@redhat.com>

* sysdeps/unix/sysv/linux/alpha/register-dump.h (regnames): Align.
(linefeed): Remove.
(register_dump): Rewrite to generate into a flat buffer instead
of into iovecs.

2004-11-02 Jakub Jelinek <jakub@redhat.com>

* debug/tst-chk1.c (ret): New volatile variable.
Expand Down
46 changes: 21 additions & 25 deletions sysdeps/unix/sysv/linux/alpha/register-dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
02111-1307 USA. */

#include <stddef.h>
#include <sys/uio.h>
#include <string.h>

/* We will print the register dump in this format:
Expand Down Expand Up @@ -51,7 +51,7 @@

#define NREGS (32+32+3)

static const char regnames[NREGS][8] =
static const char __attribute__((aligned(8))) regnames[NREGS][8] =
{
" V0: ", " T0: ", " T1: ",
" T2: ", " T3: ", " T4: ",
Expand Down Expand Up @@ -113,49 +113,45 @@ static const int offsets[NREGS] =

#undef O

static const char linefeed[2] = "\n\n";

static void
register_dump (int fd, struct sigcontext *ctx)
{
char regs[NREGS][16];
struct iovec iov[2*NREGS+24];
size_t iov_i = 0, i, j;
char buf[NREGS*(8+16) + 25 + 80];
char *p = buf;
size_t i;

#define ADD_MEM(str, len) \
(iov[iov_i].iov_base = (void *)(str), \
iov[iov_i].iov_len = len, \
++iov_i)

#define ADD_STRING(str) ADD_MEM(str, strlen(str))

ADD_STRING ("Register dump:\n\n");
p = stpcpy (p, "Register dump:\n\n");

for (i = 0; i < NREGS; ++i)
{
int this_offset, this_lf;
unsigned long val;
signed long j;

this_offset = offsets[i];
this_lf = this_offset & 7;
this_offset &= -8;

val = *(unsigned long *)((char *)ctx + this_offset);
val = *(unsigned long *)(((size_t)ctx + this_offset) & -8);

for (j = 0; j < 16; ++j)
memcpy (p, regnames[i], 8);
p += 8;

for (j = 60; j >= 0; j -= 4)
{
unsigned long x = (val >> (64 - (j + 1) * 4)) & 15;
unsigned long x = (val >> j) & 15;
x += x < 10 ? '0' : 'a' - 10;
regs[i][j] = x;
*p++ = x;
}

ADD_MEM (regnames[i], 8);
ADD_MEM (regs[i], 16);
if (this_lf)
ADD_MEM (linefeed, this_lf);
if (this_lf > 0)
{
if (this_lf > 1)
*p++ = '\n';
*p++ = '\n';
}
}

writev (fd, iov, iov_i);
write (fd, buf, p - buf);
}

#define REGISTER_DUMP register_dump (fd, ctx)

0 comments on commit a129c4f

Please sign in to comment.