Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Add parse_dwarf2_calling_convention functionality
@ 2004-10-07  9:53 Corinna Vinschen
  2004-10-08 12:47 ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Corinna Vinschen @ 2004-10-07  9:53 UTC (permalink / raw)
  To: gdb-patches

Hi,

the second patch to prepare the calling convention stuff.  It just adds
the parse_dwarf2_calling_convention functionality to gdbarch.  The
below patch contains only the patch to gdbarch.sh (not the auto-generated
gdbarch.[ch]) and the new default_parse_dwarf2_calling_convention function
in arch-utils.

Ok to apply?


Corinna

	* gdbarch.sh (parse_dwarf2_calling_convention): New method.
	* gdbarch.h, gdbarch.c: Re-generate.
	* arch-utils.c (default_parse_dwarf2_calling_convention): New function.
	* arch-utils.h (default_parse_dwarf2_calling_convention): New extern
	declaration.

Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.348
diff -u -p -r1.348 gdbarch.sh
--- gdbarch.sh	2 Sep 2004 17:22:08 -0000	1.348
+++ gdbarch.sh	7 Oct 2004 09:46:56 -0000
@@ -664,6 +664,10 @@ F:=:CORE_ADDR:fetch_pointer_argument:str
 # Return the appropriate register set for a core file section with
 # name SECT_NAME and size SECT_SIZE.
 M::const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size
+
+# Evaluate DW_AT_calling_convention value and convert in a calling_convention
+# value in the functions main type.
+m::void:parse_dwarf2_calling_convention:int has_attr, unsigned long attr_val, unsigned char gcc_compiled, struct type *func_type:has_attr, attr_val, gcc_compiled, func_type:0:default_parse_dwarf2_calling_convention::0
 EOF
 }
 
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.122
diff -u -p -r1.122 arch-utils.c
--- arch-utils.c	5 Aug 2004 14:12:38 -0000	1.122
+++ arch-utils.c	7 Oct 2004 09:46:56 -0000
@@ -331,6 +331,15 @@ default_stabs_argument_has_addr (struct 
   return 0;
 }
 
+void
+default_parse_dwarf2_calling_convention (struct gdbarch *gdbarch,
+					 int has_attr, unsigned long attr_val,
+					 unsigned char gcc_compiled,
+					 struct type *func_type)
+{
+  TYPE_CALLING_CONVENTION (func_type) = attr_val;
+}
+
 \f
 /* Functions to manipulate the endianness of the target.  */
 
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.75
diff -u -p -r1.75 arch-utils.h
--- arch-utils.h	5 Aug 2004 14:12:38 -0000	1.75
+++ arch-utils.h	7 Oct 2004 09:46:56 -0000
@@ -119,6 +119,13 @@ extern int generic_convert_register_p (i
 extern int default_stabs_argument_has_addr (struct gdbarch *gdbarch,
 					    struct type *type);
 
+/* By default, just use the dwarf2 val for the type's calling_convention.  */
+extern void default_parse_dwarf2_calling_convention (struct gdbarch *gdbarch,
+						     int has_attr,
+						     unsigned long attr_val,
+						     unsigned char gcc_compiled,
+						     struct type *func_type);
+
 /* For compatibility with older architectures, returns
    (LEGACY_SIM_REGNO_IGNORE) when the register doesn't have a valid
    name.  */

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat, Inc.


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

* Re: [RFA] Add parse_dwarf2_calling_convention functionality
  2004-10-07  9:53 [RFA] Add parse_dwarf2_calling_convention functionality Corinna Vinschen
@ 2004-10-08 12:47 ` Corinna Vinschen
  2004-10-22  3:31   ` Elena Zannoni
  0 siblings, 1 reply; 5+ messages in thread
From: Corinna Vinschen @ 2004-10-08 12:47 UTC (permalink / raw)
  To: gdb-patches

Hi,

On Oct  7 11:54, Corinna Vinschen wrote:
> the second patch to prepare the calling convention stuff.  It just adds
> the parse_dwarf2_calling_convention functionality to gdbarch.  The
> below patch contains only the patch to gdbarch.sh (not the auto-generated
> gdbarch.[ch]) and the new default_parse_dwarf2_calling_convention function
> in arch-utils.

Corrected patch below.  It seems to be more useful to use the producer
field of the compilation unit instead of an artificial "gcc_compiled"
flag.  The producer string is easily scanned and the information given
is more detailed than just a gcc_compiled flag.

The below patch overrides the previous patch and also contains the
necessary change to dwarf2read.c now.

Corinna

	* gdbarch.sh (parse_dwarf2_calling_convention): New method.
	* gdbarch.h, gdbarch.c: Re-generate.
	* arch-utils.c (default_parse_dwarf2_calling_convention): New function.
	* arch-utils.h (default_parse_dwarf2_calling_convention): New extern
	declaration.
	* dwarf2read.c (read_subroutine_type): Evaluate
	DW_AT_calling_convention attribute and call
	gdbarch_parse_dwarf2_calling_convention appropriately.

Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.348
diff -u -p -r1.348 gdbarch.sh
--- gdbarch.sh	2 Sep 2004 17:22:08 -0000	1.348
+++ gdbarch.sh	8 Oct 2004 12:29:12 -0000
@@ -664,6 +664,10 @@ F:=:CORE_ADDR:fetch_pointer_argument:str
 # Return the appropriate register set for a core file section with
 # name SECT_NAME and size SECT_SIZE.
 M::const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size
+
+# Evaluate DW_AT_calling_convention value and convert in a calling_convention
+# value in the functions main type.
+m::void:parse_dwarf2_calling_convention:int has_attr, unsigned long attr_val, const char *producer, struct type *func_type:has_attr, attr_val, producer, func_type:0:default_parse_dwarf2_calling_convention::0
 EOF
 }
 
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.122
diff -u -p -r1.122 arch-utils.c
--- arch-utils.c	5 Aug 2004 14:12:38 -0000	1.122
+++ arch-utils.c	8 Oct 2004 12:29:12 -0000
@@ -331,6 +331,15 @@ default_stabs_argument_has_addr (struct 
   return 0;
 }
 
+void
+default_parse_dwarf2_calling_convention (struct gdbarch *gdbarch,
+					 int has_attr, unsigned long attr_val,
+					 const char *producer,
+					 struct type *func_type)
+{
+  TYPE_CALLING_CONVENTION (func_type) = attr_val;
+}
+
 \f
 /* Functions to manipulate the endianness of the target.  */
 
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.75
diff -u -p -r1.75 arch-utils.h
--- arch-utils.h	5 Aug 2004 14:12:38 -0000	1.75
+++ arch-utils.h	8 Oct 2004 12:29:12 -0000
@@ -119,6 +120,13 @@ extern int generic_convert_register_p (i
 extern int default_stabs_argument_has_addr (struct gdbarch *gdbarch,
 					    struct type *type);
 
+/* By default, just use the dwarf2 val for the type's calling_convention.  */
+extern void default_parse_dwarf2_calling_convention (struct gdbarch *gdbarch,
+						     int has_attr,
+						     unsigned long attr_val,
+						     const char *producer,
+						     struct type *func_type);
+
 /* For compatibility with older architectures, returns
    (LEGACY_SIM_REGNO_IGNORE) when the register doesn't have a valid
    name.  */
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.166
diff -u -p -r1.166 dwarf2read.c
--- dwarf2read.c	6 Oct 2004 08:46:21 -0000	1.166
+++ dwarf2read.c	8 Oct 2004 12:45:52 -0000
@@ -4571,6 +4571,13 @@ read_subroutine_type (struct die_info *d
   type = die_type (die, cu);
   ftype = make_function_type (type, (struct type **) 0);
 
+  /* Check if a calling convention attribute is given. */
+  attr = dwarf2_attr (die, DW_AT_calling_convention, cu);
+  gdbarch_parse_dwarf2_calling_convention (current_gdbarch, !!attr,
+					   attr ? DW_UNSND (attr) : 0,
+					   cu->producer,
+					   ftype);
+
   /* All functions in C++ and Java have prototypes.  */
   attr = dwarf2_attr (die, DW_AT_prototyped, cu);
   if ((attr && (DW_UNSND (attr) != 0))

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat, Inc.


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

* Re: [RFA] Add parse_dwarf2_calling_convention functionality
  2004-10-08 12:47 ` Corinna Vinschen
@ 2004-10-22  3:31   ` Elena Zannoni
  2004-10-25 23:03     ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Elena Zannoni @ 2004-10-22  3:31 UTC (permalink / raw)
  To: gdb-patches

Corinna Vinschen writes:
 > Hi,
 > 
 > On Oct  7 11:54, Corinna Vinschen wrote:
 > > the second patch to prepare the calling convention stuff.  It just adds
 > > the parse_dwarf2_calling_convention functionality to gdbarch.  The
 > > below patch contains only the patch to gdbarch.sh (not the auto-generated
 > > gdbarch.[ch]) and the new default_parse_dwarf2_calling_convention function
 > > in arch-utils.
 > 
 > Corrected patch below.  It seems to be more useful to use the producer
 > field of the compilation unit instead of an artificial "gcc_compiled"
 > flag.  The producer string is easily scanned and the information given
 > is more detailed than just a gcc_compiled flag.
 > 
 > The below patch overrides the previous patch and also contains the
 > necessary change to dwarf2read.c now.
 > 
 > Corinna
 > 
 > 	* gdbarch.sh (parse_dwarf2_calling_convention): New method.
 > 	* gdbarch.h, gdbarch.c: Re-generate.
 > 	* arch-utils.c (default_parse_dwarf2_calling_convention): New function.
 > 	* arch-utils.h (default_parse_dwarf2_calling_convention): New extern
 > 	declaration.
 > 	* dwarf2read.c (read_subroutine_type): Evaluate
 > 	DW_AT_calling_convention attribute and call
 > 	gdbarch_parse_dwarf2_calling_convention appropriately.


The dwarf2read.c part is approved if the rest gets approved.


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

* Re: [RFA] Add parse_dwarf2_calling_convention functionality
  2004-10-22  3:31   ` Elena Zannoni
@ 2004-10-25 23:03     ` Andrew Cagney
  2004-12-14 16:36       ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2004-10-25 23:03 UTC (permalink / raw)
  To: Corinna Vinschen; +Cc: gdb-patches

Elena Zannoni wrote:
> Corinna Vinschen writes:
>  > Hi,
>  > 

>  > Corinna
>  > 
>  > 	* gdbarch.sh (parse_dwarf2_calling_convention): New method.
>  > 	* gdbarch.h, gdbarch.c: Re-generate.
>  > 	* arch-utils.c (default_parse_dwarf2_calling_convention): New function.
>  > 	* arch-utils.h (default_parse_dwarf2_calling_convention): New extern
>  > 	declaration.
>  > 	* dwarf2read.c (read_subroutine_type): Evaluate
>  > 	DW_AT_calling_convention attribute and call
>  > 	gdbarch_parse_dwarf2_calling_convention appropriately.
> 
> 
> The dwarf2read.c part is approved if the rest gets approved.

One mod, rather than adding this:

> +# Evaluate DW_AT_calling_convention value and convert in a calling_convention
> +# value in the functions main type.
> +m::void:parse_dwarf2_calling_convention:int has_attr, unsigned long attr_val, unsigned char gcc_compiled, struct type *func_type:has_attr, attr_val, gcc_compiled, func_type:0:default_parse_dwarf2_calling_convention::0

to the architecture vector, take a look at:

13.2 Per-architecture module data
http://sources.redhat.com/gdb/current/onlinedocs/gdbint_13.html#SEC114

it lets dwarf2 locally manage that method while still being 
per-architecture.

Andrew


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

* Re: [RFA] Add parse_dwarf2_calling_convention functionality
  2004-10-25 23:03     ` Andrew Cagney
@ 2004-12-14 16:36       ` Corinna Vinschen
  0 siblings, 0 replies; 5+ messages in thread
From: Corinna Vinschen @ 2004-12-14 16:36 UTC (permalink / raw)
  To: gdb-patches

Hi,

On Oct 25 19:02, Andrew Cagney wrote:
> Elena Zannoni wrote:
> >Corinna Vinschen writes:
> > > 	* gdbarch.sh (parse_dwarf2_calling_convention): New method.
> > > 	* gdbarch.h, gdbarch.c: Re-generate.
> > > 	* arch-utils.c (default_parse_dwarf2_calling_convention): New 
> > function.
> > > 	* arch-utils.h (default_parse_dwarf2_calling_convention): New extern
> > > 	declaration.
> > > 	* dwarf2read.c (read_subroutine_type): Evaluate
> > > 	DW_AT_calling_convention attribute and call
> > > 	gdbarch_parse_dwarf2_calling_convention appropriately.
> >
> >
> >The dwarf2read.c part is approved if the rest gets approved.
> 
> One mod, rather than adding this:
> 
> >+# Evaluate DW_AT_calling_convention value and convert in a 
> >calling_convention
> >+# value in the functions main type.
> >+m::void:parse_dwarf2_calling_convention:int has_attr, unsigned long 
> >attr_val, unsigned char gcc_compiled, struct type *func_type:has_attr, 
> >attr_val, gcc_compiled, 
> >func_type:0:default_parse_dwarf2_calling_convention::0
> 
> to the architecture vector, take a look at:
> 
> 13.2 Per-architecture module data
> http://sources.redhat.com/gdb/current/onlinedocs/gdbint_13.html#SEC114
> 
> it lets dwarf2 locally manage that method while still being 
> per-architecture.

I'm scratching my head how that's supposed to work.  There's no
architecture specific data, just an architecture specific function
which has to be called for each function in the object file.  Are
you suggesting that the architecture (SH for now) stores a function
pointer in per-arch module data created by _initialize_dwarf2_read?
Then read_subroutine_type() would have to retrieve the function pointer
from the per-arch module data to be able to call it for the function
currently evaluated.  That sounds like overkill.  Or I missed something
essential.  I'd be happy about some more information.


Thanks,
Corinna


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

end of thread, other threads:[~2004-12-14 15:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-07  9:53 [RFA] Add parse_dwarf2_calling_convention functionality Corinna Vinschen
2004-10-08 12:47 ` Corinna Vinschen
2004-10-22  3:31   ` Elena Zannoni
2004-10-25 23:03     ` Andrew Cagney
2004-12-14 16:36       ` Corinna Vinschen

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