Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC/RFA] new gdbarch method: NAME_OF_MALLOC
@ 2002-09-12 13:09 Joel Brobecker
  2002-09-12 13:44 ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2002-09-12 13:09 UTC (permalink / raw)
  To: gdb-patches

[-- 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;
  }
  
  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC/RFA] new gdbarch method: NAME_OF_MALLOC
  2002-09-12 13:09 [RFC/RFA] new gdbarch method: NAME_OF_MALLOC Joel Brobecker
@ 2002-09-12 13:44 ` Andrew Cagney
  2002-09-12 17:02   ` Joel Brobecker
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2002-09-12 13:44 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> 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?

[No one appears to have come up with a better 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?

> 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

Can ``const char *'' be used?  I think you'll just need to tweak the 
function signature for find_function_in_inferior().  If you need to 
tweak more, yell! :-)

doc/gdbint.texinfo will need a separate patch.

Andrew



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC/RFA] new gdbarch method: NAME_OF_MALLOC
  2002-09-12 13:44 ` Andrew Cagney
@ 2002-09-12 17:02   ` Joel Brobecker
  2002-09-12 17:15     ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2002-09-12 17:02 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 951 bytes --]

> Can ``const char *'' be used?  I think you'll just need to tweak the 
> function signature for find_function_in_inferior().  If you need to 
> tweak more, yell! :-)

Yes, actually, you were right. I thought that the compiler would yell to
see one of the struct fields be a "const", but it did not.

I sent a patch that constains the tweaks separately, see
http://sources.redhat.com/ml/gdb-patches/2002-09/msg00221.html.

This patch depends on the patch mentionned above.

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.

> doc/gdbint.texinfo will need a separate patch.

Ah yes, right. I will work on that as soon as the code is approved.

Thanks,
-- 
Joel

[-- Attachment #2: NAME_OF_MALLOC.diff --]
[-- Type: text/plain, Size: 6479 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 23:55:42 -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:const 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 23:55:45 -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 23:55:47 -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 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
  
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 23:55:51 -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;
+   const 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;
+ }
+ 
+ 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;
  }
  
  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC/RFA] new gdbarch method: NAME_OF_MALLOC
  2002-09-12 17:02   ` Joel Brobecker
@ 2002-09-12 17:15     ` Andrew Cagney
  2002-09-12 17:39       ` Joel Brobecker
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2002-09-12 17:15 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>> Can ``const char *'' be used?  I think you'll just need to tweak the 
>> function signature for find_function_in_inferior().  If you need to 
>> tweak more, yell! :-)
> 
> 
> Yes, actually, you were right. I thought that the compiler would yell to
> see one of the struct fields be a "const", but it did not.
> 
> I sent a patch that constains the tweaks separately, see
> http://sources.redhat.com/ml/gdb-patches/2002-09/msg00221.html.
> 
> This patch depends on the patch mentionned above.
> 
> 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.

This is ok.

Andrew


>> doc/gdbint.texinfo will need a separate patch.
> 
> 
> Ah yes, right. I will work on that as soon as the code is approved.
> 
> Thanks,
> -- Joel
> 
> 
> 
> 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 23:55:42 -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:const 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 23:55:45 -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 23:55:47 -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 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
>   
> 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 23:55:51 -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;
> +   const 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;
> + }
> + 
> + 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;
>   }
>   
>   



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC/RFA] new gdbarch method: NAME_OF_MALLOC
  2002-09-12 17:15     ` Andrew Cagney
@ 2002-09-12 17:39       ` Joel Brobecker
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2002-09-12 17:39 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

> >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.
> 
> This is ok.

Thank you, committed.

-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-09-13  0:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-12 13:09 [RFC/RFA] new gdbarch method: NAME_OF_MALLOC Joel Brobecker
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox