/* Print values for GDB, the GNU debugger.
- Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1998
+ Copyright 1986, 1988, 1989, 1991-1994, 1998, 2000
Free Software Foundation, Inc.
This file is part of GDB.
/* Prototypes for local functions */
-static void print_hex_chars PARAMS ((GDB_FILE *, unsigned char *,
- unsigned int));
+static int partial_memory_read (CORE_ADDR memaddr, char *myaddr,
+ int len, int *errnoptr);
+
+static void print_hex_chars (struct ui_file *, unsigned char *,
+ unsigned int);
static void show_print PARAMS ((char *, int));
char *valaddr;
int embedded_offset;
CORE_ADDR address;
- GDB_FILE *stream;
+ struct ui_file *stream;
int format;
int deref_ref;
int recurse;
int
value_print (val, stream, format, pretty)
value_ptr val;
- GDB_FILE *stream;
+ struct ui_file *stream;
int format;
enum val_prettyprint pretty;
{
val_print_type_code_int (type, valaddr, stream)
struct type *type;
char *valaddr;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
if (TYPE_LENGTH (type) > sizeof (LONGEST))
{
*/
#if defined (CC_HAS_LONG_LONG) && !defined (PRINTF_HAS_LONG_LONG)
-static void print_decimal PARAMS ((GDB_FILE * stream, char *sign, int use_local, ULONGEST val_ulong));
+static void print_decimal (struct ui_file * stream, char *sign,
+ int use_local, ULONGEST val_ulong);
static void
print_decimal (stream, sign, use_local, val_ulong)
- GDB_FILE *stream;
+ struct ui_file *stream;
char *sign;
int use_local;
ULONGEST val_ulong;
void
print_longest (stream, format, use_local, val_long)
- GDB_FILE *stream;
+ struct ui_file *stream;
int format;
int use_local;
LONGEST val_long;
print_floating (valaddr, type, stream)
char *valaddr;
struct type *type;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
DOUBLEST doub;
int inv;
void
print_binary_chars (stream, valaddr, len)
- GDB_FILE *stream;
+ struct ui_file *stream;
unsigned char *valaddr;
unsigned len;
{
#define BITS_IN_BYTES 8
unsigned char *p;
- int i;
+ unsigned int i;
int b;
/* Declared "int" so it will be signed.
*/
void
print_octal_chars (stream, valaddr, len)
- GDB_FILE *stream;
+ struct ui_file *stream;
unsigned char *valaddr;
unsigned len;
{
*/
void
print_decimal_chars (stream, valaddr, len)
- GDB_FILE *stream;
+ struct ui_file *stream;
unsigned char *valaddr;
unsigned len;
{
static void
print_hex_chars (stream, valaddr, len)
- GDB_FILE *stream;
+ struct ui_file *stream;
unsigned char *valaddr;
unsigned len;
{
struct type *type;
char *valaddr;
CORE_ADDR address;
- GDB_FILE *stream;
+ struct ui_file *stream;
int format;
int deref_ref;
int recurse;
}
}
+/* Read LEN bytes of target memory at address MEMADDR, placing the
+ results in GDB's memory at MYADDR. Returns a count of the bytes
+ actually read, and optionally an errno value in the location
+ pointed to by ERRNOPTR if ERRNOPTR is non-null. */
+
+/* FIXME: cagney/1999-10-14: Only used by val_print_string. Can this
+ function be eliminated. */
+
+static int
+partial_memory_read (CORE_ADDR memaddr, char *myaddr, int len, int *errnoptr)
+{
+ int nread; /* Number of bytes actually read. */
+ int errcode; /* Error from last read. */
+
+ /* First try a complete read. */
+ errcode = target_read_memory (memaddr, myaddr, len);
+ if (errcode == 0)
+ {
+ /* Got it all. */
+ nread = len;
+ }
+ else
+ {
+ /* Loop, reading one byte at a time until we get as much as we can. */
+ for (errcode = 0, nread = 0; len > 0 && errcode == 0; nread++, len--)
+ {
+ errcode = target_read_memory (memaddr++, myaddr++, 1);
+ }
+ /* If an error, the last read was unsuccessful, so adjust count. */
+ if (errcode != 0)
+ {
+ nread--;
+ }
+ }
+ if (errnoptr != NULL)
+ {
+ *errnoptr = errcode;
+ }
+ return (nread);
+}
+
/* Print a string from the inferior, starting at ADDR and printing up to LEN
characters, of WIDTH bytes a piece, to STREAM. If LEN is -1, printing
stops at the first null byte, otherwise printing proceeds (including null
CORE_ADDR addr;
int len;
int width;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
int force_ellipsis = 0; /* Force ellipsis to be printed if nonzero. */
int errcode; /* Errno returned from bad reads. */
bufptr = buffer;
old_chain = make_cleanup (free, buffer);
- nfetch = target_read_memory_partial (addr, bufptr, len * width, &errcode)
+ nfetch = partial_memory_read (addr, bufptr, len * width, &errcode)
/ width;
addr += nfetch * width;
bufptr += nfetch * width;
bufsize += nfetch;
/* Read as much as we can. */
- nfetch = target_read_memory_partial (addr, bufptr, nfetch * width, &errcode)
+ nfetch = partial_memory_read (addr, bufptr, nfetch * width, &errcode)
/ width;
/* Scan this chunk for the null byte that terminates the string