diff options
author | Joel Brobecker <brobecker@gnat.com> | 2002-09-13 00:38:48 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2002-09-13 00:38:48 +0000 |
commit | 5720643ce87e3763cdf5075d5a8c18a9af0663a3 (patch) | |
tree | dae524668a500385708a6c2a107a040dd619cdb2 /gdb | |
parent | 3bada2a2df47a36a9c44e1cc50669124af7f6370 (diff) | |
download | gdb-5720643ce87e3763cdf5075d5a8c18a9af0663a3.zip gdb-5720643ce87e3763cdf5075d5a8c18a9af0663a3.tar.gz gdb-5720643ce87e3763cdf5075d5a8c18a9af0663a3.tar.bz2 |
* gdbarch.sh (NAME_OF_MALLOC): New variable in the architecture
vector. Will be useful for Interix.
* gdbarch.h, gdbarch.c: Regenerate.
* valops.c (value_allocate_space_in_inferior): Replace hard-coded
name of the malloc function by NAME_OF_MALLOC.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/gdbarch.c | 29 | ||||
-rw-r--r-- | gdb/gdbarch.h | 18 | ||||
-rwxr-xr-x | gdb/gdbarch.sh | 1 | ||||
-rw-r--r-- | gdb/valops.c | 2 |
5 files changed, 57 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7bd6d01..655027e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2002-09-12 Joel Brobecker <brobecker@gnat.com> + * gdbarch.sh (NAME_OF_MALLOC): New variable in the architecture + vector. Will be useful for Interix. + * gdbarch.h, gdbarch.c: Regenerate. + + * valops.c (value_allocate_space_in_inferior): Replace hard-coded + name of the malloc function by NAME_OF_MALLOC. + +2002-09-12 Joel Brobecker <brobecker@gnat.com> + * value.h (find_function_in_inferior): Add const keyword to one of the parameters. Allows us to invoke this function with a const char *. diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 49c1152..c0b0b3a 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -267,6 +267,7 @@ struct gdbarch gdbarch_dwarf2_build_frame_info_ftype *dwarf2_build_frame_info; gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special; gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special; + const char * name_of_malloc; }; @@ -423,6 +424,7 @@ struct gdbarch startup_gdbarch = 0, 0, 0, + "malloc", /* startup_gdbarch() */ }; @@ -553,6 +555,7 @@ gdbarch_alloc (const struct gdbarch_info *info, current_gdbarch->construct_inferior_arguments = construct_inferior_arguments; current_gdbarch->elf_make_msymbol_special = default_elf_make_msymbol_special; current_gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special; + current_gdbarch->name_of_malloc = "malloc"; /* gdbarch_alloc() */ return current_gdbarch; @@ -797,6 +800,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of dwarf2_build_frame_info, has predicate */ /* Skip verify of elf_make_msymbol_special, invalid_p == 0 */ /* Skip verify of coff_make_msymbol_special, invalid_p == 0 */ + /* Skip verify of name_of_malloc, invalid_p == 0 */ buf = ui_file_xstrdup (log, &dummy); make_cleanup (xfree, buf); if (strlen (buf) > 0) @@ -1485,6 +1489,14 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) (long) current_gdbarch->memory_remove_breakpoint /*MEMORY_REMOVE_BREAKPOINT ()*/); #endif +#ifdef NAME_OF_MALLOC + fprintf_unfiltered (file, + "gdbarch_dump: NAME_OF_MALLOC # %s\n", + XSTRING (NAME_OF_MALLOC)); + fprintf_unfiltered (file, + "gdbarch_dump: NAME_OF_MALLOC = %ld\n", + (long) NAME_OF_MALLOC); +#endif #ifdef NPC_REGNUM fprintf_unfiltered (file, "gdbarch_dump: NPC_REGNUM # %s\n", @@ -4955,6 +4967,23 @@ set_gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, gdbarch->coff_make_msymbol_special = coff_make_msymbol_special; } +const char * +gdbarch_name_of_malloc (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Skip verify of name_of_malloc, invalid_p == 0 */ + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_name_of_malloc called\n"); + return gdbarch->name_of_malloc; +} + +void +set_gdbarch_name_of_malloc (struct gdbarch *gdbarch, + const char * name_of_malloc) +{ + gdbarch->name_of_malloc = name_of_malloc; +} + /* Keep a registry of per-architecture data-pointers required by GDB modules. */ diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 5976f46..246b4da 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -2207,7 +2207,7 @@ extern void set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch, gdbarch_addr_ #endif #endif -/* It is not at all clear why SMASH_TEXT_ADDRESS is not folded into +/* It is not at all clear why SMASH_TEXT_ADDRESS is not folded into ADDR_BITS_REMOVE. */ /* Default (function) for non- multi-arch platforms. */ @@ -2532,6 +2532,22 @@ extern void set_gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, gdba #endif #endif +/* Default (value) for non- multi-arch platforms. */ +#if (!GDB_MULTI_ARCH) && !defined (NAME_OF_MALLOC) +#define NAME_OF_MALLOC ("malloc") +#endif + +extern const char * gdbarch_name_of_malloc (struct gdbarch *gdbarch); +extern void set_gdbarch_name_of_malloc (struct gdbarch *gdbarch, const char * name_of_malloc); +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (NAME_OF_MALLOC) +#error "Non multi-arch definition of NAME_OF_MALLOC" +#endif +#if GDB_MULTI_ARCH +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (NAME_OF_MALLOC) +#define NAME_OF_MALLOC (gdbarch_name_of_malloc (current_gdbarch)) +#endif +#endif + extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index ff1d6ed..6bf7465 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -660,6 +660,7 @@ m::CONSTRUCT_INFERIOR_ARGUMENTS:char *:construct_inferior_arguments:int argc, ch F:2:DWARF2_BUILD_FRAME_INFO:void:dwarf2_build_frame_info:struct objfile *objfile:objfile:::0 f:2:ELF_MAKE_MSYMBOL_SPECIAL:void:elf_make_msymbol_special:asymbol *sym, struct minimal_symbol *msym:sym, msym:::default_elf_make_msymbol_special::0 f:2:COFF_MAKE_MSYMBOL_SPECIAL:void:coff_make_msymbol_special:int val, struct minimal_symbol *msym:val, msym:::default_coff_make_msymbol_special::0 +v::NAME_OF_MALLOC:const char *:name_of_malloc::::"malloc":"malloc"::0 EOF } diff --git a/gdb/valops.c b/gdb/valops.c index b2199cb..4efcd42 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -138,7 +138,7 @@ struct value * value_allocate_space_in_inferior (int len) { struct value *blocklen; - struct value *val = find_function_in_inferior ("malloc"); + struct value *val = find_function_in_inferior (NAME_OF_MALLOC); blocklen = value_from_longest (builtin_type_int, (LONGEST) len); val = call_function_by_hand (val, 1, &blocklen); |