#include "objfiles.h" /* ditto */
#include "completer.h" /* for completion functions */
#include "ui-out.h"
+#include "gdb_assert.h"
extern int asm_demangle; /* Whether to demangle syms in asm printouts */
extern int addressprint; /* Whether to print hex addresses in HLL " */
static void disable_display_command (char *, int);
-static void disassemble_command (char *, int);
-
static void printf_command (char *, int);
static void print_frame_nameless_args (struct frame_info *, long,
val_long = unpack_long (type, valaddr);
/* If the value is a pointer, and pointers and addresses are not the
- same, then at this point, the value's length is TARGET_ADDR_BIT, not
- TYPE_LENGTH (type). */
+ same, then at this point, the value's length (in target bytes) is
+ TARGET_ADDR_BIT/TARGET_CHAR_BIT, not TYPE_LENGTH (type). */
if (TYPE_CODE (type) == TYPE_CODE_PTR)
- len = TARGET_ADDR_BIT;
+ len = TARGET_ADDR_BIT / TARGET_CHAR_BIT;
/* If we are printing it as unsigned, truncate it in case it is actually
a negative signed value (e.g. "print/u (short)-1" should print 65535
}
}
- /* On some targets, add in extra "flag" bits to PC for
- disassembly. This should ensure that "rounding errors" in
- symbol addresses that are masked for disassembly favour the
- the correct symbol. */
-
-#ifdef GDB_TARGET_UNMASK_DISAS_PC
- addr = GDB_TARGET_UNMASK_DISAS_PC (addr);
-#endif
-
/* First try to find the address in the symbol table, then
in the minsyms. Take the closest one. */
if (symbol == NULL && msymbol == NULL)
return 1;
- /* On some targets, mask out extra "flag" bits from PC for handsome
- disassembly. */
-
-#ifdef GDB_TARGET_MASK_DISAS_PC
- name_location = GDB_TARGET_MASK_DISAS_PC (name_location);
- addr = GDB_TARGET_MASK_DISAS_PC (addr);
-#endif
-
/* If the nearest symbol is too far away, don't print anything symbolic. */
/* For when CORE_ADDR is larger than unsigned int, we do math in
old_chain = make_cleanup (free_current_contents, &expr);
cleanup = 1;
val = evaluate_expression (expr);
-
- /* C++: figure out what type we actually want to print it as. */
- type = VALUE_TYPE (val);
-
- if (objectprint
- && (TYPE_CODE (type) == TYPE_CODE_PTR
- || TYPE_CODE (type) == TYPE_CODE_REF)
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT
- || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_UNION))
- {
- struct value *v;
-
- v = value_from_vtable_info (val, TYPE_TARGET_TYPE (type));
- if (v != 0)
- {
- val = v;
- type = VALUE_TYPE (val);
- }
- }
}
else
val = access_value_history (0);
if (exp == 0)
error ("Argument required.");
- sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE,
+ sym = lookup_symbol (exp, get_selected_block (0), VAR_NAMESPACE,
&is_a_field_of_this, (struct symtab **) NULL);
if (sym == NULL)
{
printf_filtered ("Symbol \"");
fprintf_symbol_filtered (gdb_stdout, exp,
current_language->la_language, DMGL_ANSI);
- printf_filtered ("\" is a field of the local class variable `this'\n");
+ printf_filtered ("\" is a field of the local class variable ");
+ if (current_language->la_language == language_objc)
+ printf_filtered ("`self'\n"); /* ObjC equivalent of "this" */
+ else
+ printf_filtered ("`this'\n");
return;
}
case LOC_BLOCK:
printf_filtered ("a function at address ");
-#ifdef GDB_TARGET_MASK_DISAS_PC
- print_address_numeric
- (load_addr = GDB_TARGET_MASK_DISAS_PC (BLOCK_START (SYMBOL_BLOCK_VALUE (sym))),
- 1, gdb_stdout);
-#else
print_address_numeric (load_addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
1, gdb_stdout);
-#endif
if (section_is_overlay (section))
{
load_addr = overlay_unmapped_address (load_addr, section);
}
break;
- case LOC_THREAD_LOCAL_STATIC:
+ case LOC_HP_THREAD_LOCAL_STATIC:
printf_filtered (
"a thread-local variable at offset %ld from the thread base register %s",
val, REGISTER_NAME (basereg));
break;
+ case LOC_THREAD_LOCAL_STATIC:
+ printf_filtered ("a thread-local variable at offset %ld in the "
+ "thread-local storage for `%s'",
+ val, SYMBOL_OBJFILE (sym)->name);
+ break;
+
case LOC_OPTIMIZED_OUT:
printf_filtered ("optimized out");
break;
return;
if (d->block)
- within_current_scope = contained_in (get_selected_block (), d->block);
+ within_current_scope = contained_in (get_selected_block (0), d->block);
else
within_current_scope = 1;
if (!within_current_scope)
else if (d->format.format)
printf_filtered ("/%c ", d->format.format);
print_expression (d->exp, gdb_stdout);
- if (d->block && !contained_in (get_selected_block (), d->block))
+ if (d->block && !contained_in (get_selected_block (0), d->block))
printf_filtered (" (cannot be evaluated in the current context)");
printf_filtered ("\n");
gdb_flush (gdb_stdout);
if (func)
{
b = SYMBOL_BLOCK_VALUE (func);
+ /* Function blocks are order sensitive, and thus should not be
+ hashed. */
+ gdb_assert (BLOCK_HASHTABLE (b) == 0);
+
ALL_BLOCK_SYMBOLS (b, i, sym)
{
QUIT;
}
do_cleanups (old_cleanups);
}
-\f
-/* Dump a specified section of assembly code. With no command line
- arguments, this command will dump the assembly code for the
- function surrounding the pc value in the selected frame. With one
- argument, it will dump the assembly code surrounding that pc value.
- Two arguments are interpeted as bounds within which to dump
- assembly. */
-
-/* ARGSUSED */
-static void
-disassemble_command (char *arg, int from_tty)
-{
- CORE_ADDR low, high;
- char *name;
- CORE_ADDR pc, pc_masked;
- char *space_index;
-#if 0
- asection *section;
-#endif
-
- name = NULL;
- if (!arg)
- {
- if (!selected_frame)
- error ("No frame selected.\n");
-
- pc = get_frame_pc (selected_frame);
- if (find_pc_partial_function (pc, &name, &low, &high) == 0)
- error ("No function contains program counter for selected frame.\n");
-#if defined(TUI)
- else if (tui_version)
- low = tuiGetLowDisassemblyAddress (low, pc);
-#endif
- low += FUNCTION_START_OFFSET;
- }
- else if (!(space_index = (char *) strchr (arg, ' ')))
- {
- /* One argument. */
- pc = parse_and_eval_address (arg);
- if (find_pc_partial_function (pc, &name, &low, &high) == 0)
- error ("No function contains specified address.\n");
-#if defined(TUI)
- else if (tui_version)
- low = tuiGetLowDisassemblyAddress (low, pc);
-#endif
- low += FUNCTION_START_OFFSET;
- }
- else
- {
- /* Two arguments. */
- *space_index = '\0';
- low = parse_and_eval_address (arg);
- high = parse_and_eval_address (space_index + 1);
- }
-
-#if defined(TUI)
- if (!tui_is_window_visible (DISASSEM_WIN))
-#endif
- {
- printf_filtered ("Dump of assembler code ");
- if (name != NULL)
- {
- printf_filtered ("for function %s:\n", name);
- }
- else
- {
- printf_filtered ("from ");
- print_address_numeric (low, 1, gdb_stdout);
- printf_filtered (" to ");
- print_address_numeric (high, 1, gdb_stdout);
- printf_filtered (":\n");
- }
-
- /* Dump the specified range. */
- pc = low;
-
-#ifdef GDB_TARGET_MASK_DISAS_PC
- pc_masked = GDB_TARGET_MASK_DISAS_PC (pc);
-#else
- pc_masked = pc;
-#endif
-
- while (pc_masked < high)
- {
- QUIT;
- print_address (pc_masked, gdb_stdout);
- printf_filtered (":\t");
- /* We often wrap here if there are long symbolic names. */
- wrap_here (" ");
- pc += print_insn (pc, gdb_stdout);
- printf_filtered ("\n");
-
-#ifdef GDB_TARGET_MASK_DISAS_PC
- pc_masked = GDB_TARGET_MASK_DISAS_PC (pc);
-#else
- pc_masked = pc;
-#endif
- }
- printf_filtered ("End of assembler dump.\n");
- gdb_flush (gdb_stdout);
- }
-#if defined(TUI)
- else
- {
- tui_show_assembly (low);
- }
-#endif
-}
/* Print the instruction at address MEMADDR in debugged memory,
on STREAM. Returns length of the instruction, in bytes. */
Default count is 1. Default address is following last thing printed\n\
with this command or \"print\".", NULL));
- c = add_com ("disassemble", class_vars, disassemble_command,
- "Disassemble a specified section of memory.\n\
-Default is the function surrounding the pc of the selected frame.\n\
-With a single argument, the function surrounding that address is dumped.\n\
-Two arguments are taken as a range of memory to dump.");
- set_cmd_completer (c, location_completer);
- if (xdb_commands)
- add_com_alias ("va", "disassemble", class_xdb, 0);
-
#if 0
add_com ("whereis", class_vars, whereis_command,
"Print line number and file of definition of variable.");