From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17234 invoked by alias); 12 Sep 2002 20:09:13 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 17227 invoked from network); 12 Sep 2002 20:09:12 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 12 Sep 2002 20:09:12 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id A76C1D2CC1; Thu, 12 Sep 2002 13:09:09 -0700 (PDT) Date: Thu, 12 Sep 2002 13:09:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: [RFC/RFA] new gdbarch method: NAME_OF_MALLOC Message-ID: <20020912200909.GN932@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ZfOjI3PrQbgiZnxM" Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2002-09/txt/msg00214.txt.bz2 --ZfOjI3PrQbgiZnxM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1014 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 * 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 --ZfOjI3PrQbgiZnxM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="NAME_OF_MALLOC.diff" Content-length: 6443 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; } --ZfOjI3PrQbgiZnxM--