* defs.h printcmd.c: Create global disassemble_info structure

tm_print_insn_info.
	* gdbtk.c (gdb_disassemble):  Setup di.mach from
	tm_print_insn_info.mach, and set endian from TARGET_BYTE_ORDER.
	* i386-tdep.c (set_assembly_language_command):  set
	tm_print_insn_info.mach to the appropriate value for 386 or 8086
	disassembly.
	* printcmd.c (print_insn):  Move init of disassembler_info to
	_initialize_printcmd.  Set endian for disassembler here.
	* sparc-tdep.c:  Set tm_print_insn_info.mach as appropriate to
	select sparc/sparclite.
	* config/sparc/{tm-sparc.h tm-sparclite.h}:  Get rid of
	TM_PRINT_INSN.  Set TM_PRINT_INSN_MACH to
	bfd_mach_sparc/bfd_mach_sparc_sparclite.
This commit is contained in:
Stu Grossman 1996-07-15 23:54:39 +00:00
parent 3cc21bf602
commit 91550191be
7 changed files with 96 additions and 52 deletions

View File

@ -1,3 +1,20 @@
Mon Jul 15 16:44:05 1996 Stu Grossman (grossman@critters.cygnus.com)
* defs.h printcmd.c: Create global disassemble_info structure
tm_print_insn_info.
* gdbtk.c (gdb_disassemble): Setup di.mach from
tm_print_insn_info.mach, and set endian from TARGET_BYTE_ORDER.
* i386-tdep.c (set_assembly_language_command): set
tm_print_insn_info.mach to the appropriate value for 386 or 8086
disassembly.
* printcmd.c (print_insn): Move init of disassembler_info to
_initialize_printcmd. Set endian for disassembler here.
* sparc-tdep.c: Set tm_print_insn_info.mach as appropriate to
select sparc/sparclite.
* config/sparc/{tm-sparc.h tm-sparclite.h}: Get rid of
TM_PRINT_INSN. Set TM_PRINT_INSN_MACH to
bfd_mach_sparc/bfd_mach_sparc_sparclite.
Fri Jul 12 19:04:32 1996 Fred Fish <fnf@cygnus.com> Fri Jul 12 19:04:32 1996 Fred Fish <fnf@cygnus.com>
* hpread.c (hpread_lookup_type): Use xmmalloc/xmrealloc rather * hpread.c (hpread_lookup_type): Use xmmalloc/xmrealloc rather

View File

@ -644,4 +644,4 @@ extern int deferred_stores;
/* Select the sparc disassembler */ /* Select the sparc disassembler */
#define TM_PRINT_INSN print_insn_sparc #define TM_PRINT_INSN_MACH bfd_mach_sparc

View File

@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Select the sparclite disassembler. Slightly different instruction set from /* Select the sparclite disassembler. Slightly different instruction set from
the V8 sparc. */ the V8 sparc. */
#undef TM_PRINT_INSN #undef TM_PRINT_INSN_MACH
#define TM_PRINT_INSN print_insn_sparclite #define TM_PRINT_INSN_MACH bfd_mach_sparc_sparclite
/* Amount PC must be decremented by after a hardware instruction breakpoint. /* Amount PC must be decremented by after a hardware instruction breakpoint.
This is often the number of bytes in BREAKPOINT This is often the number of bytes in BREAKPOINT

View File

@ -413,7 +413,7 @@ struct command_line
struct command_line **body_list; struct command_line **body_list;
}; };
extern struct command_line *read_command_lines PARAMS ((void)); extern struct command_line *read_command_lines PARAMS ((char *, int));
extern void free_command_lines PARAMS ((struct command_line **)); extern void free_command_lines PARAMS ((struct command_line **));
@ -902,18 +902,14 @@ extern const struct floatformat floatformat_unknown;
#ifdef HAVE_LONG_DOUBLE #ifdef HAVE_LONG_DOUBLE
typedef long double DOUBLEST; typedef long double DOUBLEST;
extern void floatformat_to_long_double PARAMS ((const struct floatformat *,
char *, DOUBLEST *));
extern void floatformat_from_long_double PARAMS ((const struct floatformat *,
DOUBLEST *, char *));
#define FLOATFORMAT_TO_DOUBLEST floatformat_to_long_double
#define FLOATFORMAT_FROM_DOUBLEST floatformat_from_long_double
#else #else
typedef double DOUBLEST; typedef double DOUBLEST;
#define FLOATFORMAT_TO_DOUBLEST floatformat_to_double
#define FLOATFORMAT_FROM_DOUBLEST floatformat_from_double
#endif #endif
extern void floatformat_to_doublest PARAMS ((const struct floatformat *,
char *, DOUBLEST *));
extern void floatformat_from_doublest PARAMS ((const struct floatformat *,
DOUBLEST *, char *));
extern DOUBLEST extract_floating PARAMS ((void *, int)); extern DOUBLEST extract_floating PARAMS ((void *, int));
extern void store_floating PARAMS ((void *, int, DOUBLEST)); extern void store_floating PARAMS ((void *, int, DOUBLEST));
@ -968,6 +964,7 @@ extern void dis_asm_print_address PARAMS ((bfd_vma addr,
disassemble_info *info)); disassemble_info *info));
extern int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info*)); extern int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info*));
extern disassemble_info tm_print_insn_info;
/* Hooks for alternate command interfaces. */ /* Hooks for alternate command interfaces. */
@ -983,7 +980,7 @@ extern void (*fputs_unfiltered_hook) PARAMS ((const char *linebuffer,
extern void (*print_frame_info_listing_hook) PARAMS ((struct symtab *s, extern void (*print_frame_info_listing_hook) PARAMS ((struct symtab *s,
int line, int stopline, int line, int stopline,
int noerror)); int noerror));
extern int (*query_hook) PARAMS (()); extern int (*query_hook) PARAMS ((const char *, va_list));
extern void (*flush_hook) PARAMS ((FILE *stream)); extern void (*flush_hook) PARAMS ((FILE *stream));
extern void (*create_breakpoint_hook) PARAMS ((struct breakpoint *b)); extern void (*create_breakpoint_hook) PARAMS ((struct breakpoint *b));
extern void (*delete_breakpoint_hook) PARAMS ((struct breakpoint *bpt)); extern void (*delete_breakpoint_hook) PARAMS ((struct breakpoint *bpt));
@ -991,6 +988,9 @@ extern void (*modify_breakpoint_hook) PARAMS ((struct breakpoint *bpt));
extern void (*target_output_hook) PARAMS ((char *)); extern void (*target_output_hook) PARAMS ((char *));
extern void (*interactive_hook) PARAMS ((void)); extern void (*interactive_hook) PARAMS ((void));
extern void (*registers_changed_hook) PARAMS ((void)); extern void (*registers_changed_hook) PARAMS ((void));
extern void (*readline_begin_hook) PARAMS ((char *, ...));
extern char * (*readline_hook) PARAMS ((char *));
extern void (*readline_end_hook) PARAMS ((void));
extern int (*target_wait_hook) PARAMS ((int pid, extern int (*target_wait_hook) PARAMS ((int pid,
struct target_waitstatus *status)); struct target_waitstatus *status));

View File

@ -891,13 +891,19 @@ gdb_disassemble (clientData, interp, argc, argv)
if (! di_initialized) if (! di_initialized)
{ {
INIT_DISASSEMBLE_INFO (di, gdb_stdout, INIT_DISASSEMBLE_INFO_NO_ARCH (di, gdb_stdout,
(fprintf_ftype) fprintf_unfiltered); (fprintf_ftype) fprintf_unfiltered);
di.memory_error_func = dis_asm_memory_error; di.memory_error_func = dis_asm_memory_error;
di.print_address_func = dis_asm_print_address; di.print_address_func = dis_asm_print_address;
di_initialized = 1; di_initialized = 1;
} }
di.mach = tm_print_insn_info.mach;
if (TARGET_BYTE_ORDER == BIG_ENDIAN)
tm_print_insn_info.endian = BFD_ENDIAN_BIG;
else
tm_print_insn_info.endian = BFD_ENDIAN_LITTLE;
if (argc != 3 && argc != 4) if (argc != 3 && argc != 4)
error ("wrong # args"); error ("wrong # args");

View File

@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h" #include "defs.h"
#include "gdb_string.h" #include "gdb_string.h"
@ -113,6 +113,7 @@ static int display_number;
/* Pointer to the target-dependent disassembly function. */ /* Pointer to the target-dependent disassembly function. */
int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info *)); int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info *));
disassemble_info tm_print_insn_info;
/* Prototypes for local functions. */ /* Prototypes for local functions. */
@ -271,7 +272,8 @@ print_formatted (val, format, size)
register int format; register int format;
int size; int size;
{ {
int len = TYPE_LENGTH (VALUE_TYPE (val)); struct type *type = check_typedef (VALUE_TYPE (val));
int len = TYPE_LENGTH (type);
if (VALUE_LVAL (val) == lval_memory) if (VALUE_LVAL (val) == lval_memory)
next_address = VALUE_ADDRESS (val) + len; next_address = VALUE_ADDRESS (val) + len;
@ -296,14 +298,13 @@ print_formatted (val, format, size)
default: default:
if (format == 0 if (format == 0
|| TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ARRAY || TYPE_CODE (type) == TYPE_CODE_ARRAY
|| TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRING || TYPE_CODE (type) == TYPE_CODE_STRING
|| TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRUCT || TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_UNION || TYPE_CODE (type) == TYPE_CODE_UNION)
|| VALUE_REPEATED (val))
value_print (val, gdb_stdout, format, Val_pretty_default); value_print (val, gdb_stdout, format, Val_pretty_default);
else else
print_scalar_formatted (VALUE_CONTENTS (val), VALUE_TYPE (val), print_scalar_formatted (VALUE_CONTENTS (val), type,
format, size, gdb_stdout); format, size, gdb_stdout);
} }
} }
@ -324,7 +325,7 @@ print_scalar_formatted (valaddr, type, format, size, stream)
GDB_FILE *stream; GDB_FILE *stream;
{ {
LONGEST val_long; LONGEST val_long;
int len = TYPE_LENGTH (type); unsigned int len = TYPE_LENGTH (type);
if (len > sizeof (LONGEST) if (len > sizeof (LONGEST)
&& (format == 't' && (format == 't'
@ -334,18 +335,23 @@ print_scalar_formatted (valaddr, type, format, size, stream)
|| format == 'd' || format == 'd'
|| format == 'x')) || format == 'x'))
{ {
/* We can't print it normally, but we can print it in hex. if (! TYPE_UNSIGNED (type)
Printing it in the wrong radix is more useful than saying || ! extract_long_unsigned_integer (valaddr, len, &val_long))
"use /x, you dummy". */ {
/* FIXME: we could also do octal or binary if that was the /* We can't print it normally, but we can print it in hex.
desired format. */ Printing it in the wrong radix is more useful than saying
/* FIXME: we should be using the size field to give us a minimum "use /x, you dummy". */
field width to print. */ /* FIXME: we could also do octal or binary if that was the
val_print_type_code_int (type, valaddr, stream); desired format. */
return; /* FIXME: we should be using the size field to give us a
} minimum field width to print. */
val_print_type_code_int (type, valaddr, stream);
return;
}
if (format != 'f') /* If we get here, extract_long_unsigned_integer set val_long. */
}
else if (format != 'f')
val_long = unpack_long (type, valaddr); val_long = unpack_long (type, valaddr);
/* If we are printing it as unsigned, truncate it in case it is actually /* If we are printing it as unsigned, truncate it in case it is actually
@ -684,6 +690,7 @@ do_examine (fmt, addr)
while (count > 0) while (count > 0)
{ {
QUIT;
print_address (next_address, gdb_stdout); print_address (next_address, gdb_stdout);
printf_filtered (":"); printf_filtered (":");
for (i = maxelts; for (i = maxelts;
@ -1014,6 +1021,21 @@ address_info (exp, from_tty)
gdb_stdout); gdb_stdout);
break; break;
case LOC_UNRESOLVED:
{
struct minimal_symbol *msym;
msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, NULL);
if (msym == NULL)
printf_filtered ("unresolved");
else
{
printf_filtered ("static storage at address ");
print_address_numeric (SYMBOL_VALUE_ADDRESS (msym), 1, gdb_stdout);
}
}
break;
case LOC_OPTIMIZED_OUT: case LOC_OPTIMIZED_OUT:
printf_filtered ("optimized out"); printf_filtered ("optimized out");
break; break;
@ -1530,7 +1552,6 @@ print_frame_args (func, fi, num, stream)
case LOC_REF_ARG: case LOC_REF_ARG:
{ {
long current_offset = SYMBOL_VALUE (sym); long current_offset = SYMBOL_VALUE (sym);
arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym)); arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym));
/* Compute address of next argument by adding the size of /* Compute address of next argument by adding the size of
@ -1898,9 +1919,10 @@ printf_command (arg, from_tty)
if (argclass[nargs] == double_arg) if (argclass[nargs] == double_arg)
{ {
if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (float)) struct type *type = VALUE_TYPE (val_args[nargs]);
if (TYPE_LENGTH (type) == sizeof (float))
VALUE_TYPE (val_args[nargs]) = builtin_type_float; VALUE_TYPE (val_args[nargs]) = builtin_type_float;
if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (double)) if (TYPE_LENGTH (type) == sizeof (double))
VALUE_TYPE (val_args[nargs]) = builtin_type_double; VALUE_TYPE (val_args[nargs]) = builtin_type_double;
} }
nargs++; nargs++;
@ -2058,23 +2080,15 @@ print_insn (memaddr, stream)
CORE_ADDR memaddr; CORE_ADDR memaddr;
GDB_FILE *stream; GDB_FILE *stream;
{ {
disassemble_info info;
#define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \
(INFO).fprintf_func = (fprintf_ftype)fprintf_filtered, \
(INFO).stream = (STREAM), \
(INFO).read_memory_func = dis_asm_read_memory, \
(INFO).memory_error_func = dis_asm_memory_error, \
(INFO).print_address_func = dis_asm_print_address, \
(INFO).insn_info_valid = 0
GDB_INIT_DISASSEMBLE_INFO(info, stream);
/* If there's no disassembler, something is very wrong. */ /* If there's no disassembler, something is very wrong. */
if (tm_print_insn == NULL) if (tm_print_insn == NULL)
abort (); abort ();
return (*tm_print_insn) (memaddr, &info); if (TARGET_BYTE_ORDER == BIG_ENDIAN)
tm_print_insn_info.endian = BFD_ENDIAN_BIG;
else
tm_print_insn_info.endian = BFD_ENDIAN_LITTLE;
return (*tm_print_insn) (memaddr, &tm_print_insn_info);
} }
@ -2229,4 +2243,9 @@ environment, the value is printed in its own window.");
examine_h_type = init_type (TYPE_CODE_INT, 2, 0, "examine_h_type", NULL); examine_h_type = init_type (TYPE_CODE_INT, 2, 0, "examine_h_type", NULL);
examine_w_type = init_type (TYPE_CODE_INT, 4, 0, "examine_w_type", NULL); examine_w_type = init_type (TYPE_CODE_INT, 4, 0, "examine_w_type", NULL);
examine_g_type = init_type (TYPE_CODE_INT, 8, 0, "examine_g_type", NULL); examine_g_type = init_type (TYPE_CODE_INT, 8, 0, "examine_g_type", NULL);
INIT_DISASSEMBLE_INFO_NO_ARCH (tm_print_insn_info, gdb_stdout, (fprintf_ftype)fprintf_filtered);
tm_print_insn_info.read_memory_func = dis_asm_read_memory;
tm_print_insn_info.memory_error_func = dis_asm_memory_error;
tm_print_insn_info.print_address_func = dis_asm_print_address;
} }

View File

@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "obstack.h" #include "obstack.h"
#include "target.h" #include "target.h"
#include "value.h" #include "value.h"
#include "bfd.h"
#ifdef USE_PROC_FS #ifdef USE_PROC_FS
#include <sys/procfs.h> #include <sys/procfs.h>
@ -1548,5 +1549,6 @@ sparc_print_register_hook (regno)
void void
_initialize_sparc_tdep () _initialize_sparc_tdep ()
{ {
tm_print_insn = TM_PRINT_INSN; /* Selects sparc/sparclite */ tm_print_insn = print_insn_sparc;
tm_print_insn_info.mach = TM_PRINT_INSN_MACH; /* Selects sparc/sparclite */
} }