From: Joel Brobecker <brobecker@gnat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFC/RFA] new gdbarch method: NAME_OF_MALLOC
Date: Thu, 12 Sep 2002 13:09:00 -0000 [thread overview]
Message-ID: <20020912200909.GN932@gnat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]
Following the disussion around the fact that the name of the function
used to allocate some memory in the inferior is hard-coded to "malloc"
(http://sources.redhat.com/ml/gdb-patches/2002-09/msg00079.html),
here is a proposed addition to the architecture vector.
Is it the right thing to do to handle the interix case where the
malloc function should be "_malloc"? Is "NAME_OF_MALLOC" ok, or would
we prefer a different name?
Also, I did not find much documentation on each field for the line I
added in gdbarch.sh. So I kind of reversed engineered it by reading
the script code. So if you find anything I missed, this might explain
it...
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.
Ok to apply?
Thanks,
--
Joel
[-- Attachment #2: NAME_OF_MALLOC.diff --]
[-- Type: text/plain, Size: 6443 bytes --]
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.159
diff -c -3 -p -r1.159 gdbarch.sh
*** gdbarch.sh 6 Sep 2002 20:17:40 -0000 1.159
--- gdbarch.sh 12 Sep 2002 19:57:06 -0000
*************** m::CONSTRUCT_INFERIOR_ARGUMENTS:char *:c
*** 660,665 ****
--- 660,666 ----
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:char *:name_of_malloc::::"malloc":"malloc"::0
EOF
}
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.69
diff -c -3 -p -r1.69 valops.c
*** valops.c 21 Aug 2002 17:24:31 -0000 1.69
--- valops.c 12 Sep 2002 19:57:09 -0000
*************** struct value *
*** 138,144 ****
value_allocate_space_in_inferior (int len)
{
struct value *blocklen;
! struct value *val = find_function_in_inferior ("malloc");
blocklen = value_from_longest (builtin_type_int, (LONGEST) len);
val = call_function_by_hand (val, 1, &blocklen);
--- 138,144 ----
value_allocate_space_in_inferior (int len)
{
struct value *blocklen;
! 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);
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.115
diff -c -3 -p -r1.115 gdbarch.h
*** gdbarch.h 6 Sep 2002 20:17:40 -0000 1.115
--- gdbarch.h 12 Sep 2002 19:57:11 -0000
*************** extern void set_gdbarch_addr_bits_remove
*** 2207,2213 ****
#endif
#endif
! /* It is not at all clear why SMASH_TEXT_ADDRESS is not folded into
ADDR_BITS_REMOVE. */
/* Default (function) for non- multi-arch platforms. */
--- 2207,2213 ----
#endif
#endif
! /* It is not at all clear why SMASH_TEXT_ADDRESS is not folded into
ADDR_BITS_REMOVE. */
/* Default (function) for non- multi-arch platforms. */
*************** extern void set_gdbarch_coff_make_msymbo
*** 2529,2534 ****
--- 2529,2550 ----
#if GDB_MULTI_ARCH
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (COFF_MAKE_MSYMBOL_SPECIAL)
#define COFF_MAKE_MSYMBOL_SPECIAL(val, msym) (gdbarch_coff_make_msymbol_special (current_gdbarch, val, msym))
+ #endif
+ #endif
+
+ /* Default (value) for non- multi-arch platforms. */
+ #if (!GDB_MULTI_ARCH) && !defined (NAME_OF_MALLOC)
+ #define NAME_OF_MALLOC ("malloc")
+ #endif
+
+ extern char * gdbarch_name_of_malloc (struct gdbarch *gdbarch);
+ extern void set_gdbarch_name_of_malloc (struct gdbarch *gdbarch, 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
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.147
diff -c -3 -p -r1.147 gdbarch.c
*** gdbarch.c 6 Sep 2002 20:17:40 -0000 1.147
--- gdbarch.c 12 Sep 2002 19:57:16 -0000
*************** struct gdbarch
*** 267,272 ****
--- 267,273 ----
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;
+ char * name_of_malloc;
};
*************** struct gdbarch startup_gdbarch =
*** 423,428 ****
--- 424,430 ----
0,
0,
0,
+ "malloc",
/* startup_gdbarch() */
};
*************** gdbarch_alloc (const struct gdbarch_info
*** 553,558 ****
--- 555,561 ----
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;
*************** verify_gdbarch (struct gdbarch *gdbarch)
*** 797,802 ****
--- 800,806 ----
/* 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)
*************** gdbarch_dump (struct gdbarch *gdbarch, s
*** 1485,1490 ****
--- 1489,1502 ----
(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",
*************** set_gdbarch_coff_make_msymbol_special (s
*** 4953,4958 ****
--- 4965,4987 ----
gdbarch_coff_make_msymbol_special_ftype coff_make_msymbol_special)
{
gdbarch->coff_make_msymbol_special = coff_make_msymbol_special;
+ }
+
+ 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,
+ char * name_of_malloc)
+ {
+ gdbarch->name_of_malloc = name_of_malloc;
}
next reply other threads:[~2002-09-12 20:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-12 13:09 Joel Brobecker [this message]
2002-09-12 13:44 ` Andrew Cagney
2002-09-12 17:02 ` Joel Brobecker
2002-09-12 17:15 ` Andrew Cagney
2002-09-12 17:39 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020912200909.GN932@gnat.com \
--to=brobecker@gnat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox