aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPaul N. Hilfinger <hilfinger@adacore.com>2004-09-11 10:24:53 +0000
committerPaul N. Hilfinger <hilfinger@adacore.com>2004-09-11 10:24:53 +0000
commitbb599908a8d0f463182ab1fd0abb56ea15bfd627 (patch)
treef97d2d15cede245d00ab45aaed6d82dc0555cb60 /gdb
parent52e08514abb43792800981cc211d6a0eaed25f58 (diff)
downloadgdb-bb599908a8d0f463182ab1fd0abb56ea15bfd627.zip
gdb-bb599908a8d0f463182ab1fd0abb56ea15bfd627.tar.gz
gdb-bb599908a8d0f463182ab1fd0abb56ea15bfd627.tar.bz2
* language.c (local_hex_format_custom): Remove.
(local_hex_string): Rename to hex_string, use C format, and move to utils.c (local_hex_string_custom): Rename to hex_string_custom and change interface. Now uses C format. Move to utils.c (local_octal_format_custom): Remove. (local_decimal_format_custom): Remove. (unknown_language_defn): Remove language-specific number formatting entries. (auto_language_defn): Ditto. (local_language_defn): Ditto. * language.h (struct language_format_info): Delete declaration. (struct language_defn): Remove language_format_info fields la_binary_format, la_octal_format, la_decimal_format, la_hex_format. (local_binary_format): Remove macro. (local_binary_format_prefix): Remove macro. (local_binary_format_specifier): Remove macro. (local_binary_format_suffix): Remove macro. (local_octal_format): Remove macro. (local_octal_format_prefix): Remove macro. (local_octal_format_specifier): Remove macro. (local_octal_format_suffix): Remove macro. (local_decimal_format): Remove macro. (local_decimal_format_prefix): Remove macro. (local_decimal_format_specifier): Remove macro. (local_decimal_format_suffix): Remove macro. (local_hex_format): Remove macro. (local_hex_format_prefix): Remove macro. (local_hex_format_specifier): Remove macro. (local_hex_format_suffix): Remove macro. (local_decimal_format_custom): Remove. (local_octal_format_custom): Remove. (local_hex_format_custom): Remove. (local_hex_string): Rename to hex_string and move to defs.h. (local_hex_string_custom): Rename to hex_string_custom, change interface, and move to defs.h. * utils.c: (int_string): New function. (hex_string): New function (from language.c). (hex_string_custom): New function (from language.c). (octal2str): New function. (decimal2str): Add width parameter. (paddr_u): Use new decimal2str interface. (paddr_d): Ditto. * defs.h (hex_string): Declare. (hex_string_custom): Declare. (int_string): Declare. * printcmd.c (print_scalar_formatted): Remove localized binary formatting. * valprint.c (print_longest): Use int_string. (print_floating): Use C hex format. (print_hex_chars): Ditto. (print_binary_chars): Remove language-specific formatting. (print_octal_chars): Use C octal format. (print_decimal_chars): Delocalize format. (print_decimal): Remove. * ada-lang.c (ada_language_defn): Remove language-specific number formatting entries. * p-lang.c (pascal_language_defn): Ditto. * c-lang.c (c_language_defn): Ditto. (cplus_language_defn): Ditto. (asm_language_defn): Ditto. (minimal_language_defn): Ditto. * f-lang.c (f_language_defn): Ditto. * jv-lang.c (java_language_defn): Ditto. * m2-lang.c (m2_language_defn): Ditto. * scm-lang.c (scm_language_defn): Ditto. * objc-lang.c (objc_language_defn): Ditto. * memattr.c (mem_info_command): Use renamed hex_string_custom with new interface. * pa64solib.c (pa64_sharedlibrary_info_command): Ditto. * ui-out.c (ui_out_field_core_addr): Ditto. * breakpoint.c (breakpoint_adjustment_warning): Ditto. * exec.c (print_section_info): Ditto. * i387-tdep.c (print_i387_status_word): Ditto. (print_i387_control_word): Ditto. (i387_print_float_info): Ditto. * maint.c (maint_print_section_info): Ditto. * solib.c (info_sharedlibrary_command): Ditto. * somsolib.c (som_sharedlibrary_info_command): Ditto. * symtab.c (print_msymbol_info): Ditto. * tracepoint.c (tracepoints_info): Ditto. * solib-frv.c (lm_base): Ditto. (frv_current_sos): Ditto. (enable_break2): Ditto. (enable_break): Ditto. * dbxread.c (read_dbx_symtab): Use renamed hex_string. (process_one_symbol): Ditto. * infcmd.c (program_info): Ditto. * mdebugread.c (parse_partial_symbols): Ditto. * symfile.c (add_symbol_file_command): Ditto. * cli/cli-cmds.c (edit_command): Ditto. (list_command): Ditto. * infcall.c (call_function_by_hand): Ditto. * remote-vx.c (vx_run_files_info): Ditto. (vx_wait): Ditto. (vx_attach): Ditto. (vx_detach): Ditto. (vx_kill): Ditto. * aix-thread.c (pdc_symbol_addrs): Ditto. (pdc_read_regs): Ditto. (pdc_write_regs): Ditto. (pdc_read_data): Ditto. (pdc_write_data): Ditto. * d10v-tdep.c (display_trace): Ditto. * rs6000-nat.c (find_toc_address): Ditto. * aix-thread.c: Don't include language.h. * buildsym.c: Ditto. * dbxread.c: Ditto. * mdebugread.c: Ditto. * rs6000-nat.c: Ditto. * buildsym.c (make_blockvector): Use renamed hex_string.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog114
-rw-r--r--gdb/ada-lang.c5
-rw-r--r--gdb/aix-thread.c11
-rw-r--r--gdb/breakpoint.c4
-rw-r--r--gdb/buildsym.c3
-rw-r--r--gdb/c-lang.c16
-rw-r--r--gdb/cli/cli-cmds.c4
-rw-r--r--gdb/d10v-tdep.c2
-rw-r--r--gdb/dbxread.c5
-rw-r--r--gdb/defs.h1
-rw-r--r--gdb/exec.c10
-rw-r--r--gdb/f-lang.c4
-rw-r--r--gdb/i387-tdep.c16
-rw-r--r--gdb/infcall.c2
-rw-r--r--gdb/infcmd.c2
-rw-r--r--gdb/jv-lang.c4
-rw-r--r--gdb/language.c145
-rw-r--r--gdb/language.h107
-rw-r--r--gdb/m2-lang.c4
-rw-r--r--gdb/maint.c2
-rw-r--r--gdb/mdebugread.c3
-rw-r--r--gdb/memattr.c8
-rw-r--r--gdb/objc-lang.c4
-rw-r--r--gdb/p-lang.c4
-rw-r--r--gdb/pa64solib.c19
-rw-r--r--gdb/printcmd.c4
-rw-r--r--gdb/remote-vx.c11
-rw-r--r--gdb/rs6000-nat.c3
-rw-r--r--gdb/scm-lang.c4
-rw-r--r--gdb/solib-frv.c25
-rw-r--r--gdb/solib.c19
-rw-r--r--gdb/somsolib.c12
-rw-r--r--gdb/symfile.c5
-rw-r--r--gdb/symtab.c10
-rw-r--r--gdb/tracepoint.c7
-rw-r--r--gdb/ui-out.c4
-rw-r--r--gdb/utils.c104
-rw-r--r--gdb/valprint.c223
38 files changed, 357 insertions, 573 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b88ed40..c7ffc7f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,117 @@
+2004-09-11 Paul N. Hilfinger <hilfinger@gnat.com>
+
+ * language.c (local_hex_format_custom): Remove.
+ (local_hex_string): Rename to hex_string, use C format, and move to
+ utils.c
+ (local_hex_string_custom): Rename to hex_string_custom and change
+ interface. Now uses C format. Move to utils.c
+ (local_octal_format_custom): Remove.
+ (local_decimal_format_custom): Remove.
+ (unknown_language_defn): Remove language-specific number
+ formatting entries.
+ (auto_language_defn): Ditto.
+ (local_language_defn): Ditto.
+ * language.h (struct language_format_info): Delete declaration.
+ (struct language_defn): Remove language_format_info fields
+ la_binary_format, la_octal_format, la_decimal_format, la_hex_format.
+ (local_binary_format): Remove macro.
+ (local_binary_format_prefix): Remove macro.
+ (local_binary_format_specifier): Remove macro.
+ (local_binary_format_suffix): Remove macro.
+ (local_octal_format): Remove macro.
+ (local_octal_format_prefix): Remove macro.
+ (local_octal_format_specifier): Remove macro.
+ (local_octal_format_suffix): Remove macro.
+ (local_decimal_format): Remove macro.
+ (local_decimal_format_prefix): Remove macro.
+ (local_decimal_format_specifier): Remove macro.
+ (local_decimal_format_suffix): Remove macro.
+ (local_hex_format): Remove macro.
+ (local_hex_format_prefix): Remove macro.
+ (local_hex_format_specifier): Remove macro.
+ (local_hex_format_suffix): Remove macro.
+ (local_decimal_format_custom): Remove.
+ (local_octal_format_custom): Remove.
+ (local_hex_format_custom): Remove.
+ (local_hex_string): Rename to hex_string and move to defs.h.
+ (local_hex_string_custom): Rename to hex_string_custom, change
+ interface, and move to defs.h.
+ * utils.c: (int_string): New function.
+ (hex_string): New function (from language.c).
+ (hex_string_custom): New function (from language.c).
+ (octal2str): New function.
+ (decimal2str): Add width parameter.
+ (paddr_u): Use new decimal2str interface.
+ (paddr_d): Ditto.
+ * defs.h (hex_string): Declare.
+ (hex_string_custom): Declare.
+ (int_string): Declare.
+ * printcmd.c (print_scalar_formatted): Remove localized binary
+ formatting.
+ * valprint.c (print_longest): Use int_string.
+ (print_floating): Use C hex format.
+ (print_hex_chars): Ditto.
+ (print_binary_chars): Remove language-specific formatting.
+ (print_octal_chars): Use C octal format.
+ (print_decimal_chars): Delocalize format.
+ (print_decimal): Remove.
+ * ada-lang.c (ada_language_defn): Remove language-specific number
+ formatting entries.
+ * p-lang.c (pascal_language_defn): Ditto.
+ * c-lang.c (c_language_defn): Ditto.
+ (cplus_language_defn): Ditto.
+ (asm_language_defn): Ditto.
+ (minimal_language_defn): Ditto.
+ * f-lang.c (f_language_defn): Ditto.
+ * jv-lang.c (java_language_defn): Ditto.
+ * m2-lang.c (m2_language_defn): Ditto.
+ * scm-lang.c (scm_language_defn): Ditto.
+ * objc-lang.c (objc_language_defn): Ditto.
+ * memattr.c (mem_info_command): Use renamed hex_string_custom with
+ new interface.
+ * pa64solib.c (pa64_sharedlibrary_info_command): Ditto.
+ * ui-out.c (ui_out_field_core_addr): Ditto.
+ * breakpoint.c (breakpoint_adjustment_warning): Ditto.
+ * exec.c (print_section_info): Ditto.
+ * i387-tdep.c (print_i387_status_word): Ditto.
+ (print_i387_control_word): Ditto.
+ (i387_print_float_info): Ditto.
+ * maint.c (maint_print_section_info): Ditto.
+ * solib.c (info_sharedlibrary_command): Ditto.
+ * somsolib.c (som_sharedlibrary_info_command): Ditto.
+ * symtab.c (print_msymbol_info): Ditto.
+ * tracepoint.c (tracepoints_info): Ditto.
+ * solib-frv.c (lm_base): Ditto.
+ (frv_current_sos): Ditto.
+ (enable_break2): Ditto.
+ (enable_break): Ditto.
+ * dbxread.c (read_dbx_symtab): Use renamed hex_string.
+ (process_one_symbol): Ditto.
+ * infcmd.c (program_info): Ditto.
+ * mdebugread.c (parse_partial_symbols): Ditto.
+ * symfile.c (add_symbol_file_command): Ditto.
+ * cli/cli-cmds.c (edit_command): Ditto.
+ (list_command): Ditto.
+ * infcall.c (call_function_by_hand): Ditto.
+ * remote-vx.c (vx_run_files_info): Ditto.
+ (vx_wait): Ditto.
+ (vx_attach): Ditto.
+ (vx_detach): Ditto.
+ (vx_kill): Ditto.
+ * aix-thread.c (pdc_symbol_addrs): Ditto.
+ (pdc_read_regs): Ditto.
+ (pdc_write_regs): Ditto.
+ (pdc_read_data): Ditto.
+ (pdc_write_data): Ditto.
+ * d10v-tdep.c (display_trace): Ditto.
+ * rs6000-nat.c (find_toc_address): Ditto.
+ * aix-thread.c: Don't include language.h.
+ * buildsym.c: Ditto.
+ * dbxread.c: Ditto.
+ * mdebugread.c: Ditto.
+ * rs6000-nat.c: Ditto.
+ * buildsym.c (make_blockvector): Use renamed hex_string.
+
2004-09-10 Jason Molenda (jmolenda@apple.com)
* cli/cli-script.c (read_next_line): Accept zero or more whitespace
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index fd73fc5..51c5fb7 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10184,11 +10184,6 @@ const struct language_defn ada_language_defn = {
basic_lookup_transparent_type, /* lookup_transparent_type */
ada_la_decode, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- /* Copied from c-lang.c. */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
ada_op_print_tab, /* expression operators for printing */
0, /* c-style arrays */
1, /* String lower bound */
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 4e5a411..11a4471 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -48,7 +48,6 @@
#include "inferior.h"
#include "regcache.h"
#include "gdbcmd.h"
-#include "language.h" /* for local_hex_string() */
#include "ppc-tdep.h"
#include "gdb_string.h"
@@ -314,7 +313,7 @@ pdc_symbol_addrs (pthdb_user_t user, pthdb_symbol_t *symbols, int count)
}
if (debug_aix_thread)
fprintf_unfiltered (gdb_stdlog, " symbols[%d].addr = %s\n",
- i, local_hex_string (symbols[i].addr));
+ i, hex_string (symbols[i].addr));
}
if (debug_aix_thread)
fprintf_unfiltered (gdb_stdlog, " returning PDC_SUCCESS\n");
@@ -347,7 +346,7 @@ pdc_read_regs (pthdb_user_t user,
if (debug_aix_thread)
fprintf_unfiltered (gdb_stdlog, "pdc_read_regs tid=%d flags=%s\n",
- (int) tid, local_hex_string (flags));
+ (int) tid, hex_string (flags));
/* General-purpose registers. */
if (flags & PTHDB_FLAG_GPRS)
@@ -413,7 +412,7 @@ pdc_write_regs (pthdb_user_t user,
if (debug_aix_thread)
fprintf_unfiltered (gdb_stdlog, "pdc_write_regs tid=%d flags=%s\n",
- (int) tid, local_hex_string (flags));
+ (int) tid, hex_string (flags));
/* General-purpose registers. */
if (flags & PTHDB_FLAG_GPRS)
@@ -458,7 +457,7 @@ pdc_read_data (pthdb_user_t user, void *buf,
if (debug_aix_thread)
fprintf_unfiltered (gdb_stdlog,
"pdc_read_data (user = %ld, buf = 0x%lx, addr = %s, len = %ld)\n",
- user, (long) buf, local_hex_string (addr), len);
+ user, (long) buf, hex_string (addr), len);
status = target_read_memory (addr, buf, len);
ret = status == 0 ? PDC_SUCCESS : PDC_FAILURE;
@@ -480,7 +479,7 @@ pdc_write_data (pthdb_user_t user, void *buf,
if (debug_aix_thread)
fprintf_unfiltered (gdb_stdlog,
"pdc_write_data (user = %ld, buf = 0x%lx, addr = %s, len = %ld)\n",
- user, (long) buf, local_hex_string (addr), len);
+ user, (long) buf, hex_string (addr), len);
status = target_write_memory (addr, buf, len);
ret = status == 0 ? PDC_SUCCESS : PDC_FAILURE;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index dae098d..c5e8ddd 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3925,8 +3925,8 @@ breakpoint_adjustment_warning (CORE_ADDR from_addr, CORE_ADDR to_addr,
char astr1[40];
char astr2[40];
- strcpy (astr1, local_hex_string_custom ((unsigned long) from_addr, "08l"));
- strcpy (astr2, local_hex_string_custom ((unsigned long) to_addr, "08l"));
+ strcpy (astr1, hex_string_custom ((unsigned long) from_addr, 8));
+ strcpy (astr2, hex_string_custom ((unsigned long) to_addr, 8));
if (have_bnum)
warning ("Breakpoint %d address previously adjusted from %s to %s.",
bnum, astr1, astr2);
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 4b362e0..d1ec78e 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -38,7 +38,6 @@
#include "complaints.h"
#include "gdb_string.h"
#include "expression.h" /* For "enum exp_opcode" used by... */
-#include "language.h" /* For "local_hex_string" */
#include "bcache.h"
#include "filenames.h" /* For DOSish file names */
#include "macrotab.h"
@@ -521,7 +520,7 @@ make_blockvector (struct objfile *objfile)
= BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i));
complaint (&symfile_complaints, "block at %s out of order",
- local_hex_string ((LONGEST) start));
+ hex_string ((LONGEST) start));
}
}
}
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index ad8fa5c..c7eb918 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -588,10 +588,6 @@ const struct language_defn c_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
@@ -650,10 +646,6 @@ const struct language_defn cplus_language_defn =
cp_lookup_transparent_type, /* lookup_transparent_type */
cplus_demangle, /* Language specific symbol demangler */
cp_class_name_from_physname, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
@@ -689,10 +681,6 @@ const struct language_defn asm_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
@@ -733,10 +721,6 @@ const struct language_defn minimal_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index ffb2cd8..fbe93c9 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -600,7 +600,7 @@ edit_command (char *arg, int from_tty)
if (sal.symtab == 0)
/* FIXME-32x64--assumes sal.pc fits in long. */
error ("No source file for address %s.",
- local_hex_string((unsigned long) sal.pc));
+ hex_string ((unsigned long) sal.pc));
sym = find_pc_function (sal.pc);
if (sym)
{
@@ -767,7 +767,7 @@ list_command (char *arg, int from_tty)
if (sal.symtab == 0)
/* FIXME-32x64--assumes sal.pc fits in long. */
error ("No source file for address %s.",
- local_hex_string ((unsigned long) sal.pc));
+ hex_string ((unsigned long) sal.pc));
sym = find_pc_function (sal.pc);
if (sym)
{
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index ea44721..b0da9be 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -1313,7 +1313,7 @@ display_trace (int low, int high)
if (!suppress)
/* FIXME-32x64--assumes sal.pc fits in long. */
printf_filtered ("No source file for address %s.\n",
- local_hex_string ((unsigned long) sal.pc));
+ hex_string ((unsigned long) sal.pc));
suppress = 1;
}
}
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 5436d4a..32db167 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -54,7 +54,6 @@
#include "stabsread.h"
#include "gdb-stabs.h"
#include "demangle.h"
-#include "language.h" /* Needed for local_hex_string */
#include "complaints.h"
#include "cp-abi.h"
#include "gdb_assert.h"
@@ -2097,7 +2096,7 @@ read_dbx_symtab (struct objfile *objfile)
default:
/* If we haven't found it yet, ignore it. It's probably some
new type we don't know about yet. */
- unknown_symtype_complaint (local_hex_string (nlist.n_type));
+ unknown_symtype_complaint (hex_string (nlist.n_type));
continue;
}
}
@@ -3038,7 +3037,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
case N_NBBSS:
case N_NBSTS:
case N_NBLCS:
- unknown_symtype_complaint (local_hex_string (type));
+ unknown_symtype_complaint (hex_string (type));
/* FALLTHROUGH */
/* The following symbol types don't need the address field relocated,
diff --git a/gdb/defs.h b/gdb/defs.h
index 1be691d..ff5a4d5 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -515,6 +515,7 @@ extern char *paddr_d (LONGEST addr);
extern char *phex (ULONGEST l, int sizeof_l);
extern char *phex_nz (ULONGEST l, int sizeof_l);
+extern char *int_string (LONGEST, int, int, int, int);
/* Like paddr() only print/scan raw CORE_ADDR. The output from
core_addr_to_string() can be passed direct to
diff --git a/gdb/exec.c b/gdb/exec.c
index 4ff345a..7eaa15a 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -522,8 +522,8 @@ void
print_section_info (struct target_ops *t, bfd *abfd)
{
struct section_table *p;
- /* FIXME: "016l" is not wide enough when TARGET_ADDR_BIT > 64. */
- char *fmt = TARGET_ADDR_BIT <= 32 ? "08l" : "016l";
+ /* FIXME: 16 is not wide enough when TARGET_ADDR_BIT > 64. */
+ int wid = TARGET_ADDR_BIT <= 32 ? 8 : 16;
printf_filtered ("\t`%s', ", bfd_get_filename (abfd));
wrap_here (" ");
@@ -536,8 +536,8 @@ print_section_info (struct target_ops *t, bfd *abfd)
}
for (p = t->to_sections; p < t->to_sections_end; p++)
{
- printf_filtered ("\t%s", local_hex_string_custom (p->addr, fmt));
- printf_filtered (" - %s", local_hex_string_custom (p->endaddr, fmt));
+ printf_filtered ("\t%s", hex_string_custom (p->addr, wid));
+ printf_filtered (" - %s", hex_string_custom (p->endaddr, wid));
/* FIXME: A format of "08l" is not wide enough for file offsets
larger than 4GB. OTOH, making it "016l" isn't desirable either
@@ -546,7 +546,7 @@ print_section_info (struct target_ops *t, bfd *abfd)
format string accordingly. */
if (info_verbose)
printf_filtered (" @ %s",
- local_hex_string_custom (p->the_bfd_section->filepos, "08l"));
+ hex_string_custom (p->the_bfd_section->filepos, 8));
printf_filtered (" is %s", bfd_section_name (p->bfd, p->the_bfd_section));
if (p->bfd != abfd)
{
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 8430c97..e058dd4 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -480,10 +480,6 @@ const struct language_defn f_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%o", "0", "o", ""}, /* Octal format info */
- {"%d", "", "d", ""}, /* Decimal format info */
- {"0x%x", "0x", "x", ""}, /* Hex format info */
f_op_print_tab, /* expression operators for printing */
0, /* arrays are first-class (not c-style) */
1, /* String lower bound */
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 003818c..04b43df 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -121,7 +121,7 @@ static void
print_i387_status_word (unsigned int status, struct ui_file *file)
{
fprintf_filtered (file, "Status Word: %s",
- local_hex_string_custom (status, "04"));
+ hex_string_custom (status, 4));
fputs_filtered (" ", file);
fprintf_filtered (file, " %s", (status & 0x0001) ? "IE" : " ");
fprintf_filtered (file, " %s", (status & 0x0002) ? "DE" : " ");
@@ -151,7 +151,7 @@ static void
print_i387_control_word (unsigned int control, struct ui_file *file)
{
fprintf_filtered (file, "Control Word: %s",
- local_hex_string_custom (control, "04"));
+ hex_string_custom (control, 4));
fputs_filtered (" ", file);
fprintf_filtered (file, " %s", (control & 0x0001) ? "IM" : " ");
fprintf_filtered (file, " %s", (control & 0x0002) ? "DM" : " ");
@@ -276,15 +276,15 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
print_i387_status_word (fstat, file);
print_i387_control_word (fctrl, file);
fprintf_filtered (file, "Tag Word: %s\n",
- local_hex_string_custom (ftag, "04"));
+ hex_string_custom (ftag, 4));
fprintf_filtered (file, "Instruction Pointer: %s:",
- local_hex_string_custom (fiseg, "02"));
- fprintf_filtered (file, "%s\n", local_hex_string_custom (fioff, "08"));
+ hex_string_custom (fiseg, 2));
+ fprintf_filtered (file, "%s\n", hex_string_custom (fioff, 8));
fprintf_filtered (file, "Operand Pointer: %s:",
- local_hex_string_custom (foseg, "02"));
- fprintf_filtered (file, "%s\n", local_hex_string_custom (fooff, "08"));
+ hex_string_custom (foseg, 2));
+ fprintf_filtered (file, "%s\n", hex_string_custom (fooff, 8));
fprintf_filtered (file, "Opcode: %s\n",
- local_hex_string_custom (fop ? (fop | 0xd800) : 0, "04"));
+ hex_string_custom (fop ? (fop | 0xd800) : 0, 4));
#undef I387_ST0_REGNUM
}
diff --git a/gdb/infcall.c b/gdb/infcall.c
index ade9943..53bcffd 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -746,7 +746,7 @@ You must use a pointer to function type variable. Command ignored.", arg_name);
{
/* Can't use a cleanup here. It is discarded, instead use
an alloca. */
- char *tmp = xstrprintf ("at %s", local_hex_string (funaddr));
+ char *tmp = xstrprintf ("at %s", hex_string (funaddr));
char *a = alloca (strlen (tmp) + 1);
strcpy (a, tmp);
xfree (tmp);
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index b0d233e..839a94c 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1317,7 +1317,7 @@ program_info (char *args, int from_tty)
target_files_info ();
printf_filtered ("Program stopped at %s.\n",
- local_hex_string ((unsigned long) stop_pc));
+ hex_string ((unsigned long) stop_pc));
if (stop_step)
printf_filtered ("It stopped after being stepped.\n");
else if (num != 0)
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index fd0e712..4b7cf28 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1106,10 +1106,6 @@ const struct language_defn java_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
java_demangle, /* Language specific symbol demangler */
java_class_name_from_physname,/* Language specific class name */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
java_op_print_tab, /* expression operators for printing */
0, /* not c-style arrays */
0, /* String lower bound */
diff --git a/gdb/language.c b/gdb/language.c
index dfbfa3a..4c59b28 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -583,124 +583,41 @@ binop_result_type (struct value *v1, struct value *v2)
/* This page contains functions that return format strings for
printf for printing out numbers in different formats */
-/* Returns the appropriate printf format for hexadecimal
- numbers. */
-char *
-local_hex_format_custom (char *pre)
-{
- static char form[50];
-
- strcpy (form, local_hex_format_prefix ());
- strcat (form, "%");
- strcat (form, pre);
- strcat (form, local_hex_format_specifier ());
- strcat (form, local_hex_format_suffix ());
- return form;
-}
+#define MAX_NUM_STRING_LEN 50
-/* Converts a LONGEST to custom hexadecimal and stores it in a static
- string. Returns a pointer to this string. */
+/* Converts a LONGEST to a C-format hexadecimal literal and stores it in
+ a static string. Returns a pointer to this string. */
char *
-local_hex_string (LONGEST num)
+hex_string (LONGEST num)
{
- return local_hex_string_custom (num, "l");
+ static char result[MAX_NUM_STRING_LEN];
+ sprintf (result, "0x%s", phex_nz (num, sizeof (num)));
+ return result;
}
-/* Converts a LONGEST number to custom hexadecimal and stores it in a static
- string. Returns a pointer to this string. Note that the width parameter
- should end with "l", e.g. "08l" as with calls to local_hex_string_custom */
+/* Converts a LONGEST number to a C-format hexadecimal literal and stores
+ it in a static string. Returns a pointer to this string that is
+ valid until the next call. The number is padded on the left with
+ 0s to at least WIDTH characters. */
char *
-local_hex_string_custom (LONGEST num, char *width)
-{
-#define RESULT_BUF_LEN 50
- static char res2[RESULT_BUF_LEN];
- char format[RESULT_BUF_LEN];
- int field_width;
- int num_len;
- int num_pad_chars;
- char *pad_char; /* string with one character */
- int pad_on_left;
- char *parse_ptr;
- char temp_nbr_buf[RESULT_BUF_LEN];
-
- /* Use phex_nz to print the number into a string, then
- build the result string from local_hex_format_prefix, padding and
- the hex representation as indicated by "width". */
- strcpy (temp_nbr_buf, phex_nz (num, sizeof (num)));
- /* parse width */
- parse_ptr = width;
- pad_on_left = 1;
- pad_char = " ";
- if (*parse_ptr == '-')
- {
- parse_ptr++;
- pad_on_left = 0;
- }
- if (*parse_ptr == '0')
- {
- parse_ptr++;
- if (pad_on_left)
- pad_char = "0"; /* If padding is on the right, it is blank */
- }
- field_width = atoi (parse_ptr);
- num_len = strlen (temp_nbr_buf);
- num_pad_chars = field_width - strlen (temp_nbr_buf); /* possibly negative */
-
- if (strlen (local_hex_format_prefix ()) + num_len + num_pad_chars
- >= RESULT_BUF_LEN) /* paranoia */
- internal_error (__FILE__, __LINE__,
- "local_hex_string_custom: insufficient space to store result");
-
- strcpy (res2, local_hex_format_prefix ());
- if (pad_on_left)
- {
- while (num_pad_chars > 0)
- {
- strcat (res2, pad_char);
- num_pad_chars--;
- }
- }
- strcat (res2, temp_nbr_buf);
- if (!pad_on_left)
- {
- while (num_pad_chars > 0)
- {
- strcat (res2, pad_char);
- num_pad_chars--;
- }
- }
- return res2;
-
-} /* local_hex_string_custom */
-
-/* Returns the appropriate printf format for octal
- numbers. */
-char *
-local_octal_format_custom (char *pre)
+hex_string_custom (LONGEST num, int width)
{
- static char form[50];
-
- strcpy (form, local_octal_format_prefix ());
- strcat (form, "%");
- strcat (form, pre);
- strcat (form, local_octal_format_specifier ());
- strcat (form, local_octal_format_suffix ());
- return form;
-}
+ static char result[MAX_NUM_STRING_LEN];
+ char *result_end = result + MAX_NUM_STRING_LEN - 1;
+ const char* hex = phex_nz (num, sizeof (num));
+ int hex_len = strlen (hex);
-/* Returns the appropriate printf format for decimal numbers. */
-char *
-local_decimal_format_custom (char *pre)
-{
- static char form[50];
+ if (hex_len > width)
+ width = hex_len;
+ if (width + 2 >= MAX_NUM_STRING_LEN)
+ internal_error (__FILE__, __LINE__,
+ "hex_string_custom: insufficient space to store result");
- strcpy (form, local_decimal_format_prefix ());
- strcat (form, "%");
- strcat (form, pre);
- strcat (form, local_decimal_format_specifier ());
- strcat (form, local_decimal_format_suffix ());
- return form;
+ strcpy (result_end - width - 2, "0x");
+ memset (result_end - width, '0', width);
+ strcpy (result_end - hex_len, hex);
+ return result_end - width - 2;
}
#if 0
@@ -1313,10 +1230,6 @@ const struct language_defn unknown_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
unk_lang_class_name, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
unk_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
@@ -1353,10 +1266,6 @@ const struct language_defn auto_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
unk_lang_class_name, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
unk_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
@@ -1392,10 +1301,6 @@ const struct language_defn local_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
unk_lang_demangle, /* Language specific symbol demangler */
unk_lang_class_name, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
unk_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
diff --git a/gdb/language.h b/gdb/language.h
index 98bdc3e..33f5fd3 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -117,37 +117,6 @@ extern enum case_sensitivity
}
case_sensitivity;
-/* Information for doing language dependent formatting of printed values. */
-
-struct language_format_info
- {
- /* The format that can be passed directly to standard C printf functions
- to generate a completely formatted value in the format appropriate for
- the language. */
-
- char *la_format;
-
- /* The prefix to be used when directly printing a value, or constructing
- a standard C printf format. This generally is everything up to the
- conversion specification (the part introduced by the '%' character
- and terminated by the conversion specifier character). */
-
- char *la_format_prefix;
-
- /* The conversion specifier. This is generally everything after the
- field width and precision, typically only a single character such
- as 'o' for octal format or 'x' for hexadecimal format. */
-
- char *la_format_specifier;
-
- /* The suffix to be used when directly printing a value, or constructing
- a standard C printf format. This generally is everything after the
- conversion specification (the part introduced by the '%' character
- and terminated by the conversion specifier character). */
-
- char *la_format_suffix; /* Suffix for custom format string */
- };
-
/* Per architecture (OS/ABI) language information. */
struct language_arch_info
@@ -284,22 +253,6 @@ struct language_defn
/* Return class name of a mangled method name or NULL. */
char *(*la_class_name_from_physname) (const char *physname);
- /* Base 2 (binary) formats. */
-
- struct language_format_info la_binary_format;
-
- /* Base 8 (octal) formats. */
-
- struct language_format_info la_octal_format;
-
- /* Base 10 (decimal) formats */
-
- struct language_format_info la_decimal_format;
-
- /* Base 16 (hexadecimal) formats */
-
- struct language_format_info la_hex_format;
-
/* Table for printing expressions */
const struct op_print *la_op_print_tab;
@@ -402,47 +355,6 @@ extern enum language set_language (enum language);
#define LA_VALUE_PRINT(val,stream,fmt,pretty) \
(current_language->la_value_print(val,stream,fmt,pretty))
-/* Return a format string for printf that will print a number in one of
- the local (language-specific) formats. Result is static and is
- overwritten by the next call. Takes printf options like "08" or "l"
- (to produce e.g. %08x or %lx). */
-
-#define local_binary_format() \
- (current_language->la_binary_format.la_format)
-#define local_binary_format_prefix() \
- (current_language->la_binary_format.la_format_prefix)
-#define local_binary_format_specifier() \
- (current_language->la_binary_format.la_format_specifier)
-#define local_binary_format_suffix() \
- (current_language->la_binary_format.la_format_suffix)
-
-#define local_octal_format() \
- (current_language->la_octal_format.la_format)
-#define local_octal_format_prefix() \
- (current_language->la_octal_format.la_format_prefix)
-#define local_octal_format_specifier() \
- (current_language->la_octal_format.la_format_specifier)
-#define local_octal_format_suffix() \
- (current_language->la_octal_format.la_format_suffix)
-
-#define local_decimal_format() \
- (current_language->la_decimal_format.la_format)
-#define local_decimal_format_prefix() \
- (current_language->la_decimal_format.la_format_prefix)
-#define local_decimal_format_specifier() \
- (current_language->la_decimal_format.la_format_specifier)
-#define local_decimal_format_suffix() \
- (current_language->la_decimal_format.la_format_suffix)
-
-#define local_hex_format() \
- (current_language->la_hex_format.la_format)
-#define local_hex_format_prefix() \
- (current_language->la_hex_format.la_format_prefix)
-#define local_hex_format_specifier() \
- (current_language->la_hex_format.la_format_specifier)
-#define local_hex_format_suffix() \
- (current_language->la_hex_format.la_format_suffix)
-
#define LA_PRINT_CHAR(ch, stream) \
(current_language->la_printchar(ch, stream))
#define LA_PRINT_STRING(stream, string, length, width, force_ellipses) \
@@ -461,17 +373,6 @@ extern enum language set_language (enum language);
&& ((c) < 0x7F || (c) >= 0xA0) \
&& (!sevenbit_strings || (c) < 0x80))
-/* Return a format string for printf that will print a number in one of
- the local (language-specific) formats. Result is static and is
- overwritten by the next call. Takes printf options like "08" or "l"
- (to produce e.g. %08x or %lx). */
-
-extern char *local_decimal_format_custom (char *); /* language.c */
-
-extern char *local_octal_format_custom (char *); /* language.c */
-
-extern char *local_hex_format_custom (char *); /* language.c */
-
#if 0
/* FIXME: cagney/2000-03-04: This function does not appear to be used.
It can be deleted once 5.0 has been released. */
@@ -481,13 +382,11 @@ extern char *local_hex_format_custom (char *); /* language.c */
extern char *longest_raw_hex_string (LONGEST);
#endif
-/* Return a string that contains a number formatted in one of the local
- (language-specific) formats. Result is static and is overwritten by
- the next call. Takes printf options like "08l" or "l". */
+/* Return a string that contains a number formatted as a hex string */
-extern char *local_hex_string (LONGEST); /* language.c */
+extern char *hex_string (LONGEST); /* language.c */
-extern char *local_hex_string_custom (LONGEST, char *); /* language.c */
+extern char *hex_string_custom (LONGEST, int); /* language.c */
/* Type predicates */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 746b2f4..fbb1fa3 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -433,10 +433,6 @@ const struct language_defn m2_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"%loB", "", "o", "B"}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0%lXH", "0", "X", "H"}, /* Hex format info */
m2_op_print_tab, /* expression operators for printing */
0, /* arrays are first-class (not c-style) */
0, /* String lower bound */
diff --git a/gdb/maint.c b/gdb/maint.c
index 638c1f8..0ee3533 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -308,7 +308,7 @@ maint_print_section_info (const char *name, flagword flags,
printf_filtered (" 0x%s", paddr (addr));
printf_filtered ("->0x%s", paddr (endaddr));
printf_filtered (" at %s",
- local_hex_string_custom ((unsigned long) filepos, "08l"));
+ hex_string_custom ((unsigned long) filepos, 8));
printf_filtered (": %s", name);
print_bfd_flags (flags);
printf_filtered ("\n");
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 5207b7e..e4a51c2 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -88,7 +88,6 @@ typedef struct mips_extra_func_info
#include "aout/stab_gnu.h" /* STABS information */
#include "expression.h"
-#include "language.h" /* For local_hex_string() */
extern void _initialize_mdebugread (void);
@@ -3266,7 +3265,7 @@ parse_partial_symbols (struct objfile *objfile)
/* If we haven't found it yet, ignore it. It's probably some
new type we don't know about yet. */
complaint (&symfile_complaints, "unknown symbol type %s",
- local_hex_string (type_code)); /*CUR_SYMBOL_TYPE*/
+ hex_string (type_code)); /*CUR_SYMBOL_TYPE*/
continue;
}
if (stabstring
diff --git a/gdb/memattr.c b/gdb/memattr.c
index 4ab5dbf..6f95e5c 100644
--- a/gdb/memattr.c
+++ b/gdb/memattr.c
@@ -240,9 +240,9 @@ mem_info_command (char *args, int from_tty)
m->number,
m->enabled_p ? 'y' : 'n');
if (TARGET_ADDR_BIT <= 32)
- tmp = local_hex_string_custom ((unsigned long) m->lo, "08l");
+ tmp = hex_string_custom ((unsigned long) m->lo, 8);
else
- tmp = local_hex_string_custom ((unsigned long) m->lo, "016l");
+ tmp = hex_string_custom ((unsigned long) m->lo, 16);
printf_filtered ("%s ", tmp);
@@ -251,14 +251,14 @@ mem_info_command (char *args, int from_tty)
if (m->hi == 0)
tmp = "0x100000000";
else
- tmp = local_hex_string_custom ((unsigned long) m->hi, "08l");
+ tmp = hex_string_custom ((unsigned long) m->hi, 8);
}
else
{
if (m->hi == 0)
tmp = "0x10000000000000000";
else
- tmp = local_hex_string_custom ((unsigned long) m->hi, "016l");
+ tmp = hex_string_custom ((unsigned long) m->hi, 16);
}
printf_filtered ("%s ", tmp);
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index b02af1c..14c71bc 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -677,10 +677,6 @@ const struct language_defn objc_language_defn = {
basic_lookup_transparent_type,/* lookup_transparent_type */
objc_demangle, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"0x%lx", "0x", "x", ""}, /* Hex format info */
objc_op_print_tab, /* Expression operators for printing */
1, /* C-style arrays */
0, /* String lower bound */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 296a0ba..f7c49df 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -469,10 +469,6 @@ const struct language_defn pascal_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "%", "b", ""}, /* Binary format info */
- {"0%lo", "0", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"$%lx", "$", "x", ""}, /* Hex format info */
pascal_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
diff --git a/gdb/pa64solib.c b/gdb/pa64solib.c
index 35d5559..076d6cb 100644
--- a/gdb/pa64solib.c
+++ b/gdb/pa64solib.c
@@ -796,23 +796,18 @@ pa64_sharedlibrary_info_command (char *ignore, int from_tty)
if (so_list->loaded == 0)
printf_unfiltered (" (shared library unloaded)");
printf_unfiltered (" %-18s",
- local_hex_string_custom (so_list->pa64_solib_desc.linkage_ptr,
- "016l"));
+ hex_string_custom (so_list->pa64_solib_desc.linkage_ptr, 16));
printf_unfiltered ("\n");
printf_unfiltered ("%-18s",
- local_hex_string_custom (so_list->pa64_solib_desc.text_base,
- "016l"));
+ hex_string_custom (so_list->pa64_solib_desc.text_base, 16));
printf_unfiltered (" %-18s",
- local_hex_string_custom ((so_list->pa64_solib_desc.text_base
- + so_list->pa64_solib_desc.text_size),
- "016l"));
+ hex_string_custom ((so_list->pa64_solib_desc.text_base
+ + so_list->pa64_solib_desc.text_size), 16));
printf_unfiltered (" %-18s",
- local_hex_string_custom (so_list->pa64_solib_desc.data_base,
- "016l"));
+ hex_string_custom (so_list->pa64_solib_desc.data_base, 16));
printf_unfiltered (" %-18s\n",
- local_hex_string_custom ((so_list->pa64_solib_desc.data_base
- + so_list->pa64_solib_desc.data_size),
- "016l"));
+ hex_string_custom ((so_list->pa64_solib_desc.data_base
+ + so_list->pa64_solib_desc.data_size), 16));
so_list = so_list->next;
}
}
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index c167cc4..8b7d31d 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -499,9 +499,7 @@ print_scalar_formatted (void *valaddr, struct type *type, int format, int size,
if (*cp == '\0')
cp--;
}
- strcpy (buf, local_binary_format_prefix ());
- strcat (buf, cp);
- strcat (buf, local_binary_format_suffix ());
+ strcpy (buf, cp);
fputs_filtered (buf, stream);
}
break;
diff --git a/gdb/remote-vx.c b/gdb/remote-vx.c
index 7f4ed0f..de5cc03 100644
--- a/gdb/remote-vx.c
+++ b/gdb/remote-vx.c
@@ -566,7 +566,7 @@ vx_run_files_info (void)
{
printf_unfiltered ("\tRunning %s VxWorks process %s",
vx_running ? "child" : "attached",
- local_hex_string (PIDGET (inferior_ptid)));
+ hex_string (PIDGET (inferior_ptid)));
if (vx_running)
printf_unfiltered (", function `%s'", vx_running);
printf_unfiltered (".\n");
@@ -972,7 +972,7 @@ vx_wait (ptid_t ptid_to_wait_for, struct target_waitstatus *status)
else if (pid != PIDGET (inferior_ptid))
internal_error (__FILE__, __LINE__,
"Bad pid for debugged task: %s\n",
- local_hex_string ((unsigned long) pid));
+ hex_string ((unsigned long) pid));
}
while (pid == 0);
@@ -1183,7 +1183,7 @@ vx_attach (char *args, int from_tty)
if (from_tty)
printf_unfiltered ("Attaching pid %s.\n",
- local_hex_string ((unsigned long) pid));
+ hex_string ((unsigned long) pid));
memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
@@ -1230,7 +1230,7 @@ vx_detach (char *args, int from_tty)
if (from_tty)
printf_unfiltered ("Detaching pid %s.\n",
- local_hex_string (
+ hex_string (
(unsigned long) PIDGET (inferior_ptid)));
if (args) /* FIXME, should be possible to leave suspended */
@@ -1262,7 +1262,8 @@ vx_kill (void)
Ptrace_return ptrace_out;
int status;
- printf_unfiltered ("Killing pid %s.\n", local_hex_string ((unsigned long) PIDGET (inferior_ptid)));
+ printf_unfiltered ("Killing pid %s.\n",
+ hex_string ((unsigned long) PIDGET (inferior_ptid)));
memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 5f71850..59067c6 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -33,7 +33,6 @@
#include "gdb-stabs.h"
#include "regcache.h"
#include "arch-utils.h"
-#include "language.h" /* for local_hex_string(). */
#include "ppc-tdep.h"
#include "exec.h"
@@ -1229,7 +1228,7 @@ find_toc_address (CORE_ADDR pc)
: vp->objfile);
}
}
- error ("Unable to find TOC entry for pc %s\n", local_hex_string (pc));
+ error ("Unable to find TOC entry for pc %s\n", hex_string (pc));
}
/* Register that we are able to handle rs6000 core file formats. */
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index c459b81..21f39ec 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -266,10 +266,6 @@ const struct language_defn scm_language_defn =
basic_lookup_transparent_type,/* lookup_transparent_type */
NULL, /* Language specific symbol demangler */
NULL, /* Language specific class_name_from_physname */
- {"", "", "", ""}, /* Binary format info */
- {"#o%lo", "#o", "o", ""}, /* Octal format info */
- {"%ld", "", "d", ""}, /* Decimal format info */
- {"#x%lX", "#X", "X", ""}, /* Hex format info */
NULL, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index efdfc86..cd3fc8d 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -375,7 +375,7 @@ lm_base (void)
if (solib_frv_debug)
fprintf_unfiltered (gdb_stdlog,
"lm_base: _GLOBAL_OFFSET_TABLE_ + 8 = %s\n",
- local_hex_string_custom (addr, "08l"));
+ hex_string_custom (addr, 8));
if (target_read_memory (addr, buf, sizeof buf) != 0)
return 0;
@@ -384,7 +384,7 @@ lm_base (void)
if (solib_frv_debug)
fprintf_unfiltered (gdb_stdlog,
"lm_base: lm_base_cache = %s\n",
- local_hex_string_custom (lm_base_cache, "08l"));
+ hex_string_custom (lm_base_cache, 8));
return lm_base_cache;
}
@@ -431,7 +431,7 @@ frv_current_sos (void)
if (solib_frv_debug)
fprintf_unfiltered (gdb_stdlog,
"current_sos: reading link_map entry at %s\n",
- local_hex_string_custom (lm_addr, "08l"));
+ hex_string_custom (lm_addr, 8));
if (target_read_memory (lm_addr, (char *) &lm_buf, sizeof (lm_buf)) != 0)
{
@@ -670,14 +670,13 @@ enable_break2 (void)
if (solib_frv_debug)
fprintf_unfiltered (gdb_stdlog,
"enable_break: interp_loadmap_addr = %s\n",
- local_hex_string_custom (interp_loadmap_addr,
- "08l"));
+ hex_string_custom (interp_loadmap_addr, 8));
ldm = fetch_loadmap (interp_loadmap_addr);
if (ldm == NULL)
{
warning ("Unable to load dynamic linker loadmap at address %s\n",
- local_hex_string_custom (interp_loadmap_addr, "08l"));
+ hex_string_custom (interp_loadmap_addr, 8));
enable_break_failure_warning ();
bfd_close (tmp_bfd);
return 0;
@@ -718,20 +717,20 @@ enable_break2 (void)
if (solib_frv_debug)
fprintf_unfiltered (gdb_stdlog,
"enable_break: _dl_debug_addr (prior to relocation) = %s\n",
- local_hex_string_custom (addr, "08l"));
+ hex_string_custom (addr, 8));
addr += displacement_from_map (ldm, addr);
if (solib_frv_debug)
fprintf_unfiltered (gdb_stdlog,
"enable_break: _dl_debug_addr (after relocation) = %s\n",
- local_hex_string_custom (addr, "08l"));
+ hex_string_custom (addr, 8));
/* Fetch the address of the r_debug struct. */
if (target_read_memory (addr, addr_buf, sizeof addr_buf) != 0)
{
warning ("Unable to fetch contents of _dl_debug_addr (at address %s) from dynamic linker",
- local_hex_string_custom (addr, "08l"));
+ hex_string_custom (addr, 8));
}
addr = extract_unsigned_integer (addr_buf, sizeof addr_buf);
@@ -740,7 +739,7 @@ enable_break2 (void)
if (target_read_memory (addr + 8, addr_buf, sizeof addr_buf) != 0)
{
warning ("Unable to fetch _dl_debug_addr->r_brk (at address %s) from dynamic linker",
- local_hex_string_custom (addr + 8, "08l"));
+ hex_string_custom (addr + 8, 8));
enable_break_failure_warning ();
bfd_close (tmp_bfd);
return 0;
@@ -751,7 +750,7 @@ enable_break2 (void)
if (target_read_memory (addr, addr_buf, sizeof addr_buf) != 0)
{
warning ("Unable to fetch _dl_debug_addr->.r_brk entry point (at address %s) from dynamic linker",
- local_hex_string_custom (addr, "08l"));
+ hex_string_custom (addr, 8));
enable_break_failure_warning ();
bfd_close (tmp_bfd);
return 0;
@@ -799,8 +798,8 @@ enable_break (void)
if (solib_frv_debug)
fprintf_unfiltered (gdb_stdlog,
"enable_break: solib event breakpoint placed at entry point: %s\n",
- local_hex_string_custom
- (symfile_objfile->ei.entry_point, "08l"));
+ hex_string_custom
+ (symfile_objfile->ei.entry_point, 8));
}
else
{
diff --git a/gdb/solib.c b/gdb/solib.c
index 8927568..35480bf 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -645,18 +645,11 @@ info_sharedlibrary_command (char *ignore, int from_tty)
struct so_list *so = NULL; /* link map state variable */
int header_done = 0;
int addr_width;
- char *addr_fmt;
if (TARGET_PTR_BIT == 32)
- {
- addr_width = 8 + 4;
- addr_fmt = "08l";
- }
+ addr_width = 8 + 4;
else if (TARGET_PTR_BIT == 64)
- {
- addr_width = 16 + 4;
- addr_fmt = "016l";
- }
+ addr_width = 16 + 4;
else
{
internal_error (__FILE__, __LINE__,
@@ -680,15 +673,15 @@ info_sharedlibrary_command (char *ignore, int from_tty)
printf_unfiltered ("%-*s", addr_width,
so->textsection != NULL
- ? local_hex_string_custom (
+ ? hex_string_custom (
(LONGEST) so->textsection->addr,
- addr_fmt)
+ addr_width - 4)
: "");
printf_unfiltered ("%-*s", addr_width,
so->textsection != NULL
- ? local_hex_string_custom (
+ ? hex_string_custom (
(LONGEST) so->textsection->endaddr,
- addr_fmt)
+ addr_width - 4)
: "");
printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
printf_unfiltered ("%s\n", so->so_name);
diff --git a/gdb/somsolib.c b/gdb/somsolib.c
index fd6c00c..e70d6bd 100644
--- a/gdb/somsolib.c
+++ b/gdb/somsolib.c
@@ -1463,17 +1463,17 @@ som_sharedlibrary_info_command (char *ignore, int from_tty)
if (so_list->objfile == NULL)
printf_unfiltered (" (symbols not loaded)");
printf_unfiltered ("\n");
- printf_unfiltered (" %-12s", local_hex_string_custom (flags, "08l"));
+ printf_unfiltered (" %-12s", hex_string_custom (flags, 8));
printf_unfiltered ("%-12s",
- local_hex_string_custom (so_list->som_solib.text_addr, "08l"));
+ hex_string_custom (so_list->som_solib.text_addr, 8));
printf_unfiltered ("%-12s",
- local_hex_string_custom (so_list->som_solib.text_end, "08l"));
+ hex_string_custom (so_list->som_solib.text_end, 8));
printf_unfiltered ("%-12s",
- local_hex_string_custom (so_list->som_solib.data_start, "08l"));
+ hex_string_custom (so_list->som_solib.data_start, 8));
printf_unfiltered ("%-12s",
- local_hex_string_custom (so_list->som_solib.data_end, "08l"));
+ hex_string_custom (so_list->som_solib.data_end, 8));
printf_unfiltered ("%-12s\n",
- local_hex_string_custom (so_list->som_solib.got_value, "08l"));
+ hex_string_custom (so_list->som_solib.got_value, 8));
so_list = so_list->next;
}
}
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 59fc378..14e8ccd 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1742,7 +1742,7 @@ add_symbol_file_command (char *args, int from_tty)
/* Print the prompt for the query below. And save the arguments into
a sect_addr_info structure to be passed around to other
functions. We have to split this up into separate print
- statements because local_hex_string returns a local static
+ statements because hex_string returns a local static
string. */
printf_unfiltered ("add symbol table from file \"%s\" at\n", filename);
@@ -1761,8 +1761,7 @@ add_symbol_file_command (char *args, int from_tty)
section_addrs->other[sec_num].name = sec;
section_addrs->other[sec_num].addr = addr;
printf_unfiltered ("\t%s_addr = %s\n",
- sec,
- local_hex_string ((unsigned long)addr));
+ sec, hex_string ((unsigned long)addr));
sec_num++;
/* The object's sections are initialized when a
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 7684bf9..46325db 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3136,12 +3136,12 @@ print_msymbol_info (struct minimal_symbol *msymbol)
char *tmp;
if (TARGET_ADDR_BIT <= 32)
- tmp = local_hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol)
- & (CORE_ADDR) 0xffffffff,
- "08l");
+ tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol)
+ & (CORE_ADDR) 0xffffffff,
+ 8);
else
- tmp = local_hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol),
- "016l");
+ tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol),
+ 16);
printf_filtered ("%s %s\n",
tmp, SYMBOL_PRINT_NAME (msymbol));
}
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 61fd5f1..a3901e8 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -494,11 +494,10 @@ tracepoints_info (char *tpnum_exp, int from_tty)
char *tmp;
if (TARGET_ADDR_BIT <= 32)
- tmp = local_hex_string_custom (t->address
- & (CORE_ADDR) 0xffffffff,
- "08l");
+ tmp = hex_string_custom (t->address & (CORE_ADDR) 0xffffffff,
+ 8);
else
- tmp = local_hex_string_custom (t->address, "016l");
+ tmp = hex_string_custom (t->address, 16);
printf_filtered ("%s ", tmp);
}
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 854ec49..783c538 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -496,9 +496,9 @@ ui_out_field_core_addr (struct ui_out *uiout,
based on TARGET_ADDR_BIT. */
/* print_address_numeric (address, 1, local_stream); */
if (TARGET_ADDR_BIT <= 32)
- strcpy (addstr, local_hex_string_custom (address, "08l"));
+ strcpy (addstr, hex_string_custom (address, 8));
else
- strcpy (addstr, local_hex_string_custom (address, "016l"));
+ strcpy (addstr, hex_string_custom (address, 16));
ui_out_field_string (uiout, fldname, addstr);
}
diff --git a/gdb/utils.c b/gdb/utils.c
index 10c40c7..846b97d 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2636,7 +2636,7 @@ paddr_nz (CORE_ADDR addr)
}
static void
-decimal2str (char *paddr_str, char *sign, ULONGEST addr)
+decimal2str (char *paddr_str, char *sign, ULONGEST addr, int width)
{
/* steal code from valprint.c:print_decimal(). Should this worry
about the real size of addr as the above does? */
@@ -2647,18 +2647,60 @@ decimal2str (char *paddr_str, char *sign, ULONGEST addr)
temp[i] = addr % (1000 * 1000 * 1000);
addr /= (1000 * 1000 * 1000);
i++;
+ width -= 9;
}
while (addr != 0 && i < (sizeof (temp) / sizeof (temp[0])));
+ width += 9;
+ if (width < 0)
+ width = 0;
switch (i)
{
case 1:
- sprintf (paddr_str, "%s%lu", sign, temp[0]);
+ sprintf (paddr_str, "%s%0*lu", sign, width, temp[0]);
break;
case 2:
- sprintf (paddr_str, "%s%lu%09lu", sign, temp[1], temp[0]);
+ sprintf (paddr_str, "%s%0*lu%09lu", sign, width, temp[1], temp[0]);
break;
case 3:
- sprintf (paddr_str, "%s%lu%09lu%09lu", sign, temp[2], temp[1], temp[0]);
+ sprintf (paddr_str, "%s%0*lu%09lu%09lu", sign, width,
+ temp[2], temp[1], temp[0]);
+ break;
+ default:
+ internal_error (__FILE__, __LINE__,
+ "failed internal consistency check");
+ }
+}
+
+static void
+octal2str (char *paddr_str, ULONGEST addr, int width)
+{
+ unsigned long temp[3];
+ int i = 0;
+ do
+ {
+ temp[i] = addr % (0100000 * 0100000);
+ addr /= (0100000 * 0100000);
+ i++;
+ width -= 10;
+ }
+ while (addr != 0 && i < (sizeof (temp) / sizeof (temp[0])));
+ width += 10;
+ if (width < 0)
+ width = 0;
+ switch (i)
+ {
+ case 1:
+ if (temp[0] == 0)
+ sprintf (paddr_str, "%*o", width, 0);
+ else
+ sprintf (paddr_str, "0%0*lo", width, temp[0]);
+ break;
+ case 2:
+ sprintf (paddr_str, "0%0*lo%010lo", width, temp[1], temp[0]);
+ break;
+ case 3:
+ sprintf (paddr_str, "0%0*lo%010lo%010lo", width,
+ temp[2], temp[1], temp[0]);
break;
default:
internal_error (__FILE__, __LINE__,
@@ -2670,7 +2712,7 @@ char *
paddr_u (CORE_ADDR addr)
{
char *paddr_str = get_cell ();
- decimal2str (paddr_str, "", addr);
+ decimal2str (paddr_str, "", addr, 0);
return paddr_str;
}
@@ -2679,9 +2721,9 @@ paddr_d (LONGEST addr)
{
char *paddr_str = get_cell ();
if (addr < 0)
- decimal2str (paddr_str, "-", -addr);
+ decimal2str (paddr_str, "-", -addr, 0);
else
- decimal2str (paddr_str, "", addr);
+ decimal2str (paddr_str, "", addr, 0);
return paddr_str;
}
@@ -2747,6 +2789,54 @@ phex_nz (ULONGEST l, int sizeof_l)
}
+/* Convert VAL to a numeral in the given radix. For
+ * radix 10, IS_SIGNED may be true, indicating a signed quantity;
+ * otherwise VAL is interpreted as unsigned. If WIDTH is supplied,
+ * it is the minimum width (0-padded if needed). USE_C_FORMAT means
+ * to use C format in all cases. If it is false, then 'x'
+ * and 'o' formats do not include a prefix (0x or leading 0). */
+
+char *
+int_string (LONGEST val, int radix, int is_signed, int width,
+ int use_c_format)
+{
+ switch (radix)
+ {
+ case 16:
+ {
+ char *result;
+ if (width == 0)
+ result = hex_string (val);
+ else
+ result = hex_string_custom (val, width);
+ if (! use_c_format)
+ result += 2;
+ return result;
+ }
+ case 10:
+ {
+ char *result = get_cell ();
+ if (is_signed && val < 0)
+ decimal2str (result, "-", -val, width);
+ else
+ decimal2str (result, "", val, width);
+ return result;
+ }
+ case 8:
+ {
+ char *result = get_cell ();
+ octal2str (result, val, width);
+ if (use_c_format || val == 0)
+ return result;
+ else
+ return result + 1;
+ }
+ default:
+ internal_error (__FILE__, __LINE__,
+ "failed internal consistency check");
+ }
+}
+
/* Convert a CORE_ADDR into a string. */
const char *
core_addr_to_string (const CORE_ADDR addr)
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 16c46b8..64216f8 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -209,202 +209,52 @@ val_print_type_code_int (struct type *type, char *valaddr,
/* Print a number according to FORMAT which is one of d,u,x,o,b,h,w,g.
The raison d'etre of this function is to consolidate printing of
- LONG_LONG's into this one function. Some platforms have long longs but
- don't have a printf() that supports "ll" in the format string. We handle
- these by seeing if the number is representable as either a signed or
- unsigned long, depending upon what format is desired, and if not we just
- bail out and print the number in hex.
-
- The format chars b,h,w,g are from print_scalar_formatted(). If USE_LOCAL,
- format it according to the current language (this should be used for most
- integers which GDB prints, the exception is things like protocols where
- the format of the integer is a protocol thing, not a user-visible thing).
- */
-
-#if defined (CC_HAS_LONG_LONG) && !defined (PRINTF_HAS_LONG_LONG)
-static void print_decimal (struct ui_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)
-{
- unsigned long temp[3];
- int i = 0;
- do
- {
- temp[i] = val_ulong % (1000 * 1000 * 1000);
- val_ulong /= (1000 * 1000 * 1000);
- i++;
- }
- while (val_ulong != 0 && i < (sizeof (temp) / sizeof (temp[0])));
- switch (i)
- {
- case 1:
- fprintf_filtered (stream, "%s%lu",
- sign, temp[0]);
- break;
- case 2:
- fprintf_filtered (stream, "%s%lu%09lu",
- sign, temp[1], temp[0]);
- break;
- case 3:
- fprintf_filtered (stream, "%s%lu%09lu%09lu",
- sign, temp[2], temp[1], temp[0]);
- break;
- default:
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
- }
- return;
-}
-#endif
+ LONG_LONG's into this one function. The format chars b,h,w,g are
+ from print_scalar_formatted(). Numbers are printed using C
+ format.
+
+ USE_C_FORMAT means to use C format in all cases. Without it,
+ 'o' and 'x' format do not include the standard C radix prefix
+ (leading 0 or 0x).
+
+ Hilfinger/2004-09-09: USE_C_FORMAT was originally called USE_LOCAL
+ and was intended to request formating according to the current
+ language and would be used for most integers that GDB prints. The
+ exceptional cases were things like protocols where the format of
+ the integer is a protocol thing, not a user-visible thing). The
+ parameter remains to preserve the information of what things might
+ be printed with language-specific format, should we ever resurrect
+ that capability. */
void
-print_longest (struct ui_file *stream, int format, int use_local,
+print_longest (struct ui_file *stream, int format, int use_c_format,
LONGEST val_long)
{
-#if defined (CC_HAS_LONG_LONG) && !defined (PRINTF_HAS_LONG_LONG)
- if (sizeof (long) < sizeof (LONGEST))
- {
- switch (format)
- {
- case 'd':
- {
- /* Print a signed value, that doesn't fit in a long */
- if ((long) val_long != val_long)
- {
- if (val_long < 0)
- print_decimal (stream, "-", use_local, -val_long);
- else
- print_decimal (stream, "", use_local, val_long);
- return;
- }
- break;
- }
- case 'u':
- {
- /* Print an unsigned value, that doesn't fit in a long */
- if ((unsigned long) val_long != (ULONGEST) val_long)
- {
- print_decimal (stream, "", use_local, val_long);
- return;
- }
- break;
- }
- case 'x':
- case 'o':
- case 'b':
- case 'h':
- case 'w':
- case 'g':
- /* Print as unsigned value, must fit completely in unsigned long */
- {
- unsigned long temp = val_long;
- if (temp != val_long)
- {
- /* Urk, can't represent value in long so print in hex.
- Do shift in two operations so that if sizeof (long)
- == sizeof (LONGEST) we can avoid warnings from
- picky compilers about shifts >= the size of the
- shiftee in bits */
- unsigned long vbot = (unsigned long) val_long;
- LONGEST temp = (val_long >> (sizeof (long) * HOST_CHAR_BIT - 1));
- unsigned long vtop = temp >> 1;
- fprintf_filtered (stream, "0x%lx%08lx", vtop, vbot);
- return;
- }
- break;
- }
- }
- }
-#endif
-
-#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
+ char *val;
switch (format)
{
case 'd':
- fprintf_filtered (stream,
- use_local ? local_decimal_format_custom ("ll")
- : "%lld",
- (long long) val_long);
- break;
+ val = int_string (val_long, 10, 1, 0, 1); break;
case 'u':
- fprintf_filtered (stream, "%llu", (long long) val_long);
- break;
+ val = int_string (val_long, 10, 0, 0, 1); break;
case 'x':
- fprintf_filtered (stream,
- use_local ? local_hex_format_custom ("ll")
- : "%llx",
- (unsigned long long) val_long);
- break;
- case 'o':
- fprintf_filtered (stream,
- use_local ? local_octal_format_custom ("ll")
- : "%llo",
- (unsigned long long) val_long);
- break;
+ val = int_string (val_long, 16, 0, 0, use_c_format); break;
case 'b':
- fprintf_filtered (stream, local_hex_format_custom ("02ll"), val_long);
- break;
+ val = int_string (val_long, 16, 0, 2, 1); break;
case 'h':
- fprintf_filtered (stream, local_hex_format_custom ("04ll"), val_long);
- break;
+ val = int_string (val_long, 16, 0, 4, 1); break;
case 'w':
- fprintf_filtered (stream, local_hex_format_custom ("08ll"), val_long);
- break;
+ val = int_string (val_long, 16, 0, 8, 1); break;
case 'g':
- fprintf_filtered (stream, local_hex_format_custom ("016ll"), val_long);
- break;
- default:
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
- }
-#else /* !CC_HAS_LONG_LONG || !PRINTF_HAS_LONG_LONG */
- /* In the following it is important to coerce (val_long) to a long. It does
- nothing if !LONG_LONG, but it will chop off the top half (which we know
- we can ignore) if the host supports long longs. */
-
- switch (format)
- {
- case 'd':
- fprintf_filtered (stream,
- use_local ? local_decimal_format_custom ("l")
- : "%ld",
- (long) val_long);
- break;
- case 'u':
- fprintf_filtered (stream, "%lu", (unsigned long) val_long);
- break;
- case 'x':
- fprintf_filtered (stream,
- use_local ? local_hex_format_custom ("l")
- : "%lx",
- (unsigned long) val_long);
+ val = int_string (val_long, 16, 0, 16, 1); break;
break;
case 'o':
- fprintf_filtered (stream,
- use_local ? local_octal_format_custom ("l")
- : "%lo",
- (unsigned long) val_long);
- break;
- case 'b':
- fprintf_filtered (stream, local_hex_format_custom ("02l"),
- (unsigned long) val_long);
- break;
- case 'h':
- fprintf_filtered (stream, local_hex_format_custom ("04l"),
- (unsigned long) val_long);
- break;
- case 'w':
- fprintf_filtered (stream, local_hex_format_custom ("08l"),
- (unsigned long) val_long);
- break;
- case 'g':
- fprintf_filtered (stream, local_hex_format_custom ("016l"),
- (unsigned long) val_long);
- break;
+ val = int_string (val_long, 8, 0, 0, use_c_format); break;
default:
internal_error (__FILE__, __LINE__, "failed internal consistency check");
- }
-#endif /* CC_HAS_LONG_LONG || PRINTF_HAS_LONG_LONG */
+ }
+
+ fprintf_filtered (stream, val);
}
/* This used to be a macro, but I don't think it is called often enough
@@ -449,9 +299,8 @@ print_floating (char *valaddr, struct type *type, struct ui_file *stream)
if (floatformat_is_negative (fmt, valaddr))
fprintf_filtered (stream, "-");
fprintf_filtered (stream, "nan(");
- fputs_filtered (local_hex_format_prefix (), stream);
+ fputs_filtered ("0x", stream);
fputs_filtered (floatformat_mantissa (fmt, valaddr), stream);
- fputs_filtered (local_hex_format_suffix (), stream);
fprintf_filtered (stream, ")");
return;
}
@@ -512,7 +361,6 @@ print_binary_chars (struct ui_file *stream, unsigned char *valaddr,
/* FIXME: We should be not printing leading zeroes in most cases. */
- fputs_filtered (local_binary_format_prefix (), stream);
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
for (p = valaddr;
@@ -550,7 +398,6 @@ print_binary_chars (struct ui_file *stream, unsigned char *valaddr,
}
}
}
- fputs_filtered (local_binary_format_suffix (), stream);
}
/* VALADDR points to an integer of LEN bytes.
@@ -599,7 +446,7 @@ print_octal_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
cycle = (len * BITS_IN_BYTES) % BITS_IN_OCTAL;
carry = 0;
- fputs_filtered (local_octal_format_prefix (), stream);
+ fputs_filtered ("0", stream);
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
for (p = valaddr;
@@ -698,7 +545,6 @@ print_octal_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
}
}
- fputs_filtered (local_octal_format_suffix (), stream);
}
/* VALADDR points to an integer of LEN bytes.
@@ -741,8 +587,6 @@ print_decimal_chars (struct ui_file *stream, unsigned char *valaddr,
digits[i] = 0;
}
- fputs_filtered (local_decimal_format_prefix (), stream);
-
/* Ok, we have an unknown number of bytes of data to be printed in
* decimal.
*
@@ -837,8 +681,6 @@ print_decimal_chars (struct ui_file *stream, unsigned char *valaddr,
fprintf_filtered (stream, "%1d", digits[i]);
}
xfree (digits);
-
- fputs_filtered (local_decimal_format_suffix (), stream);
}
/* VALADDR points to an integer of LEN bytes. Print it in hex on stream. */
@@ -850,7 +692,7 @@ print_hex_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
/* FIXME: We should be not printing leading zeroes in most cases. */
- fputs_filtered (local_hex_format_prefix (), stream);
+ fputs_filtered ("0x", stream);
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
for (p = valaddr;
@@ -869,7 +711,6 @@ print_hex_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
fprintf_filtered (stream, "%02x", *p);
}
}
- fputs_filtered (local_hex_format_suffix (), stream);
}
/* VALADDR points to a char integer of LEN bytes. Print it out in appropriate language form on stream.