mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
Compare commits
3 Commits
users/ARM/
...
users/palv
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04956cf9b8 | ||
|
|
ca47aa93d4 | ||
|
|
dd4a4f8624 |
@@ -35,6 +35,7 @@ extern "C" {
|
|||||||
#include "ansidecl.h"
|
#include "ansidecl.h"
|
||||||
#include "symcat.h"
|
#include "symcat.h"
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include "bfd-types.h"
|
||||||
|
|
||||||
#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
|
#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
|
||||||
#ifndef SABER
|
#ifndef SABER
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ extern "C" {
|
|||||||
#include "ansidecl.h"
|
#include "ansidecl.h"
|
||||||
#include "symcat.h"
|
#include "symcat.h"
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include "bfd-types.h"
|
||||||
|
|
||||||
#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
|
#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
|
||||||
#ifndef SABER
|
#ifndef SABER
|
||||||
@@ -7124,8 +7125,6 @@ enum bfd_flavour
|
|||||||
bfd_target_sym_flavour
|
bfd_target_sym_flavour
|
||||||
};
|
};
|
||||||
|
|
||||||
enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
|
|
||||||
|
|
||||||
/* Forward declaration. */
|
/* Forward declaration. */
|
||||||
typedef struct bfd_link_info _bfd_link_info;
|
typedef struct bfd_link_info _bfd_link_info;
|
||||||
|
|
||||||
|
|||||||
@@ -171,8 +171,6 @@ DESCRIPTION
|
|||||||
. bfd_target_sym_flavour
|
. bfd_target_sym_flavour
|
||||||
.};
|
.};
|
||||||
.
|
.
|
||||||
.enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
|
|
||||||
.
|
|
||||||
.{* Forward declaration. *}
|
.{* Forward declaration. *}
|
||||||
.typedef struct bfd_link_info _bfd_link_info;
|
.typedef struct bfd_link_info _bfd_link_info;
|
||||||
.
|
.
|
||||||
|
|||||||
@@ -896,6 +896,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
|
|||||||
target/waitstatus.c common/print-utils.c common/rsp-low.c \
|
target/waitstatus.c common/print-utils.c common/rsp-low.c \
|
||||||
common/errors.c common/common-debug.c common/common-exceptions.c \
|
common/errors.c common/common-debug.c common/common-exceptions.c \
|
||||||
common/btrace-common.c common/fileio.c common/common-regcache.c \
|
common/btrace-common.c common/fileio.c common/common-regcache.c \
|
||||||
|
common/gdb-byteswap.c \
|
||||||
$(SUBDIR_GCC_COMPILE_SRCS)
|
$(SUBDIR_GCC_COMPILE_SRCS)
|
||||||
|
|
||||||
LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
|
LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
|
||||||
@@ -988,7 +989,9 @@ common/common-exceptions.h target/target.h common/symbol.h \
|
|||||||
common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \
|
common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \
|
||||||
common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h nat/amd64-linux-siginfo.h\
|
common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h nat/amd64-linux-siginfo.h\
|
||||||
nat/linux-namespaces.h arch/arm.h common/gdb_sys_time.h arch/aarch64-insn.h \
|
nat/linux-namespaces.h arch/arm.h common/gdb_sys_time.h arch/aarch64-insn.h \
|
||||||
tid-parse.h
|
tid-parse.h \
|
||||||
|
common/gdb-byteswap.h
|
||||||
|
|
||||||
|
|
||||||
# Header files that already have srcdir in them, or which are in objdir.
|
# Header files that already have srcdir in them, or which are in objdir.
|
||||||
|
|
||||||
@@ -1087,7 +1090,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
|
|||||||
format.o registry.o btrace.o record-btrace.o waitstatus.o \
|
format.o registry.o btrace.o record-btrace.o waitstatus.o \
|
||||||
print-utils.o rsp-low.o errors.o common-debug.o debug.o \
|
print-utils.o rsp-low.o errors.o common-debug.o debug.o \
|
||||||
common-exceptions.o btrace-common.o fileio.o \
|
common-exceptions.o btrace-common.o fileio.o \
|
||||||
common-regcache.o \
|
common-regcache.o gdb-byteswap.o \
|
||||||
$(SUBDIR_GCC_COMPILE_OBS)
|
$(SUBDIR_GCC_COMPILE_OBS)
|
||||||
|
|
||||||
TSOBS = inflow.o
|
TSOBS = inflow.o
|
||||||
@@ -2275,6 +2278,10 @@ common-regcache.o: ${srcdir}/common/common-regcache.c
|
|||||||
$(COMPILE) $(srcdir)/common/common-regcache.c
|
$(COMPILE) $(srcdir)/common/common-regcache.c
|
||||||
$(POSTCOMPILE)
|
$(POSTCOMPILE)
|
||||||
|
|
||||||
|
gdb-byteswap.o: ${srcdir}/common/gdb-byteswap.c
|
||||||
|
$(COMPILE) $(srcdir)/common/gdb-byteswap.c
|
||||||
|
$(POSTCOMPILE)
|
||||||
|
|
||||||
#
|
#
|
||||||
# gdb/target/ dependencies
|
# gdb/target/ dependencies
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
#ifndef COMMON_TYPES_H
|
#ifndef COMMON_TYPES_H
|
||||||
#define COMMON_TYPES_H
|
#define COMMON_TYPES_H
|
||||||
|
|
||||||
|
/* This header is always available, even when BFD is not
|
||||||
|
configured. */
|
||||||
|
#include "bfd-types.h"
|
||||||
|
|
||||||
#ifdef GDBSERVER
|
#ifdef GDBSERVER
|
||||||
|
|
||||||
/* * A byte from the program being debugged. */
|
/* * A byte from the program being debugged. */
|
||||||
|
|||||||
201
gdb/common/gdb-byteswap.c
Normal file
201
gdb/common/gdb-byteswap.c
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
/* Basic byte-swapping routines, for GDB, the GNU debugger.
|
||||||
|
|
||||||
|
Copyright (C) 1986-2016 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 "common-defs.h"
|
||||||
|
#include "gdb-byteswap.h"
|
||||||
|
#include "host-defs.h"
|
||||||
|
|
||||||
|
/* See gdb-byteswap.h. */
|
||||||
|
|
||||||
|
LONGEST
|
||||||
|
extract_signed_integer (const gdb_byte *addr, int len,
|
||||||
|
enum bfd_endian byte_order)
|
||||||
|
{
|
||||||
|
LONGEST retval;
|
||||||
|
const unsigned char *p;
|
||||||
|
const unsigned char *startaddr = addr;
|
||||||
|
const unsigned char *endaddr = startaddr + len;
|
||||||
|
|
||||||
|
if (len > (int) sizeof (LONGEST))
|
||||||
|
error (_("\
|
||||||
|
That operation is not available on integers of more than %d bytes."),
|
||||||
|
(int) sizeof (LONGEST));
|
||||||
|
|
||||||
|
/* Start at the most significant end of the integer, and work towards
|
||||||
|
the least significant. */
|
||||||
|
if (byte_order == BFD_ENDIAN_BIG)
|
||||||
|
{
|
||||||
|
p = startaddr;
|
||||||
|
/* Do the sign extension once at the start. */
|
||||||
|
retval = ((LONGEST) * p ^ 0x80) - 0x80;
|
||||||
|
for (++p; p < endaddr; ++p)
|
||||||
|
retval = (retval << 8) | *p;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p = endaddr - 1;
|
||||||
|
/* Do the sign extension once at the start. */
|
||||||
|
retval = ((LONGEST) * p ^ 0x80) - 0x80;
|
||||||
|
for (--p; p >= startaddr; --p)
|
||||||
|
retval = (retval << 8) | *p;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See gdb-byteswap.h. */
|
||||||
|
|
||||||
|
ULONGEST
|
||||||
|
extract_unsigned_integer (const gdb_byte *addr, int len,
|
||||||
|
enum bfd_endian byte_order)
|
||||||
|
{
|
||||||
|
ULONGEST retval;
|
||||||
|
const unsigned char *p;
|
||||||
|
const unsigned char *startaddr = addr;
|
||||||
|
const unsigned char *endaddr = startaddr + len;
|
||||||
|
|
||||||
|
if (len > (int) sizeof (ULONGEST))
|
||||||
|
error (_("\
|
||||||
|
That operation is not available on integers of more than %d bytes."),
|
||||||
|
(int) sizeof (ULONGEST));
|
||||||
|
|
||||||
|
/* Start at the most significant end of the integer, and work towards
|
||||||
|
the least significant. */
|
||||||
|
retval = 0;
|
||||||
|
if (byte_order == BFD_ENDIAN_BIG)
|
||||||
|
{
|
||||||
|
for (p = startaddr; p < endaddr; ++p)
|
||||||
|
retval = (retval << 8) | *p;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (p = endaddr - 1; p >= startaddr; --p)
|
||||||
|
retval = (retval << 8) | *p;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See gdb_byteswap.h. */
|
||||||
|
|
||||||
|
int
|
||||||
|
extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
|
||||||
|
enum bfd_endian byte_order, LONGEST *pval)
|
||||||
|
{
|
||||||
|
const gdb_byte *p;
|
||||||
|
const gdb_byte *first_addr;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = orig_len;
|
||||||
|
if (byte_order == BFD_ENDIAN_BIG)
|
||||||
|
{
|
||||||
|
for (p = addr;
|
||||||
|
len > (int) sizeof (LONGEST) && p < addr + orig_len;
|
||||||
|
p++)
|
||||||
|
{
|
||||||
|
if (*p == 0)
|
||||||
|
len--;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
first_addr = p;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
first_addr = addr;
|
||||||
|
for (p = addr + orig_len - 1;
|
||||||
|
len > (int) sizeof (LONGEST) && p >= addr;
|
||||||
|
p--)
|
||||||
|
{
|
||||||
|
if (*p == 0)
|
||||||
|
len--;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len <= (int) sizeof (LONGEST))
|
||||||
|
{
|
||||||
|
*pval = (LONGEST) extract_unsigned_integer (first_addr,
|
||||||
|
sizeof (LONGEST),
|
||||||
|
byte_order);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* See gdb-byteswap.h. */
|
||||||
|
|
||||||
|
void
|
||||||
|
store_signed_integer (gdb_byte *addr, int len,
|
||||||
|
enum bfd_endian byte_order, LONGEST val)
|
||||||
|
{
|
||||||
|
gdb_byte *p;
|
||||||
|
gdb_byte *startaddr = addr;
|
||||||
|
gdb_byte *endaddr = startaddr + len;
|
||||||
|
|
||||||
|
/* Start at the least significant end of the integer, and work towards
|
||||||
|
the most significant. */
|
||||||
|
if (byte_order == BFD_ENDIAN_BIG)
|
||||||
|
{
|
||||||
|
for (p = endaddr - 1; p >= startaddr; --p)
|
||||||
|
{
|
||||||
|
*p = val & 0xff;
|
||||||
|
val >>= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (p = startaddr; p < endaddr; ++p)
|
||||||
|
{
|
||||||
|
*p = val & 0xff;
|
||||||
|
val >>= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See gdb-byteswap.h. */
|
||||||
|
|
||||||
|
void
|
||||||
|
store_unsigned_integer (gdb_byte *addr, int len,
|
||||||
|
enum bfd_endian byte_order, ULONGEST val)
|
||||||
|
{
|
||||||
|
unsigned char *p;
|
||||||
|
unsigned char *startaddr = (unsigned char *) addr;
|
||||||
|
unsigned char *endaddr = startaddr + len;
|
||||||
|
|
||||||
|
/* Start at the least significant end of the integer, and work towards
|
||||||
|
the most significant. */
|
||||||
|
if (byte_order == BFD_ENDIAN_BIG)
|
||||||
|
{
|
||||||
|
for (p = endaddr - 1; p >= startaddr; --p)
|
||||||
|
{
|
||||||
|
*p = val & 0xff;
|
||||||
|
val >>= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (p = startaddr; p < endaddr; ++p)
|
||||||
|
{
|
||||||
|
*p = val & 0xff;
|
||||||
|
val >>= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
49
gdb/common/gdb-byteswap.h
Normal file
49
gdb/common/gdb-byteswap.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/* Basic byte-swapping routines, for GDB, the GNU debugger.
|
||||||
|
|
||||||
|
Copyright (C) 2009-2016 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/>. */
|
||||||
|
|
||||||
|
#ifndef GDB_BYTESWAP_H
|
||||||
|
#define GDB_BYTESWAP_H 1
|
||||||
|
|
||||||
|
/* All 'extract' functions return a host-format integer from a
|
||||||
|
target-format integer at ADDR which is LEN bytes long. */
|
||||||
|
|
||||||
|
extern LONGEST extract_signed_integer (const gdb_byte *, int,
|
||||||
|
enum bfd_endian);
|
||||||
|
|
||||||
|
extern ULONGEST extract_unsigned_integer (const gdb_byte *, int,
|
||||||
|
enum bfd_endian);
|
||||||
|
|
||||||
|
/* Sometimes a long long unsigned integer can be extracted as a
|
||||||
|
LONGEST value. This is done so that we can print these values
|
||||||
|
better. If this integer can be converted to a LONGEST, this
|
||||||
|
function returns 1 and sets *PVAL. Otherwise it returns 0. */
|
||||||
|
|
||||||
|
extern int extract_long_unsigned_integer (const gdb_byte *, int,
|
||||||
|
enum bfd_endian, LONGEST *);
|
||||||
|
|
||||||
|
/* All 'store' functions accept a host-format integer and store a
|
||||||
|
target-format integer at ADDR which is LEN bytes long. */
|
||||||
|
|
||||||
|
extern void store_signed_integer (gdb_byte *, int,
|
||||||
|
enum bfd_endian, LONGEST);
|
||||||
|
|
||||||
|
extern void store_unsigned_integer (gdb_byte *, int,
|
||||||
|
enum bfd_endian, ULONGEST);
|
||||||
|
|
||||||
|
#endif
|
||||||
17
gdb/defs.h
17
gdb/defs.h
@@ -594,26 +594,13 @@ extern double atof (const char *); /* X3.159-1989 4.10.1.1 */
|
|||||||
|
|
||||||
enum { MAX_REGISTER_SIZE = 64 };
|
enum { MAX_REGISTER_SIZE = 64 };
|
||||||
|
|
||||||
|
#include "gdb-byteswap.h"
|
||||||
|
|
||||||
/* In findvar.c. */
|
/* In findvar.c. */
|
||||||
|
|
||||||
extern LONGEST extract_signed_integer (const gdb_byte *, int,
|
|
||||||
enum bfd_endian);
|
|
||||||
|
|
||||||
extern ULONGEST extract_unsigned_integer (const gdb_byte *, int,
|
|
||||||
enum bfd_endian);
|
|
||||||
|
|
||||||
extern int extract_long_unsigned_integer (const gdb_byte *, int,
|
|
||||||
enum bfd_endian, LONGEST *);
|
|
||||||
|
|
||||||
extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
|
extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
|
||||||
struct type *type);
|
struct type *type);
|
||||||
|
|
||||||
extern void store_signed_integer (gdb_byte *, int,
|
|
||||||
enum bfd_endian, LONGEST);
|
|
||||||
|
|
||||||
extern void store_unsigned_integer (gdb_byte *, int,
|
|
||||||
enum bfd_endian, ULONGEST);
|
|
||||||
|
|
||||||
extern void store_typed_address (gdb_byte *buf, struct type *type,
|
extern void store_typed_address (gdb_byte *buf, struct type *type,
|
||||||
CORE_ADDR addr);
|
CORE_ADDR addr);
|
||||||
|
|
||||||
|
|||||||
189
gdb/findvar.c
189
gdb/findvar.c
@@ -34,136 +34,6 @@
|
|||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "dwarf2loc.h"
|
#include "dwarf2loc.h"
|
||||||
|
|
||||||
/* Basic byte-swapping routines. All 'extract' functions return a
|
|
||||||
host-format integer from a target-format integer at ADDR which is
|
|
||||||
LEN bytes long. */
|
|
||||||
|
|
||||||
#if TARGET_CHAR_BIT != 8 || HOST_CHAR_BIT != 8
|
|
||||||
/* 8 bit characters are a pretty safe assumption these days, so we
|
|
||||||
assume it throughout all these swapping routines. If we had to deal with
|
|
||||||
9 bit characters, we would need to make len be in bits and would have
|
|
||||||
to re-write these routines... */
|
|
||||||
you lose
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LONGEST
|
|
||||||
extract_signed_integer (const gdb_byte *addr, int len,
|
|
||||||
enum bfd_endian byte_order)
|
|
||||||
{
|
|
||||||
LONGEST retval;
|
|
||||||
const unsigned char *p;
|
|
||||||
const unsigned char *startaddr = addr;
|
|
||||||
const unsigned char *endaddr = startaddr + len;
|
|
||||||
|
|
||||||
if (len > (int) sizeof (LONGEST))
|
|
||||||
error (_("\
|
|
||||||
That operation is not available on integers of more than %d bytes."),
|
|
||||||
(int) sizeof (LONGEST));
|
|
||||||
|
|
||||||
/* Start at the most significant end of the integer, and work towards
|
|
||||||
the least significant. */
|
|
||||||
if (byte_order == BFD_ENDIAN_BIG)
|
|
||||||
{
|
|
||||||
p = startaddr;
|
|
||||||
/* Do the sign extension once at the start. */
|
|
||||||
retval = ((LONGEST) * p ^ 0x80) - 0x80;
|
|
||||||
for (++p; p < endaddr; ++p)
|
|
||||||
retval = (retval << 8) | *p;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p = endaddr - 1;
|
|
||||||
/* Do the sign extension once at the start. */
|
|
||||||
retval = ((LONGEST) * p ^ 0x80) - 0x80;
|
|
||||||
for (--p; p >= startaddr; --p)
|
|
||||||
retval = (retval << 8) | *p;
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONGEST
|
|
||||||
extract_unsigned_integer (const gdb_byte *addr, int len,
|
|
||||||
enum bfd_endian byte_order)
|
|
||||||
{
|
|
||||||
ULONGEST retval;
|
|
||||||
const unsigned char *p;
|
|
||||||
const unsigned char *startaddr = addr;
|
|
||||||
const unsigned char *endaddr = startaddr + len;
|
|
||||||
|
|
||||||
if (len > (int) sizeof (ULONGEST))
|
|
||||||
error (_("\
|
|
||||||
That operation is not available on integers of more than %d bytes."),
|
|
||||||
(int) sizeof (ULONGEST));
|
|
||||||
|
|
||||||
/* Start at the most significant end of the integer, and work towards
|
|
||||||
the least significant. */
|
|
||||||
retval = 0;
|
|
||||||
if (byte_order == BFD_ENDIAN_BIG)
|
|
||||||
{
|
|
||||||
for (p = startaddr; p < endaddr; ++p)
|
|
||||||
retval = (retval << 8) | *p;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (p = endaddr - 1; p >= startaddr; --p)
|
|
||||||
retval = (retval << 8) | *p;
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sometimes a long long unsigned integer can be extracted as a
|
|
||||||
LONGEST value. This is done so that we can print these values
|
|
||||||
better. If this integer can be converted to a LONGEST, this
|
|
||||||
function returns 1 and sets *PVAL. Otherwise it returns 0. */
|
|
||||||
|
|
||||||
int
|
|
||||||
extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
|
|
||||||
enum bfd_endian byte_order, LONGEST *pval)
|
|
||||||
{
|
|
||||||
const gdb_byte *p;
|
|
||||||
const gdb_byte *first_addr;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
len = orig_len;
|
|
||||||
if (byte_order == BFD_ENDIAN_BIG)
|
|
||||||
{
|
|
||||||
for (p = addr;
|
|
||||||
len > (int) sizeof (LONGEST) && p < addr + orig_len;
|
|
||||||
p++)
|
|
||||||
{
|
|
||||||
if (*p == 0)
|
|
||||||
len--;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
first_addr = p;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
first_addr = addr;
|
|
||||||
for (p = addr + orig_len - 1;
|
|
||||||
len > (int) sizeof (LONGEST) && p >= addr;
|
|
||||||
p--)
|
|
||||||
{
|
|
||||||
if (*p == 0)
|
|
||||||
len--;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len <= (int) sizeof (LONGEST))
|
|
||||||
{
|
|
||||||
*pval = (LONGEST) extract_unsigned_integer (first_addr,
|
|
||||||
sizeof (LONGEST),
|
|
||||||
byte_order);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Treat the bytes at BUF as a pointer of type TYPE, and return the
|
/* Treat the bytes at BUF as a pointer of type TYPE, and return the
|
||||||
address it represents. */
|
address it represents. */
|
||||||
CORE_ADDR
|
CORE_ADDR
|
||||||
@@ -178,65 +48,6 @@ extract_typed_address (const gdb_byte *buf, struct type *type)
|
|||||||
return gdbarch_pointer_to_address (get_type_arch (type), type, buf);
|
return gdbarch_pointer_to_address (get_type_arch (type), type, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All 'store' functions accept a host-format integer and store a
|
|
||||||
target-format integer at ADDR which is LEN bytes long. */
|
|
||||||
|
|
||||||
void
|
|
||||||
store_signed_integer (gdb_byte *addr, int len,
|
|
||||||
enum bfd_endian byte_order, LONGEST val)
|
|
||||||
{
|
|
||||||
gdb_byte *p;
|
|
||||||
gdb_byte *startaddr = addr;
|
|
||||||
gdb_byte *endaddr = startaddr + len;
|
|
||||||
|
|
||||||
/* Start at the least significant end of the integer, and work towards
|
|
||||||
the most significant. */
|
|
||||||
if (byte_order == BFD_ENDIAN_BIG)
|
|
||||||
{
|
|
||||||
for (p = endaddr - 1; p >= startaddr; --p)
|
|
||||||
{
|
|
||||||
*p = val & 0xff;
|
|
||||||
val >>= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (p = startaddr; p < endaddr; ++p)
|
|
||||||
{
|
|
||||||
*p = val & 0xff;
|
|
||||||
val >>= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
store_unsigned_integer (gdb_byte *addr, int len,
|
|
||||||
enum bfd_endian byte_order, ULONGEST val)
|
|
||||||
{
|
|
||||||
unsigned char *p;
|
|
||||||
unsigned char *startaddr = (unsigned char *) addr;
|
|
||||||
unsigned char *endaddr = startaddr + len;
|
|
||||||
|
|
||||||
/* Start at the least significant end of the integer, and work towards
|
|
||||||
the most significant. */
|
|
||||||
if (byte_order == BFD_ENDIAN_BIG)
|
|
||||||
{
|
|
||||||
for (p = endaddr - 1; p >= startaddr; --p)
|
|
||||||
{
|
|
||||||
*p = val & 0xff;
|
|
||||||
val >>= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (p = startaddr; p < endaddr; ++p)
|
|
||||||
{
|
|
||||||
*p = val & 0xff;
|
|
||||||
val >>= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Store the address ADDR as a pointer of type TYPE at BUF, in target
|
/* Store the address ADDR as a pointer of type TYPE at BUF, in target
|
||||||
form. */
|
form. */
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -185,7 +185,8 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
|
|||||||
$(srcdir)/common/btrace-common.c \
|
$(srcdir)/common/btrace-common.c \
|
||||||
$(srcdir)/common/fileio.c $(srcdir)/nat/linux-namespaces.c \
|
$(srcdir)/common/fileio.c $(srcdir)/nat/linux-namespaces.c \
|
||||||
$(srcdir)/arch/arm.c $(srcdir)/common/common-regcache.c \
|
$(srcdir)/arch/arm.c $(srcdir)/common/common-regcache.c \
|
||||||
$(srcdir)/arch/arm-linux.c $(srcdir)/arch/arm-get-next-pcs.c
|
$(srcdir)/arch/arm-linux.c $(srcdir)/arch/arm-get-next-pcs.c \
|
||||||
|
$(srcdir)/common/gdb-byteswap.c
|
||||||
|
|
||||||
DEPFILES = @GDBSERVER_DEPFILES@
|
DEPFILES = @GDBSERVER_DEPFILES@
|
||||||
|
|
||||||
@@ -200,6 +201,7 @@ OBS = agent.o ax.o inferiors.o regcache.o remote-utils.o server.o signals.o \
|
|||||||
common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \
|
common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \
|
||||||
tdesc.o print-utils.o rsp-low.o errors.o common-debug.o cleanups.o \
|
tdesc.o print-utils.o rsp-low.o errors.o common-debug.o cleanups.o \
|
||||||
common-exceptions.o symbol.o btrace-common.o fileio.o common-regcache.o \
|
common-exceptions.o symbol.o btrace-common.o fileio.o common-regcache.o \
|
||||||
|
gdb-byteswap.o \
|
||||||
$(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)
|
$(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)
|
||||||
GDBREPLAY_OBS = gdbreplay.o version.o
|
GDBREPLAY_OBS = gdbreplay.o version.o
|
||||||
GDBSERVER_LIBS = @GDBSERVER_LIBS@
|
GDBSERVER_LIBS = @GDBSERVER_LIBS@
|
||||||
@@ -590,6 +592,9 @@ fileio.o: ../common/fileio.c
|
|||||||
common-regcache.o: ../common/common-regcache.c
|
common-regcache.o: ../common/common-regcache.c
|
||||||
$(COMPILE) $<
|
$(COMPILE) $<
|
||||||
$(POSTCOMPILE)
|
$(POSTCOMPILE)
|
||||||
|
gdb-byteswap.o: ../common/gdb-byteswap.c
|
||||||
|
$(COMPILE) $<
|
||||||
|
$(POSTCOMPILE)
|
||||||
|
|
||||||
# Arch object files rules form ../arch
|
# Arch object files rules form ../arch
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
#include "gdbthread.h"
|
#include "gdbthread.h"
|
||||||
#include "tdesc.h"
|
#include "tdesc.h"
|
||||||
#include "rsp-low.h"
|
#include "rsp-low.h"
|
||||||
|
#include "bfd-types.h"
|
||||||
|
#include "gdb-byteswap.h"
|
||||||
|
|
||||||
#ifndef IN_PROCESS_AGENT
|
#ifndef IN_PROCESS_AGENT
|
||||||
|
|
||||||
struct regcache *
|
struct regcache *
|
||||||
@@ -424,14 +427,25 @@ collect_register (struct regcache *regcache, int n, void *buf)
|
|||||||
register_size (regcache->tdesc, n));
|
register_size (regcache->tdesc, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef IN_PROCESS_AGENT
|
||||||
|
|
||||||
|
/* Return host endianness as an enum bfd_endian. */
|
||||||
|
|
||||||
|
static enum bfd_endian
|
||||||
|
host_bfd_endian (void)
|
||||||
|
{
|
||||||
|
return (__BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
? BFD_ENDIAN_LITTLE
|
||||||
|
: BFD_ENDIAN_BIG);
|
||||||
|
}
|
||||||
|
|
||||||
enum register_status
|
enum register_status
|
||||||
regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
|
regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
|
||||||
ULONGEST *val)
|
ULONGEST *val)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
gdb_byte *buf;
|
||||||
gdb_assert (regcache != NULL);
|
enum bfd_endian byteorder;
|
||||||
gdb_assert (regnum >= 0 && regnum < regcache->tdesc->num_registers);
|
|
||||||
|
|
||||||
size = register_size (regcache->tdesc, regnum);
|
size = register_size (regcache->tdesc, regnum);
|
||||||
|
|
||||||
@@ -440,14 +454,17 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
|
|||||||
"%d bytes."),
|
"%d bytes."),
|
||||||
(int) sizeof (ULONGEST));
|
(int) sizeof (ULONGEST));
|
||||||
|
|
||||||
*val = 0;
|
buf = (gdb_byte *) alloca (size);
|
||||||
collect_register (regcache, regnum, val);
|
collect_register (regcache, regnum, buf);
|
||||||
|
|
||||||
|
/* Assume the inferior's byte order is the same as gdbserver's (the
|
||||||
|
host). */
|
||||||
|
byteorder = host_bfd_endian ();
|
||||||
|
|
||||||
|
*val = extract_unsigned_integer (buf, size, byteorder);
|
||||||
return REG_VALID;
|
return REG_VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef IN_PROCESS_AGENT
|
|
||||||
|
|
||||||
void
|
void
|
||||||
collect_register_as_string (struct regcache *regcache, int n, char *buf)
|
collect_register_as_string (struct regcache *regcache, int n, char *buf)
|
||||||
{
|
{
|
||||||
|
|||||||
26
include/bfd-types.h
Normal file
26
include/bfd-types.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/* bfd core types that do not depend on configuration.
|
||||||
|
|
||||||
|
Copyright (C) 1990-2016 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
#ifndef BFD_TYPES_H
|
||||||
|
#define BFD_TYPES_H
|
||||||
|
|
||||||
|
enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user