* utils.c: Clean up comments about wrap buffer and wrap_here.
* printcmd.c (printf_command): Call wrap_here before vprintf.
This commit is contained in:
parent
81074ec8d1
commit
19bdd57f75
|
@ -1,5 +1,8 @@
|
||||||
Fri Jul 9 12:36:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
Fri Jul 9 12:36:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||||
|
|
||||||
|
* utils.c: Clean up comments about wrap buffer and wrap_here.
|
||||||
|
* printcmd.c (printf_command): Call wrap_here before vprintf.
|
||||||
|
|
||||||
* mipsread.c (cross_ref): Set the name to unknown for "struct *" case.
|
* mipsread.c (cross_ref): Set the name to unknown for "struct *" case.
|
||||||
Patch from ptf@delcam.co.uk (Paul Flinders).
|
Patch from ptf@delcam.co.uk (Paul Flinders).
|
||||||
|
|
||||||
|
|
139
gdb/printcmd.c
139
gdb/printcmd.c
|
@ -19,6 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <varargs.h>
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "gdbtypes.h"
|
#include "gdbtypes.h"
|
||||||
|
@ -318,7 +319,7 @@ print_formatted (val, format, size)
|
||||||
I'm not completely sure what that means, I suspect most print_insn
|
I'm not completely sure what that means, I suspect most print_insn
|
||||||
now do use _filtered, so I guess it's obsolete. */
|
now do use _filtered, so I guess it's obsolete. */
|
||||||
/* We often wrap here if there are long symbolic names. */
|
/* We often wrap here if there are long symbolic names. */
|
||||||
wrap_here ("\t");
|
wrap_here (" ");
|
||||||
next_address = VALUE_ADDRESS (val)
|
next_address = VALUE_ADDRESS (val)
|
||||||
+ print_insn (VALUE_ADDRESS (val), stdout);
|
+ print_insn (VALUE_ADDRESS (val), stdout);
|
||||||
break;
|
break;
|
||||||
|
@ -1611,6 +1612,86 @@ print_frame_nameless_args (fi, start, num, first, stream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make makeva* work on an __INT_VARARGS_H machine. */
|
||||||
|
|
||||||
|
#if defined (__INT_VARARGS_H)
|
||||||
|
/* This is used on an 88k. Not sure whether it is used by anything else. */
|
||||||
|
#define MAKEVA_END(list) \
|
||||||
|
va_list retval; \
|
||||||
|
retval.__va_arg = 0; \
|
||||||
|
retval.__va_stk = (int *) (list)->arg_bytes; \
|
||||||
|
retval.__va_reg = (int *) (list)->arg_bytes; \
|
||||||
|
return retval;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This is an interface which allows to us make a va_list. */
|
||||||
|
typedef struct {
|
||||||
|
unsigned int nargs;
|
||||||
|
unsigned int max_arg_size;
|
||||||
|
|
||||||
|
/* Current position in bytes. */
|
||||||
|
unsigned int argindex;
|
||||||
|
|
||||||
|
char arg_bytes[1];
|
||||||
|
} makeva_list;
|
||||||
|
|
||||||
|
/* Tell the caller how many bytes to allocate for a makeva_list with NARGS
|
||||||
|
arguments and whose largest argument is MAX_ARG_SIZE bytes. This
|
||||||
|
way the caller can use alloca, malloc, or some other allocator. */
|
||||||
|
unsigned int
|
||||||
|
makeva_size (nargs, max_arg_size)
|
||||||
|
unsigned int nargs;
|
||||||
|
unsigned int max_arg_size;
|
||||||
|
{
|
||||||
|
return sizeof (makeva_list) + nargs * max_arg_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Start working on LIST with NARGS arguments and whose largest
|
||||||
|
argument is MAX_ARG_SIZE bytes. */
|
||||||
|
void
|
||||||
|
makeva_start (list, nargs, max_arg_size)
|
||||||
|
makeva_list *list;
|
||||||
|
unsigned int nargs;
|
||||||
|
unsigned int max_arg_size;
|
||||||
|
{
|
||||||
|
list->nargs = nargs;
|
||||||
|
list->max_arg_size = max_arg_size;
|
||||||
|
#if defined (MAKEVA_START)
|
||||||
|
MAKEVA_START (list);
|
||||||
|
#else
|
||||||
|
list->argindex = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add ARG to LIST. */
|
||||||
|
void
|
||||||
|
makeva_arg (list, argaddr, argsize)
|
||||||
|
makeva_list *list;
|
||||||
|
PTR argaddr;
|
||||||
|
unsigned int argsize;
|
||||||
|
{
|
||||||
|
#if defined (MAKEVA_ARG)
|
||||||
|
MAKEVA_ARG (list, argaddr, argsize);
|
||||||
|
#else
|
||||||
|
memcpy (&list->arg_bytes[list->argindex], argaddr, argsize);
|
||||||
|
list->argindex += argsize;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* From LIST, for which makeva_arg has been called for each arg,
|
||||||
|
return a va_list containing the args. */
|
||||||
|
va_list
|
||||||
|
makeva_end (list)
|
||||||
|
makeva_list *list;
|
||||||
|
{
|
||||||
|
#if defined (MAKEVA_END)
|
||||||
|
MAKEVA_END (list);
|
||||||
|
#else
|
||||||
|
/* This works if a va_list is just a pointer to the arguments. */
|
||||||
|
return (va_list) list->arg_bytes;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
static void
|
static void
|
||||||
printf_command (arg, from_tty)
|
printf_command (arg, from_tty)
|
||||||
|
@ -1623,7 +1704,7 @@ printf_command (arg, from_tty)
|
||||||
value *val_args;
|
value *val_args;
|
||||||
int nargs = 0;
|
int nargs = 0;
|
||||||
int allocated_args = 20;
|
int allocated_args = 20;
|
||||||
char *arg_bytes;
|
va_list args_to_vprintf;
|
||||||
|
|
||||||
val_args = (value *) xmalloc (allocated_args * sizeof (value));
|
val_args = (value *) xmalloc (allocated_args * sizeof (value));
|
||||||
|
|
||||||
|
@ -1698,10 +1779,10 @@ printf_command (arg, from_tty)
|
||||||
enum argclass {int_arg, string_arg, double_arg, long_long_arg};
|
enum argclass {int_arg, string_arg, double_arg, long_long_arg};
|
||||||
enum argclass *argclass;
|
enum argclass *argclass;
|
||||||
int nargs_wanted;
|
int nargs_wanted;
|
||||||
int argindex;
|
|
||||||
int lcount;
|
int lcount;
|
||||||
int i;
|
int i;
|
||||||
|
makeva_list *args_makeva;
|
||||||
|
|
||||||
argclass = (enum argclass *) alloca (strlen (s) * sizeof *argclass);
|
argclass = (enum argclass *) alloca (strlen (s) * sizeof *argclass);
|
||||||
nargs_wanted = 0;
|
nargs_wanted = 0;
|
||||||
f = string;
|
f = string;
|
||||||
|
@ -1757,12 +1838,13 @@ printf_command (arg, from_tty)
|
||||||
|
|
||||||
if (nargs != nargs_wanted)
|
if (nargs != nargs_wanted)
|
||||||
error ("Wrong number of arguments for specified format-string");
|
error ("Wrong number of arguments for specified format-string");
|
||||||
|
|
||||||
/* Now lay out an argument-list containing the arguments
|
/* Now lay out an argument-list containing the arguments
|
||||||
as doubles, integers and C pointers. */
|
as doubles, integers and C pointers. */
|
||||||
|
|
||||||
arg_bytes = (char *) alloca (sizeof (double) * nargs);
|
args_makeva = (makeva_list *)
|
||||||
argindex = 0;
|
alloca (makeva_size (nargs, sizeof (double)));
|
||||||
|
makeva_start (args_makeva, nargs, sizeof (double));
|
||||||
for (i = 0; i < nargs; i++)
|
for (i = 0; i < nargs; i++)
|
||||||
{
|
{
|
||||||
if (argclass[i] == string_arg)
|
if (argclass[i] == string_arg)
|
||||||
|
@ -1788,49 +1870,38 @@ printf_command (arg, from_tty)
|
||||||
str[j] = 0;
|
str[j] = 0;
|
||||||
|
|
||||||
/* Pass address of internal copy as the arg to vprintf. */
|
/* Pass address of internal copy as the arg to vprintf. */
|
||||||
*((int *) &arg_bytes[argindex]) = (int) str;
|
makeva_arg (args_makeva, &str, sizeof (str));
|
||||||
argindex += sizeof (int);
|
|
||||||
}
|
}
|
||||||
else if (VALUE_TYPE (val_args[i])->code == TYPE_CODE_FLT)
|
else if (VALUE_TYPE (val_args[i])->code == TYPE_CODE_FLT)
|
||||||
{
|
{
|
||||||
*((double *) &arg_bytes[argindex]) = value_as_double (val_args[i]);
|
double val = value_as_double (val_args[i]);
|
||||||
argindex += sizeof (double);
|
makeva_arg (args_makeva, &val, sizeof (val));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#ifdef CC_HAS_LONG_LONG
|
#ifdef CC_HAS_LONG_LONG
|
||||||
if (argclass[i] == long_long_arg)
|
if (argclass[i] == long_long_arg)
|
||||||
{
|
{
|
||||||
*(LONGEST *) &arg_bytes[argindex] = value_as_long (val_args[i]);
|
long long val = value_as_long (val_args[i]);
|
||||||
argindex += sizeof (LONGEST);
|
makeva_arg (args_makeva, &val, sizeof (val));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
*((long *) &arg_bytes[argindex]) = value_as_long (val_args[i]);
|
long val = value_as_long (val_args[i]);
|
||||||
argindex += sizeof (long);
|
makeva_arg (args_makeva, &val, sizeof (val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
args_to_vprintf = makeva_end (args_makeva);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There is not a standard way to make a va_list, so we need
|
/* FIXME: We should be using vprintf_filtered, but as long as it has an
|
||||||
to do various things for different systems. */
|
arbitrary limit that is unacceptable. Correct fix is for vprintf_filtered
|
||||||
#if defined (__INT_VARARGS_H)
|
to scan down the format string so it knows how big a buffer it needs.
|
||||||
/* This is defined by an 88k using gcc1. Do other machines use it? */
|
|
||||||
{
|
|
||||||
va_list list;
|
|
||||||
|
|
||||||
list.__va_arg = 0;
|
But for now, just force out any pending output, so at least the output
|
||||||
list.__va_stk = (int *) arg_bytes;
|
appears in the correct order. */
|
||||||
list.__va_reg = (int *) arg_bytes;
|
wrap_here ((char *)NULL);
|
||||||
vprintf (string, list);
|
vprintf (string, args_to_vprintf);
|
||||||
}
|
|
||||||
#else /* No __INT_VARARGS_H. */
|
|
||||||
#ifdef VPRINTF
|
|
||||||
VPRINTF (string, arg_bytes);
|
|
||||||
#else /* No VPRINTF. */
|
|
||||||
vprintf (string, (PTR) arg_bytes);
|
|
||||||
#endif /* No VPRINTF. */
|
|
||||||
#endif /* No __INT_VARARGS_H. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper function for asdump_command. Finds the bounds of a function
|
/* Helper function for asdump_command. Finds the bounds of a function
|
||||||
|
|
Loading…
Reference in New Issue