Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Set calling convention of methods
@ 2009-04-06 19:51 Jonas Maebe
  2009-04-10 17:34 ` Tom Tromey
  0 siblings, 1 reply; 28+ messages in thread
From: Jonas Maebe @ 2009-04-06 19:51 UTC (permalink / raw)
  To: gdb-patches

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

Hello,

In attachment is my patch to set the calling convention for methods.  
Since the calling convention cannot be defined using stabs, I've  
hardcoded "0" there (which means that nothing changes compared to the  
past). Maybe that should rather be some constant? If so, where should  
it be defined?

The patch is against the "archer" branch of Archer (not the master  
branch as I wrote earlier), but it applies cleanly against CVS head  
with only a bit of fuzz (and compiles). I have tested it in Archer in  
combination with an improved version of my Borland fastcall patch  
(which Mark Kettenis kindly offered to review) and some small changes  
in p-exp.y, and can successfully call both regular and virtual Free  
Pascal methods with it that use the Borland fastcall calling convention.

Thanks,


Jonas

2009-04-06  Jonas Maebe  <jonas.maebe@elis.ugent.be>

	Set the type.type_specific.calling_convention field for methods.

	* gdbtypes.h (smash_to_method_type): Add calling_convention parameter.
	* gdbtypes.c (smash_to_method_type): Set method calling convention  
based
	on calling_convention parameter.
	* dwarf2read.c (dwarf2_add_member_fn): Pass calling convention to
	smash_to_method_type().
	(quirk_gcc_member_function_pointer): Likewise.
	* stabsread.c (read_type): Pass 0 (== default) as calling convention to
	smash_to_method_type().


[-- Attachment #2: gdb_method_calling_conventions.patch --]
[-- Type: application/octet-stream, Size: 2662 bytes --]

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 625c416..59a6f0e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4426,7 +4426,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
 			    TYPE_TARGET_TYPE (this_type),
 			    TYPE_FIELDS (this_type),
 			    TYPE_NFIELDS (this_type),
-			    TYPE_VARARGS (this_type));
+			    TYPE_VARARGS (this_type),
+			    TYPE_CALLING_CONVENTION (this_type));
 
       /* Handle static member functions.
          Dwarf2 has no clean way to discern C++ static and non-static
@@ -4601,7 +4602,8 @@ quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu)
   type = alloc_type (objfile, NULL);
   smash_to_method_type (type, domain_type, TYPE_TARGET_TYPE (pfn_type),
 			TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type),
-			TYPE_VARARGS (pfn_type));
+			TYPE_VARARGS (pfn_type),
+			TYPE_CALLING_CONVENTION (pfn_type));
   type = lookup_methodptr_type (type);
   return set_die_type (die, type, cu);
 }
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 012485c..858d7ca 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1074,7 +1074,7 @@ smash_to_memberptr_type (struct type *type, struct type *domain,
 void
 smash_to_method_type (struct type *type, struct type *domain,
 		      struct type *to_type, struct field *args,
-		      int nargs, int varargs)
+		      int nargs, int varargs, unsigned calling_convention)
 {
   struct objfile *objfile;
 
@@ -1088,6 +1088,7 @@ smash_to_method_type (struct type *type, struct type *domain,
   TYPE_NFIELDS (type) = nargs;
   if (varargs)
     TYPE_VARARGS (type) = 1;
+  TYPE_CALLING_CONVENTION (type) = calling_convention;
   TYPE_LENGTH (type) = 1;	/* In practice, this is never needed.  */
   TYPE_CODE (type) = TYPE_CODE_METHOD;
 }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 9ce920b..ddf4e7b 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1235,7 +1235,8 @@ extern struct type *lookup_methodptr_type (struct type *);
 
 extern void smash_to_method_type (struct type *type, struct type *domain,
 				  struct type *to_type, struct field *args,
-				  int nargs, int varargs);
+				  int nargs, int varargs,
+				  unsigned calling_convention);
 
 extern void smash_to_memberptr_type (struct type *, struct type *,
 				     struct type *);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 3b8eb29..02fac7e 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1868,7 +1868,7 @@ again:
 	    return error_type (pp, objfile);
 	  type = dbx_alloc_type (typenums, objfile);
 	  smash_to_method_type (type, domain, return_type, args,
-				nargs, varargs);
+				nargs, varargs, 0);
 	}
       break;
 

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



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

* Re: [patch] Set calling convention of methods
  2009-04-06 19:51 [patch] Set calling convention of methods Jonas Maebe
@ 2009-04-10 17:34 ` Tom Tromey
  2009-04-20  8:40   ` Jonas Maebe
  0 siblings, 1 reply; 28+ messages in thread
From: Tom Tromey @ 2009-04-10 17:34 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: gdb-patches

>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:

Jonas> In attachment is my patch to set the calling convention for methods.

Do you have a copyright assignment on file?

Jonas> Since the calling convention cannot be defined using stabs, I've
Jonas> hardcoded "0" there (which means that nothing changes compared to the
Jonas> past). Maybe that should rather be some constant? If so, where should
Jonas> it be defined?

Yeah, this is a bit gross.  AFAICT the calling convention field only
takes values from dwarf.  So, I suppose the question is how you plan
to use this information in later patches.  If you check the calling
convention in general code then I suppose we will need some generic
set of values here.

Other than this issue, this looks reasonable to me.

Tom


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

* Re: [patch] Set calling convention of methods
  2009-04-10 17:34 ` Tom Tromey
@ 2009-04-20  8:40   ` Jonas Maebe
  2009-04-20 18:27     ` Tom Tromey
  0 siblings, 1 reply; 28+ messages in thread
From: Jonas Maebe @ 2009-04-20  8:40 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches ml

Sorry for the late reply, I was on holidays.


On 10 Apr 2009, at 19:32, Tom Tromey wrote:

>>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:
>
> Jonas> In attachment is my patch to set the calling convention for  
> methods.
>
> Do you have a copyright assignment on file?

Not yet. I'm in the final stage of getting the waiver from my employer  
to send it to FSF though.

> Jonas> Since the calling convention cannot be defined using stabs,  
> I've
> Jonas> hardcoded "0" there (which means that nothing changes  
> compared to the
> Jonas> past). Maybe that should rather be some constant? If so,  
> where should
> Jonas> it be defined?
>
> Yeah, this is a bit gross.  AFAICT the calling convention field only
> takes values from dwarf.  So, I suppose the question is how you plan
> to use this information in later patches.  If you check the calling
> convention in general code then I suppose we will need some generic
> set of values here.

It is already used in general code (well, in non-DWARF-specific code),  
see the use of DW_CC_GNU_renesas_sh in sh-tdep.c

> Other than this issue, this looks reasonable to me.

Thanks.


Jonas


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

* Re: [patch] Set calling convention of methods
  2009-04-20  8:40   ` Jonas Maebe
@ 2009-04-20 18:27     ` Tom Tromey
  2009-04-22 17:45       ` Jonas Maebe
  0 siblings, 1 reply; 28+ messages in thread
From: Tom Tromey @ 2009-04-20 18:27 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: gdb-patches ml

>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:

Tom> Yeah, this is a bit gross.  AFAICT the calling convention field only
Tom> takes values from dwarf.  So, I suppose the question is how you plan
Tom> to use this information in later patches.  If you check the calling
Tom> convention in general code then I suppose we will need some generic
Tom> set of values here.

Jonas> It is already used in general code (well, in non-DWARF-specific code),
Jonas> see the use of DW_CC_GNU_renesas_sh in sh-tdep.c

Yeah, I saw that.  I suspect that this means that the SH maintainer
knows that DWARF is the only debug format in use on the SH.

"dwarf2.h" is not included in many places in gdb, and not by any
header.  So, assuming your uses of this field will end up in truly
generic code, I think the thing to do is introduce a new enum, and
then translate values in the DWARF reader.  It is tempting to simply
reuse the DWARF enum internally, but I think that goes against the GDB
style.

Tom


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

* Re: [patch] Set calling convention of methods
  2009-04-20 18:27     ` Tom Tromey
@ 2009-04-22 17:45       ` Jonas Maebe
  2009-04-22 19:22         ` Tom Tromey
  2009-04-22 22:16         ` Mark Kettenis
  0 siblings, 2 replies; 28+ messages in thread
From: Jonas Maebe @ 2009-04-22 17:45 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches ml


On 20 Apr 2009, at 20:25, Tom Tromey wrote:

> "dwarf2.h" is not included in many places in gdb, and not by any
> header.  So, assuming your uses of this field will end up in truly
> generic code, I think the thing to do is introduce a new enum, and
> then translate values in the DWARF reader.  It is tempting to simply
> reuse the DWARF enum internally, but I think that goes against the GDB
> style.

Ok, I can adapt my patch to clean that up. I'd prefer my i386 Borland  
fastcall patch to be committed first though, since changing this  
calling convention stuff would also affect that patch. Is that  
possible given my current in-progress state as far as the copyright  
assignment process is concerned? If so, Mark, could you tell me  
whether anything should still be changed in the last version I sent you?

Thanks,


Jonas


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

* Re: [patch] Set calling convention of methods
  2009-04-22 17:45       ` Jonas Maebe
@ 2009-04-22 19:22         ` Tom Tromey
  2009-04-22 22:16         ` Mark Kettenis
  1 sibling, 0 replies; 28+ messages in thread
From: Tom Tromey @ 2009-04-22 19:22 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: gdb-patches ml

>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:

Jonas> I'd prefer my i386 Borland fastcall patch to be committed first
Jonas> though, since changing this calling convention stuff would also
Jonas> affect that patch. Is that possible given my current
Jonas> in-progress state as far as the copyright assignment process is
Jonas> concerned?

I think it is too big to be accepted until the paperwork is
finalized.  At least, if we are talking about:

    http://sourceware.org/ml/gdb-patches/2009-04/msg00057.html

The usual rule is that more than 10 lines of code require paperwork.

Tom


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

* Re: [patch] Set calling convention of methods
  2009-04-22 17:45       ` Jonas Maebe
  2009-04-22 19:22         ` Tom Tromey
@ 2009-04-22 22:16         ` Mark Kettenis
  2009-06-04  8:23           ` Jonas Maebe
  1 sibling, 1 reply; 28+ messages in thread
From: Mark Kettenis @ 2009-04-22 22:16 UTC (permalink / raw)
  To: jonas.maebe; +Cc: tromey, gdb-patches

> From: Jonas Maebe <jonas.maebe@elis.ugent.be>
> Date: Wed, 22 Apr 2009 19:45:22 +0200
> 
> On 20 Apr 2009, at 20:25, Tom Tromey wrote:
> 
> > "dwarf2.h" is not included in many places in gdb, and not by any
> > header.  So, assuming your uses of this field will end up in truly
> > generic code, I think the thing to do is introduce a new enum, and
> > then translate values in the DWARF reader.  It is tempting to simply
> > reuse the DWARF enum internally, but I think that goes against the GDB
> > style.
> 
> Ok, I can adapt my patch to clean that up. I'd prefer my i386 Borland  
> fastcall patch to be committed first though, since changing this  
> calling convention stuff would also affect that patch. Is that  
> possible given my current in-progress state as far as the copyright  
> assignment process is concerned? If so, Mark, could you tell me  
> whether anything should still be changed in the last version I sent you?

That last diff is ok with me, but Tom has a point here.  The effect on
the i386-specific bits should be fairly minimal.

The copyright assignment process needs to be dealt with before we move
forward though.


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

* Re: [patch] Set calling convention of methods
  2009-04-22 22:16         ` Mark Kettenis
@ 2009-06-04  8:23           ` Jonas Maebe
  2009-06-04 18:19             ` Tom Tromey
  0 siblings, 1 reply; 28+ messages in thread
From: Jonas Maebe @ 2009-06-04  8:23 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: tromey, gdb-patches


On 23 Apr 2009, at 00:15, Mark Kettenis wrote:

>> From: Jonas Maebe <jonas.maebe@elis.ugent.be>
>> Date: Wed, 22 Apr 2009 19:45:22 +0200
>>
>> Ok, I can adapt my patch to clean that up. I'd prefer my i386 Borland
>> fastcall patch to be committed first though, since changing this
>> calling convention stuff would also affect that patch. Is that
>> possible given my current in-progress state as far as the copyright
>> assignment process is concerned? If so, Mark, could you tell me
>> whether anything should still be changed in the last version I sent  
>> you?
>
> That last diff is ok with me, but Tom has a point here.  The effect on
> the i386-specific bits should be fairly minimal.
>
> The copyright assignment process needs to be dealt with before we move
> forward though.

It took quite a while, but I'm happy to say that my copyright  
assignment is now complete. I've received my confirmation mail from  
FSF that they received all necessary documents.


Jonas


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

* Re: [patch] Set calling convention of methods
  2009-06-04  8:23           ` Jonas Maebe
@ 2009-06-04 18:19             ` Tom Tromey
  2009-06-10 20:44               ` Jonas Maebe
  2009-07-06 20:50               ` Jonas Maebe
  0 siblings, 2 replies; 28+ messages in thread
From: Tom Tromey @ 2009-06-04 18:19 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: Mark Kettenis, gdb-patches

>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:

Jonas> It took quite a while, but I'm happy to say that my copyright
Jonas> assignment is now complete. I've received my confirmation mail from
Jonas> FSF that they received all necessary documents.

Thanks.  Could you send the URLs of the last versions of your pending
patches?  That would help.

Tom


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

* Re: [patch] Set calling convention of methods
  2009-06-04 18:19             ` Tom Tromey
@ 2009-06-10 20:44               ` Jonas Maebe
  2009-06-18 21:45                 ` Fwd: " Jonas Maebe
  2009-09-30  0:02                 ` Joel Brobecker
  2009-07-06 20:50               ` Jonas Maebe
  1 sibling, 2 replies; 28+ messages in thread
From: Jonas Maebe @ 2009-06-10 20:44 UTC (permalink / raw)
  To: tromey; +Cc: Mark Kettenis, gdb-patches

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


On 04 Jun 2009, at 20:17, Tom Tromey wrote:

>>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:
>
> Jonas> It took quite a while, but I'm happy to say that my copyright
> Jonas> assignment is now complete. I've received my confirmation  
> mail from
> Jonas> FSF that they received all necessary documents.
>
> Thanks.  Could you send the URLs of the last versions of your pending
> patches?  That would help.

I've attached my first patch. Other patches will modify code in this  
one, so I'd prefer to get this one out of the way first.

To Mark: it's slightly different from the last one that I previously  
sent you. There was still a bug whereby the address of the complex  
function result was pushed in the wrong order in case it has to passed  
on the stack (parameters are pushed from right to right, and the  
function result should be pushed before the rightmost parameter rather  
than after the leftmost). Hence, I moved the code to push the function  
result address from the end to the start of the loop pushing the  
memory parameter.

This patch is against the current git://sourceware.org/git/gdb.git

Thanks,


Jonas

2009-06-10  Jonas Maebe  <jonas.maebe@elis.ugent.be>

	Add support for the "Borland fastcall" calling convention.

	* elf/dwarf2.h: Add DW_CC_GNU_borland_fastcall_i386 constant.
	* i386-tdep.c: #include elf/dwarf2.h
	(i386_borland_fastcall_push_dummy_call): New.
	(i386_push_dummy_generic_call): Renamed i386_push_dummy_call.
	(i386_push_dummy_call): New dispatch function that calls
	i386_generic_push_dummy_call or i386_push_dummy_borland_fast_call
	depending on the calling convention.


[-- Attachment #2: gdb_borland_fastcall5.patch --]
[-- Type: application/octet-stream, Size: 7655 bytes --]

diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 60526b0..d559707 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -53,6 +53,8 @@
 #include "record.h"
 #include <stdint.h>
 
+#include "elf/dwarf2.h"
+
 /* Register names.  */
 
 static char *i386_register_names[] =
@@ -1408,7 +1410,7 @@ i386_frame_this_id (struct frame_info *this_frame, void **this_cache,
   if (cache->base == 0)
     return;
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   (*this_id) = frame_id_build (cache->base + 8, cache->pc);
 }
 
@@ -1517,7 +1519,7 @@ i386_sigtramp_frame_this_id (struct frame_info *this_frame, void **this_cache,
   struct i386_frame_cache *cache =
     i386_sigtramp_frame_cache (this_frame, this_cache);
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   (*this_id) = frame_id_build (cache->base + 8, get_frame_pc (this_frame));
 }
 
@@ -1594,7 +1596,7 @@ i386_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 
   fp = get_frame_register_unsigned (this_frame, I386_EBP_REGNUM);
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   return frame_id_build (fp + 8, get_frame_pc (this_frame));
 }
 \f
@@ -1661,10 +1663,10 @@ i386_16_byte_align_p (struct type *type)
 }
 
 static CORE_ADDR
-i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
-		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
-		      struct value **args, CORE_ADDR sp, int struct_return,
-		      CORE_ADDR struct_addr)
+i386_generic_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+			      struct regcache *regcache, CORE_ADDR bp_addr,
+			      int nargs, struct value **args, CORE_ADDR sp,
+			      int struct_return, CORE_ADDR struct_addr)
 {
   gdb_byte buf[4];
   int i;
@@ -1756,6 +1758,162 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   return sp + 8;
 }
 
+/* Borland fastcall: register parameters are passed from left to right, then
+   stack parameters also from left to right.  The first three unstructured
+   parameters <= 32 bits are passed in %eax, %edx and %ecx.  The others are
+   passed on the stack.  Furthermore, in case of a struct return by reference,
+   the address of this struct is passed as the last parameter.  */
+static CORE_ADDR 
+i386_borland_fastcall_push_dummy_call (struct gdbarch *gdbarch, 
+				       struct value *function,
+				       struct regcache *regcache,
+				       CORE_ADDR bp_addr, int nargs,
+				       struct value **args, CORE_ADDR sp,
+				       int struct_return, CORE_ADDR struct_addr)
+{
+  static const int para_regs[3] = { I386_EAX_REGNUM, I386_EDX_REGNUM,
+      I386_ECX_REGNUM };
+
+  gdb_byte buf[4];
+  int reg_paras[3] = { -1, -1, -1 }; 
+  int i, j;
+  int write_pass;
+  int para_regnum = 0;
+
+  /* First assign the register parameters (left to right).  */
+  for (i = 0; i < nargs && para_regnum < 3; i++)
+    {
+      struct type *type = check_typedef (value_enclosing_type (args[i]));
+      int len = TYPE_LENGTH (type);
+
+      if (len <= 4
+	  && TYPE_CODE (type) != TYPE_CODE_ARRAY
+	  && TYPE_CODE (type) != TYPE_CODE_STRUCT
+	  && TYPE_CODE (type) != TYPE_CODE_FLT)
+	{
+	  regcache_cooked_write (regcache, para_regs[para_regnum],
+				 value_contents_all (args[i]));
+	  reg_paras[para_regnum] = i;
+	  para_regnum++;
+	}
+    }  
+  if (struct_return)
+    {
+      if (para_regnum < 3)
+	{
+	  store_unsigned_integer (buf, 4, struct_addr);
+	  regcache_cooked_write (regcache, para_regs[para_regnum],
+				 buf);
+	  /* Use the otherwise invalid "nargs" argument index to denote the
+	     function result.  */
+	  reg_paras[para_regnum] = nargs;
+	  para_regnum++;
+	}
+    }
+
+  /* Now process the stack parameters from left to right.  */
+  for (write_pass = 0; write_pass < 2; write_pass++)
+    {
+      int args_space = 0;
+      int have_16_byte_aligned_arg = 0;
+
+      /* If we have a struct_return then para_regnum cannot be 0, since at
+	 least this return struct would have been passed in a register.
+	 Additionally, if it is passed via a register, it will always be in
+	 the last used position of the reg_paras array.  */
+      if (struct_return
+	  && reg_paras[para_regnum-1] != nargs)
+	{
+	  if (write_pass)
+	    {
+	      /* Push value address.  */
+	      store_unsigned_integer (buf, 4, struct_addr);
+	      write_memory (sp + args_space, buf, 4);
+	    }
+	  args_space += 4;
+	}
+
+      for (i = nargs - 1; i >= 0; i--)
+	{
+	  struct type *type = check_typedef (value_enclosing_type (args[i]));
+	  int len = TYPE_LENGTH (type);
+	  int processed = 0;
+
+	  /* Skip parameters already assigned to registers.  */
+	  for (j = 0; j < para_regnum; j++)
+	    if (reg_paras[j] == i)
+	      {
+		processed = 1;
+		break;
+	      }
+	  if (processed)
+	    continue;
+
+	  if (i386_16_byte_align_p (value_enclosing_type (args[i])))
+	    {
+	      args_space = align_up (args_space, 16);
+	      have_16_byte_aligned_arg = 1;
+	    }
+	  if (write_pass)
+	    {
+	      write_memory (sp + args_space,
+			    value_contents_all (args[i]), len);
+	    }
+	  args_space += align_up (len, 4);
+	}
+
+      if (!write_pass)
+	{
+	  /* Early exit if nothing to do.  */
+	  if (!args_space)
+	    break;
+	  if (have_16_byte_aligned_arg)
+	    args_space = align_up (args_space, 16);
+	  sp -= args_space;
+	}
+    }
+
+  /* Store return address.  */
+  sp -= 4;
+  store_unsigned_integer (buf, 4, bp_addr);
+  write_memory (sp, buf, 4);
+
+  /* Finally, update the stack pointer...  */
+  store_unsigned_integer (buf, 4, sp);
+  regcache_cooked_write (regcache, I386_ESP_REGNUM, buf);
+
+  /* ...and fake a frame pointer.  */
+  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
+
+  /* See the end of i386_generic_push_dummy_call.  */
+  return sp + 8;
+}
+
+static CORE_ADDR
+i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
+		      struct value **args, CORE_ADDR sp, int struct_return,
+		      CORE_ADDR struct_addr)
+{
+  struct type *type = check_typedef (value_type (function));
+
+  /* Look up the target type in case of a function/method pointer.  */
+  while (type
+	 && can_dereference (type))
+    type = TYPE_TARGET_TYPE (type);
+
+  /* Check calling convention.  */
+  if (type
+      && TYPE_CALLING_CONVENTION (type) == DW_CC_GNU_borland_fastcall_i386)
+    return i386_borland_fastcall_push_dummy_call (gdbarch, function, regcache,
+					      bp_addr, nargs, args, sp,
+					      struct_return, struct_addr);
+  else
+    return i386_generic_push_dummy_call (gdbarch, function, regcache, bp_addr,
+					 nargs, args, sp, struct_return,
+					 struct_addr);
+}
+
 /* These registers are used for returning integers (and on some
    targets also for returning `struct' and `union' values when their
    size and alignment match an integer type).  */
diff --git a/include/elf/dwarf2.h b/include/elf/dwarf2.h
index a7448dc..efa786e 100644
--- a/include/elf/dwarf2.h
+++ b/include/elf/dwarf2.h
@@ -662,7 +662,8 @@ enum dwarf_calling_convention
     DW_CC_normal = 0x1,
     DW_CC_program = 0x2,
     DW_CC_nocall = 0x3,
-    DW_CC_GNU_renesas_sh = 0x40
+    DW_CC_GNU_renesas_sh = 0x40,
+    DW_CC_GNU_borland_fastcall_i386 = 0x41
   };
 
 #define DW_CC_lo_user 0x40

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



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

* Fwd: [patch] Set calling convention of methods
  2009-06-10 20:44               ` Jonas Maebe
@ 2009-06-18 21:45                 ` Jonas Maebe
  2009-09-30  0:02                 ` Joel Brobecker
  1 sibling, 0 replies; 28+ messages in thread
From: Jonas Maebe @ 2009-06-18 21:45 UTC (permalink / raw)
  To: gdb-patches ml

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

Ping.


Begin forwarded message:

> From: Jonas Maebe <jonas.maebe@elis.ugent.be>
> Date: Wed 10 Jun 2009 22:44:23 GMT+02:00
> To: tromey@redhat.com
> Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb- 
> patches@sourceware.org
> Subject: Re: [patch] Set calling convention of methods
>
>
> On 04 Jun 2009, at 20:17, Tom Tromey wrote:
>
>>>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:
>>
>> Jonas> It took quite a while, but I'm happy to say that my copyright
>> Jonas> assignment is now complete. I've received my confirmation  
>> mail from
>> Jonas> FSF that they received all necessary documents.
>>
>> Thanks.  Could you send the URLs of the last versions of your pending
>> patches?  That would help.
>
> I've attached my first patch. Other patches will modify code in this  
> one, so I'd prefer to get this one out of the way first.
>
> To Mark: it's slightly different from the last one that I previously  
> sent you. There was still a bug whereby the address of the complex  
> function result was pushed in the wrong order in case it has to  
> passed on the stack (parameters are pushed from right to right, and  
> the function result should be pushed before the rightmost parameter  
> rather than after the leftmost). Hence, I moved the code to push the  
> function result address from the end to the start of the loop  
> pushing the memory parameter.
>
> This patch is against the current git://sourceware.org/git/gdb.git
>
> Thanks,
>
>
> Jonas
>
> 2009-06-10  Jonas Maebe  <jonas.maebe@elis.ugent.be>
>
> 	Add support for the "Borland fastcall" calling convention.
>
> 	* elf/dwarf2.h: Add DW_CC_GNU_borland_fastcall_i386 constant.
> 	* i386-tdep.c: #include elf/dwarf2.h
> 	(i386_borland_fastcall_push_dummy_call): New.
> 	(i386_push_dummy_generic_call): Renamed i386_push_dummy_call.
> 	(i386_push_dummy_call): New dispatch function that calls
> 	i386_generic_push_dummy_call or i386_push_dummy_borland_fast_call
> 	depending on the calling convention.
>

[-- Attachment #2: gdb_borland_fastcall5.patch --]
[-- Type: application/octet-stream, Size: 7655 bytes --]

diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 60526b0..d559707 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -53,6 +53,8 @@
 #include "record.h"
 #include <stdint.h>
 
+#include "elf/dwarf2.h"
+
 /* Register names.  */
 
 static char *i386_register_names[] =
@@ -1408,7 +1410,7 @@ i386_frame_this_id (struct frame_info *this_frame, void **this_cache,
   if (cache->base == 0)
     return;
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   (*this_id) = frame_id_build (cache->base + 8, cache->pc);
 }
 
@@ -1517,7 +1519,7 @@ i386_sigtramp_frame_this_id (struct frame_info *this_frame, void **this_cache,
   struct i386_frame_cache *cache =
     i386_sigtramp_frame_cache (this_frame, this_cache);
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   (*this_id) = frame_id_build (cache->base + 8, get_frame_pc (this_frame));
 }
 
@@ -1594,7 +1596,7 @@ i386_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 
   fp = get_frame_register_unsigned (this_frame, I386_EBP_REGNUM);
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   return frame_id_build (fp + 8, get_frame_pc (this_frame));
 }
 \f
@@ -1661,10 +1663,10 @@ i386_16_byte_align_p (struct type *type)
 }
 
 static CORE_ADDR
-i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
-		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
-		      struct value **args, CORE_ADDR sp, int struct_return,
-		      CORE_ADDR struct_addr)
+i386_generic_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+			      struct regcache *regcache, CORE_ADDR bp_addr,
+			      int nargs, struct value **args, CORE_ADDR sp,
+			      int struct_return, CORE_ADDR struct_addr)
 {
   gdb_byte buf[4];
   int i;
@@ -1756,6 +1758,162 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   return sp + 8;
 }
 
+/* Borland fastcall: register parameters are passed from left to right, then
+   stack parameters also from left to right.  The first three unstructured
+   parameters <= 32 bits are passed in %eax, %edx and %ecx.  The others are
+   passed on the stack.  Furthermore, in case of a struct return by reference,
+   the address of this struct is passed as the last parameter.  */
+static CORE_ADDR 
+i386_borland_fastcall_push_dummy_call (struct gdbarch *gdbarch, 
+				       struct value *function,
+				       struct regcache *regcache,
+				       CORE_ADDR bp_addr, int nargs,
+				       struct value **args, CORE_ADDR sp,
+				       int struct_return, CORE_ADDR struct_addr)
+{
+  static const int para_regs[3] = { I386_EAX_REGNUM, I386_EDX_REGNUM,
+      I386_ECX_REGNUM };
+
+  gdb_byte buf[4];
+  int reg_paras[3] = { -1, -1, -1 }; 
+  int i, j;
+  int write_pass;
+  int para_regnum = 0;
+
+  /* First assign the register parameters (left to right).  */
+  for (i = 0; i < nargs && para_regnum < 3; i++)
+    {
+      struct type *type = check_typedef (value_enclosing_type (args[i]));
+      int len = TYPE_LENGTH (type);
+
+      if (len <= 4
+	  && TYPE_CODE (type) != TYPE_CODE_ARRAY
+	  && TYPE_CODE (type) != TYPE_CODE_STRUCT
+	  && TYPE_CODE (type) != TYPE_CODE_FLT)
+	{
+	  regcache_cooked_write (regcache, para_regs[para_regnum],
+				 value_contents_all (args[i]));
+	  reg_paras[para_regnum] = i;
+	  para_regnum++;
+	}
+    }  
+  if (struct_return)
+    {
+      if (para_regnum < 3)
+	{
+	  store_unsigned_integer (buf, 4, struct_addr);
+	  regcache_cooked_write (regcache, para_regs[para_regnum],
+				 buf);
+	  /* Use the otherwise invalid "nargs" argument index to denote the
+	     function result.  */
+	  reg_paras[para_regnum] = nargs;
+	  para_regnum++;
+	}
+    }
+
+  /* Now process the stack parameters from left to right.  */
+  for (write_pass = 0; write_pass < 2; write_pass++)
+    {
+      int args_space = 0;
+      int have_16_byte_aligned_arg = 0;
+
+      /* If we have a struct_return then para_regnum cannot be 0, since at
+	 least this return struct would have been passed in a register.
+	 Additionally, if it is passed via a register, it will always be in
+	 the last used position of the reg_paras array.  */
+      if (struct_return
+	  && reg_paras[para_regnum-1] != nargs)
+	{
+	  if (write_pass)
+	    {
+	      /* Push value address.  */
+	      store_unsigned_integer (buf, 4, struct_addr);
+	      write_memory (sp + args_space, buf, 4);
+	    }
+	  args_space += 4;
+	}
+
+      for (i = nargs - 1; i >= 0; i--)
+	{
+	  struct type *type = check_typedef (value_enclosing_type (args[i]));
+	  int len = TYPE_LENGTH (type);
+	  int processed = 0;
+
+	  /* Skip parameters already assigned to registers.  */
+	  for (j = 0; j < para_regnum; j++)
+	    if (reg_paras[j] == i)
+	      {
+		processed = 1;
+		break;
+	      }
+	  if (processed)
+	    continue;
+
+	  if (i386_16_byte_align_p (value_enclosing_type (args[i])))
+	    {
+	      args_space = align_up (args_space, 16);
+	      have_16_byte_aligned_arg = 1;
+	    }
+	  if (write_pass)
+	    {
+	      write_memory (sp + args_space,
+			    value_contents_all (args[i]), len);
+	    }
+	  args_space += align_up (len, 4);
+	}
+
+      if (!write_pass)
+	{
+	  /* Early exit if nothing to do.  */
+	  if (!args_space)
+	    break;
+	  if (have_16_byte_aligned_arg)
+	    args_space = align_up (args_space, 16);
+	  sp -= args_space;
+	}
+    }
+
+  /* Store return address.  */
+  sp -= 4;
+  store_unsigned_integer (buf, 4, bp_addr);
+  write_memory (sp, buf, 4);
+
+  /* Finally, update the stack pointer...  */
+  store_unsigned_integer (buf, 4, sp);
+  regcache_cooked_write (regcache, I386_ESP_REGNUM, buf);
+
+  /* ...and fake a frame pointer.  */
+  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
+
+  /* See the end of i386_generic_push_dummy_call.  */
+  return sp + 8;
+}
+
+static CORE_ADDR
+i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
+		      struct value **args, CORE_ADDR sp, int struct_return,
+		      CORE_ADDR struct_addr)
+{
+  struct type *type = check_typedef (value_type (function));
+
+  /* Look up the target type in case of a function/method pointer.  */
+  while (type
+	 && can_dereference (type))
+    type = TYPE_TARGET_TYPE (type);
+
+  /* Check calling convention.  */
+  if (type
+      && TYPE_CALLING_CONVENTION (type) == DW_CC_GNU_borland_fastcall_i386)
+    return i386_borland_fastcall_push_dummy_call (gdbarch, function, regcache,
+					      bp_addr, nargs, args, sp,
+					      struct_return, struct_addr);
+  else
+    return i386_generic_push_dummy_call (gdbarch, function, regcache, bp_addr,
+					 nargs, args, sp, struct_return,
+					 struct_addr);
+}
+
 /* These registers are used for returning integers (and on some
    targets also for returning `struct' and `union' values when their
    size and alignment match an integer type).  */
diff --git a/include/elf/dwarf2.h b/include/elf/dwarf2.h
index a7448dc..efa786e 100644
--- a/include/elf/dwarf2.h
+++ b/include/elf/dwarf2.h
@@ -662,7 +662,8 @@ enum dwarf_calling_convention
     DW_CC_normal = 0x1,
     DW_CC_program = 0x2,
     DW_CC_nocall = 0x3,
-    DW_CC_GNU_renesas_sh = 0x40
+    DW_CC_GNU_renesas_sh = 0x40,
+    DW_CC_GNU_borland_fastcall_i386 = 0x41
   };
 
 #define DW_CC_lo_user 0x40

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

>


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

* Re: [patch] Set calling convention of methods
  2009-06-04 18:19             ` Tom Tromey
  2009-06-10 20:44               ` Jonas Maebe
@ 2009-07-06 20:50               ` Jonas Maebe
  1 sibling, 0 replies; 28+ messages in thread
From: Jonas Maebe @ 2009-07-06 20:50 UTC (permalink / raw)
  To: tromey; +Cc: Mark Kettenis, gdb-patches

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

Ping.


On 04 Jun 2009, at 20:17, Tom Tromey wrote:

>>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:
>
> Jonas> It took quite a while, but I'm happy to say that my copyright
> Jonas> assignment is now complete. I've received my confirmation  
> mail from
> Jonas> FSF that they received all necessary documents.
>
> Thanks.  Could you send the URLs of the last versions of your pending
> patches?  That would help.

I've attached my first patch. Other patches will modify code in this  
one, so I'd prefer to get this one out of the way first.

To Mark: it's slightly different from the last one that I previously  
sent you. There was still a bug whereby the address of the complex  
function result was pushed in the wrong order in case it has to passed  
on the stack (parameters are pushed from right to right, and the  
function result should be pushed before the rightmost parameter rather  
than after the leftmost). Hence, I moved the code to push the function  
result address from the end to the start of the loop pushing the  
memory parameter.

This patch is against the current git://sourceware.org/git/gdb.git

Thanks,


Jonas

2009-06-10  Jonas Maebe  <jonas.maebe@elis.ugent.be>

	Add support for the "Borland fastcall" calling convention.

	* elf/dwarf2.h: Add DW_CC_GNU_borland_fastcall_i386 constant.
	* i386-tdep.c: #include elf/dwarf2.h
	(i386_borland_fastcall_push_dummy_call): New.
	(i386_push_dummy_generic_call): Renamed i386_push_dummy_call.
	(i386_push_dummy_call): New dispatch function that calls
	i386_generic_push_dummy_call or i386_push_dummy_borland_fast_call
	depending on the calling convention.


[-- Attachment #2: gdb_borland_fastcall5.patch --]
[-- Type: application/octet-stream, Size: 7655 bytes --]

diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 60526b0..d559707 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -53,6 +53,8 @@
 #include "record.h"
 #include <stdint.h>
 
+#include "elf/dwarf2.h"
+
 /* Register names.  */
 
 static char *i386_register_names[] =
@@ -1408,7 +1410,7 @@ i386_frame_this_id (struct frame_info *this_frame, void **this_cache,
   if (cache->base == 0)
     return;
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   (*this_id) = frame_id_build (cache->base + 8, cache->pc);
 }
 
@@ -1517,7 +1519,7 @@ i386_sigtramp_frame_this_id (struct frame_info *this_frame, void **this_cache,
   struct i386_frame_cache *cache =
     i386_sigtramp_frame_cache (this_frame, this_cache);
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   (*this_id) = frame_id_build (cache->base + 8, get_frame_pc (this_frame));
 }
 
@@ -1594,7 +1596,7 @@ i386_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 
   fp = get_frame_register_unsigned (this_frame, I386_EBP_REGNUM);
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   return frame_id_build (fp + 8, get_frame_pc (this_frame));
 }
 \f
@@ -1661,10 +1663,10 @@ i386_16_byte_align_p (struct type *type)
 }
 
 static CORE_ADDR
-i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
-		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
-		      struct value **args, CORE_ADDR sp, int struct_return,
-		      CORE_ADDR struct_addr)
+i386_generic_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+			      struct regcache *regcache, CORE_ADDR bp_addr,
+			      int nargs, struct value **args, CORE_ADDR sp,
+			      int struct_return, CORE_ADDR struct_addr)
 {
   gdb_byte buf[4];
   int i;
@@ -1756,6 +1758,162 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   return sp + 8;
 }
 
+/* Borland fastcall: register parameters are passed from left to right, then
+   stack parameters also from left to right.  The first three unstructured
+   parameters <= 32 bits are passed in %eax, %edx and %ecx.  The others are
+   passed on the stack.  Furthermore, in case of a struct return by reference,
+   the address of this struct is passed as the last parameter.  */
+static CORE_ADDR 
+i386_borland_fastcall_push_dummy_call (struct gdbarch *gdbarch, 
+				       struct value *function,
+				       struct regcache *regcache,
+				       CORE_ADDR bp_addr, int nargs,
+				       struct value **args, CORE_ADDR sp,
+				       int struct_return, CORE_ADDR struct_addr)
+{
+  static const int para_regs[3] = { I386_EAX_REGNUM, I386_EDX_REGNUM,
+      I386_ECX_REGNUM };
+
+  gdb_byte buf[4];
+  int reg_paras[3] = { -1, -1, -1 }; 
+  int i, j;
+  int write_pass;
+  int para_regnum = 0;
+
+  /* First assign the register parameters (left to right).  */
+  for (i = 0; i < nargs && para_regnum < 3; i++)
+    {
+      struct type *type = check_typedef (value_enclosing_type (args[i]));
+      int len = TYPE_LENGTH (type);
+
+      if (len <= 4
+	  && TYPE_CODE (type) != TYPE_CODE_ARRAY
+	  && TYPE_CODE (type) != TYPE_CODE_STRUCT
+	  && TYPE_CODE (type) != TYPE_CODE_FLT)
+	{
+	  regcache_cooked_write (regcache, para_regs[para_regnum],
+				 value_contents_all (args[i]));
+	  reg_paras[para_regnum] = i;
+	  para_regnum++;
+	}
+    }  
+  if (struct_return)
+    {
+      if (para_regnum < 3)
+	{
+	  store_unsigned_integer (buf, 4, struct_addr);
+	  regcache_cooked_write (regcache, para_regs[para_regnum],
+				 buf);
+	  /* Use the otherwise invalid "nargs" argument index to denote the
+	     function result.  */
+	  reg_paras[para_regnum] = nargs;
+	  para_regnum++;
+	}
+    }
+
+  /* Now process the stack parameters from left to right.  */
+  for (write_pass = 0; write_pass < 2; write_pass++)
+    {
+      int args_space = 0;
+      int have_16_byte_aligned_arg = 0;
+
+      /* If we have a struct_return then para_regnum cannot be 0, since at
+	 least this return struct would have been passed in a register.
+	 Additionally, if it is passed via a register, it will always be in
+	 the last used position of the reg_paras array.  */
+      if (struct_return
+	  && reg_paras[para_regnum-1] != nargs)
+	{
+	  if (write_pass)
+	    {
+	      /* Push value address.  */
+	      store_unsigned_integer (buf, 4, struct_addr);
+	      write_memory (sp + args_space, buf, 4);
+	    }
+	  args_space += 4;
+	}
+
+      for (i = nargs - 1; i >= 0; i--)
+	{
+	  struct type *type = check_typedef (value_enclosing_type (args[i]));
+	  int len = TYPE_LENGTH (type);
+	  int processed = 0;
+
+	  /* Skip parameters already assigned to registers.  */
+	  for (j = 0; j < para_regnum; j++)
+	    if (reg_paras[j] == i)
+	      {
+		processed = 1;
+		break;
+	      }
+	  if (processed)
+	    continue;
+
+	  if (i386_16_byte_align_p (value_enclosing_type (args[i])))
+	    {
+	      args_space = align_up (args_space, 16);
+	      have_16_byte_aligned_arg = 1;
+	    }
+	  if (write_pass)
+	    {
+	      write_memory (sp + args_space,
+			    value_contents_all (args[i]), len);
+	    }
+	  args_space += align_up (len, 4);
+	}
+
+      if (!write_pass)
+	{
+	  /* Early exit if nothing to do.  */
+	  if (!args_space)
+	    break;
+	  if (have_16_byte_aligned_arg)
+	    args_space = align_up (args_space, 16);
+	  sp -= args_space;
+	}
+    }
+
+  /* Store return address.  */
+  sp -= 4;
+  store_unsigned_integer (buf, 4, bp_addr);
+  write_memory (sp, buf, 4);
+
+  /* Finally, update the stack pointer...  */
+  store_unsigned_integer (buf, 4, sp);
+  regcache_cooked_write (regcache, I386_ESP_REGNUM, buf);
+
+  /* ...and fake a frame pointer.  */
+  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
+
+  /* See the end of i386_generic_push_dummy_call.  */
+  return sp + 8;
+}
+
+static CORE_ADDR
+i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
+		      struct value **args, CORE_ADDR sp, int struct_return,
+		      CORE_ADDR struct_addr)
+{
+  struct type *type = check_typedef (value_type (function));
+
+  /* Look up the target type in case of a function/method pointer.  */
+  while (type
+	 && can_dereference (type))
+    type = TYPE_TARGET_TYPE (type);
+
+  /* Check calling convention.  */
+  if (type
+      && TYPE_CALLING_CONVENTION (type) == DW_CC_GNU_borland_fastcall_i386)
+    return i386_borland_fastcall_push_dummy_call (gdbarch, function, regcache,
+					      bp_addr, nargs, args, sp,
+					      struct_return, struct_addr);
+  else
+    return i386_generic_push_dummy_call (gdbarch, function, regcache, bp_addr,
+					 nargs, args, sp, struct_return,
+					 struct_addr);
+}
+
 /* These registers are used for returning integers (and on some
    targets also for returning `struct' and `union' values when their
    size and alignment match an integer type).  */
diff --git a/include/elf/dwarf2.h b/include/elf/dwarf2.h
index a7448dc..efa786e 100644
--- a/include/elf/dwarf2.h
+++ b/include/elf/dwarf2.h
@@ -662,7 +662,8 @@ enum dwarf_calling_convention
     DW_CC_normal = 0x1,
     DW_CC_program = 0x2,
     DW_CC_nocall = 0x3,
-    DW_CC_GNU_renesas_sh = 0x40
+    DW_CC_GNU_renesas_sh = 0x40,
+    DW_CC_GNU_borland_fastcall_i386 = 0x41
   };
 
 #define DW_CC_lo_user 0x40

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



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

* Re: [patch] Set calling convention of methods
  2009-06-10 20:44               ` Jonas Maebe
  2009-06-18 21:45                 ` Fwd: " Jonas Maebe
@ 2009-09-30  0:02                 ` Joel Brobecker
  2009-09-30 11:18                   ` Jonas Maebe
  1 sibling, 1 reply; 28+ messages in thread
From: Joel Brobecker @ 2009-09-30  0:02 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: tromey, Mark Kettenis, gdb-patches

> I've attached my first patch. Other patches will modify code in this  
> one, so I'd prefer to get this one out of the way first.

But it looks like this patch actually introduces code that will be dead
until you actually set the calling convention, right? It seems strange
that you'd prefer to do it this way.

> 2009-06-10  Jonas Maebe  <jonas.maebe@elis.ugent.be>
>
> 	Add support for the "Borland fastcall" calling convention.
>
> 	* elf/dwarf2.h: Add DW_CC_GNU_borland_fastcall_i386 constant.
> 	* i386-tdep.c: #include elf/dwarf2.h
> 	(i386_borland_fastcall_push_dummy_call): New.
> 	(i386_push_dummy_generic_call): Renamed i386_push_dummy_call.
> 	(i386_push_dummy_call): New dispatch function that calls
> 	i386_generic_push_dummy_call or i386_push_dummy_borland_fast_call
> 	depending on the calling convention.

One of the concerns that never got resolved from what I've read in the
archives, was the use of a DWARF constant outside of DWARF code.
I am not sure I understand the problem, though. Was it the use of
constant zero when populating this field when reading stabs debug
info, or anything else?

As far as I am concerned, I can't see a problem with using DWARF
declarations even from stabs.

Just a couple of formatting nits:

> +      if (struct_return
> +	  && reg_paras[para_regnum-1] != nargs)

and

> +  while (type
> +	 && can_dereference (type))

You probably want to join the two lines in one. gdb_indent.sh, our
automatic indentation program would (though no one uses it, it makes
pretty bad choices sometimes). I think it'd make the code a little
easier to read too.

> diff --git a/include/elf/dwarf2.h b/include/elf/dwarf2.h
> index a7448dc..efa786e 100644
> --- a/include/elf/dwarf2.h
> +++ b/include/elf/dwarf2.h
> @@ -662,7 +662,8 @@ enum dwarf_calling_convention
>      DW_CC_normal = 0x1,
>      DW_CC_program = 0x2,
>      DW_CC_nocall = 0x3,
> -    DW_CC_GNU_renesas_sh = 0x40
> +    DW_CC_GNU_renesas_sh = 0x40,
> +    DW_CC_GNU_borland_fastcall_i386 = 0x41

This part is maintained by binutils, I believe.  You'll need
to ask them for approval of this change.

-- 
Joel


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

* Re: [patch] Set calling convention of methods
  2009-09-30  0:02                 ` Joel Brobecker
@ 2009-09-30 11:18                   ` Jonas Maebe
  2009-09-30 14:54                     ` Jonas Maebe
                                       ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Jonas Maebe @ 2009-09-30 11:18 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: tromey, Mark Kettenis, gdb-patches


On 30 Sep 2009, at 02:02, Joel Brobecker wrote:

>> I've attached my first patch. Other patches will modify code in this
>> one, so I'd prefer to get this one out of the way first.
>
> But it looks like this patch actually introduces code that will be  
> dead
> until you actually set the calling convention, right? It seems strange
> that you'd prefer to do it this way.

It will already be active for regular functions/procedures, because  
the DWARF reader does propagate the calling convention in that case  
(as it was already done for the DW_CC_GNU_renesas_sh calling  
convention). It simply won't be taken into account yet for methods  
(because that requires a patch to the DWARF reader), that will indeed  
require a further patch.

> One of the concerns that never got resolved from what I've read in the
> archives, was the use of a DWARF constant outside of DWARF code.
> I am not sure I understand the problem, though. Was it the use of
> constant zero when populating this field when reading stabs debug
> info, or anything else?

Yes, it was the use of an unnamed constant: http://sourceware.org/ml/gdb-patches/2009-04/msg00196.html

> As far as I am concerned, I can't see a problem with using DWARF
> declarations even from stabs.

We could include the dwarf2.h header in the stabs reader and set the  
calling convention to DW_CC_normal in all cases.

> Just a couple of formatting nits:
>
>> +      if (struct_return
>> +	  && reg_paras[para_regnum-1] != nargs)
>
> and
>
>> +  while (type
>> +	 && can_dereference (type))
>
> You probably want to join the two lines in one. gdb_indent.sh, our
> automatic indentation program would (though no one uses it, it makes
> pretty bad choices sometimes). I think it'd make the code a little
> easier to read too.

Ok, will do.

> diff --git a/include/elf/dwarf2.h b/include/elf/dwarf2.h
>> index a7448dc..efa786e 100644
>> --- a/include/elf/dwarf2.h
>> +++ b/include/elf/dwarf2.h
>> @@ -662,7 +662,8 @@ enum dwarf_calling_convention
>>     DW_CC_normal = 0x1,
>>     DW_CC_program = 0x2,
>>     DW_CC_nocall = 0x3,
>> -    DW_CC_GNU_renesas_sh = 0x40
>> +    DW_CC_GNU_renesas_sh = 0x40,
>> +    DW_CC_GNU_borland_fastcall_i386 = 0x41
>
> This part is maintained by binutils, I believe.  You'll need
> to ask them for approval of this change.

Tom said it came from gcc (http://sourceware.org/ml/gdb-patches/2009-04/msg00063.html 
) and I did submit a patch there: http://gcc.gnu.org/ml/gcc-patches/2009-04/msg00301.html 
  . I did not get any reaction to that patch (and I guess it's not  
been applied).

Later on, Tom clarified that he thought that the gdb and gcc versions  
of dwarf2.h should actually be merged into a single copy, but that I  
shouldn't worry about this since the divergence started before my  
patch: http://sourceware.org/ml/gdb-patches/2009-04/msg00099.html


Jonas


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

* Re: [patch] Set calling convention of methods
  2009-09-30 11:18                   ` Jonas Maebe
@ 2009-09-30 14:54                     ` Jonas Maebe
  2009-09-30 15:22                       ` Mark Kettenis
  2009-09-30 16:25                       ` Joel Brobecker
  2009-09-30 16:10                     ` Joel Brobecker
  2009-09-30 16:47                     ` Tom Tromey
  2 siblings, 2 replies; 28+ messages in thread
From: Jonas Maebe @ 2009-09-30 14:54 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, Mark Kettenis, gdb-patches ml

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


On 30 Sep 2009, at 13:18, Jonas Maebe wrote:

> On 30 Sep 2009, at 02:02, Joel Brobecker wrote:
>
>> One of the concerns that never got resolved from what I've read in  
>> the
>> archives, was the use of a DWARF constant outside of DWARF code.
>> I am not sure I understand the problem, though. Was it the use of
>> constant zero when populating this field when reading stabs debug
>> info, or anything else?
>
> Yes, it was the use of an unnamed constant: http://sourceware.org/ml/gdb-patches/2009-04/msg00196.html

Note that the patch under discussion right now is unrelated to that  
concern, as it does not yet make any modification to the Stabs reader  
(that's only required once calling conventions are stored for methods).

I've also attached a version of the patch that applies against current  
gdb head (dwarf2.h was moved from include/elf to include,  
store_unsigned_integer now takes an extra byte_order parameter).  
Additionally, I've added a test, because even in my previous new  
version I messed up struct returns. This test should prevent that from  
happening again.


Jonas

2009-09-30  Jonas Maebe  <jonas.maebe <at> elis.ugent.be>

	Add support for the "Borland fastcall" calling convention.

	* dwarf2.h: Add DW_CC_GNU_borland_fastcall_i386 constant.
	* i386-tdep.c: #include dwarf2.h
	(i386_borland_fastcall_push_dummy_call): New.
	(i386_push_dummy_generic_call): Renamed i386_push_dummy_call.
	(i386_push_dummy_call): New dispatch function that calls
	i386_generic_push_dummy_call or i386_push_dummy_borland_fast_call
	depending on the calling convention.
	* gdb.dwarf2/dw2-borland_fastcall.exp: New.
	* gdb.dwarf2/dw2-borland_fastcall.S: New.


[-- Attachment #2: gdb_borland_fastcall6.patch --]
[-- Type: application/octet-stream, Size: 24757 bytes --]

diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index b79bcd2..bd8844e 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -53,6 +53,8 @@
 #include "record.h"
 #include <stdint.h>
 
+#include "dwarf2.h"
+
 /* Register names.  */
 
 static char *i386_register_names[] =
@@ -1426,7 +1428,7 @@ i386_frame_this_id (struct frame_info *this_frame, void **this_cache,
   if (cache->base == 0)
     return;
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   (*this_id) = frame_id_build (cache->base + 8, cache->pc);
 }
 
@@ -1620,7 +1622,7 @@ i386_sigtramp_frame_this_id (struct frame_info *this_frame, void **this_cache,
   struct i386_frame_cache *cache =
     i386_sigtramp_frame_cache (this_frame, this_cache);
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   (*this_id) = frame_id_build (cache->base + 8, get_frame_pc (this_frame));
 }
 
@@ -1697,7 +1699,7 @@ i386_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 
   fp = get_frame_register_unsigned (this_frame, I386_EBP_REGNUM);
 
-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
   return frame_id_build (fp + 8, get_frame_pc (this_frame));
 }
 \f
@@ -1765,10 +1767,10 @@ i386_16_byte_align_p (struct type *type)
 }
 
 static CORE_ADDR
-i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
-		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
-		      struct value **args, CORE_ADDR sp, int struct_return,
-		      CORE_ADDR struct_addr)
+i386_generic_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+			      struct regcache *regcache, CORE_ADDR bp_addr,
+			      int nargs, struct value **args, CORE_ADDR sp,
+			      int struct_return, CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
@@ -1861,6 +1863,144 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   return sp + 8;
 }
 
+/* Borland fastcall: register parameters are passed from left to right, then
+   stack parameters also from left to right.  The first three unstructured
+   parameters <= 32 bits are passed in %eax, %edx and %ecx.  The others are
+   passed on the stack.  Furthermore, in case of a struct return by reference,
+   the address of this struct is passed as the last parameter.  */
+static CORE_ADDR 
+i386_borland_fastcall_push_dummy_call (struct gdbarch *gdbarch, 
+				       struct value *function,
+				       struct regcache *regcache,
+				       CORE_ADDR bp_addr, int nargs,
+				       struct value **args, CORE_ADDR sp,
+				       int struct_return, CORE_ADDR struct_addr)
+{
+  static const int para_regs[3] = { I386_EAX_REGNUM, I386_EDX_REGNUM,
+      I386_ECX_REGNUM };
+
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  gdb_byte buf[4];
+  int reg_paras[3] = { -1, -1, -1 }; 
+  int i, j;
+  int write_pass;
+  int para_regnum = 0;
+
+  /* First assign the register parameters (left to right).  */
+  if (struct_return)
+    {
+      store_unsigned_integer (buf, 4, byte_order, struct_addr);
+      regcache_cooked_write (regcache, para_regs[para_regnum],
+				 buf);
+      /* Use the otherwise invalid "nargs" argument index to denote the
+         function result.  */
+      reg_paras[para_regnum] = nargs;
+      para_regnum++;
+    }
+
+  for (i = 0; i < nargs && para_regnum < 3; i++)
+    {
+      struct type *type = check_typedef (value_enclosing_type (args[i]));
+      int len = TYPE_LENGTH (type);
+
+      if (len <= 4
+	  && TYPE_CODE (type) != TYPE_CODE_ARRAY
+	  && TYPE_CODE (type) != TYPE_CODE_STRUCT
+	  && TYPE_CODE (type) != TYPE_CODE_FLT)
+	{
+	  regcache_cooked_write (regcache, para_regs[para_regnum],
+				 value_contents_all (args[i]));
+	  reg_paras[para_regnum] = i;
+	  para_regnum++;
+	}
+    }  
+
+  /* Now process the stack parameters from left to right.  */
+  for (write_pass = 0; write_pass < 2; write_pass++)
+    {
+      int args_space = 0;
+      int have_16_byte_aligned_arg = 0;
+
+      for (i = nargs - 1; i >= 0; i--)
+	{
+	  struct type *type = check_typedef (value_enclosing_type (args[i]));
+	  int len = TYPE_LENGTH (type);
+	  int processed = 0;
+
+	  /* Skip parameters already assigned to registers.  */
+	  for (j = 0; j < para_regnum; j++)
+	    if (reg_paras[j] == i)
+	      {
+		processed = 1;
+		break;
+	      }
+	  if (processed)
+	    continue;
+
+	  if (i386_16_byte_align_p (value_enclosing_type (args[i])))
+	    {
+	      args_space = align_up (args_space, 16);
+	      have_16_byte_aligned_arg = 1;
+	    }
+	  if (write_pass)
+	    {
+	      write_memory (sp + args_space,
+			    value_contents_all (args[i]), len);
+	    }
+	  args_space += align_up (len, 4);
+	}
+
+      if (!write_pass)
+	{
+	  /* Early exit if nothing to do.  */
+	  if (!args_space)
+	    break;
+	  if (have_16_byte_aligned_arg)
+	    args_space = align_up (args_space, 16);
+	  sp -= args_space;
+	}
+    }
+
+  /* Store return address.  */
+  sp -= 4;
+  store_unsigned_integer (buf, 4, byte_order, bp_addr);
+  write_memory (sp, buf, 4);
+
+  /* Finally, update the stack pointer...  */
+  store_unsigned_integer (buf, 4, byte_order, sp);
+  regcache_cooked_write (regcache, I386_ESP_REGNUM, buf);
+
+  /* ...and fake a frame pointer.  */
+  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
+
+  /* See the end of i386_generic_push_dummy_call.  */
+  return sp + 8;
+}
+
+static CORE_ADDR
+i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
+		      struct value **args, CORE_ADDR sp, int struct_return,
+		      CORE_ADDR struct_addr)
+{
+  struct type *type = check_typedef (value_type (function));
+
+  /* Look up the target type in case of a function/method pointer.  */
+  while (type && can_dereference (type))
+    type = TYPE_TARGET_TYPE (type);
+
+  /* Check calling convention.  */
+  if (type
+      && TYPE_CALLING_CONVENTION (type) == DW_CC_GNU_borland_fastcall_i386)
+    return i386_borland_fastcall_push_dummy_call (gdbarch, function, regcache,
+					      bp_addr, nargs, args, sp,
+					      struct_return, struct_addr);
+  else
+    return i386_generic_push_dummy_call (gdbarch, function, regcache, bp_addr,
+					 nargs, args, sp, struct_return,
+					 struct_addr);
+}
+
 /* These registers are used for returning integers (and on some
    targets also for returning `struct' and `union' values when their
    size and alignment match an integer type).  */
diff --git a/include/dwarf2.h b/include/dwarf2.h
index 385ab22..9e4459a 100644
--- a/include/dwarf2.h
+++ b/include/dwarf2.h
@@ -721,7 +721,8 @@ enum dwarf_calling_convention
     DW_CC_lo_user = 0x40,
     DW_CC_hi_user = 0xff,
 
-    DW_CC_GNU_renesas_sh = 0x40
+    DW_CC_GNU_renesas_sh = 0x40,
+    DW_CC_GNU_borland_fastcall_i386 = 0x41
   };
 
 /* Inline attribute.  */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.S b/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.S
new file mode 100644
index 0000000..002d40e
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.S
@@ -0,0 +1,943 @@
+	.file "tgdbcc.pp"
+# Begin asmlist al_begin
+
+.section .debug_line
+	.type	.Ldebug_linesection0,@object
+.Ldebug_linesection0:
+	.type	.Ldebug_line0,@object
+.Ldebug_line0:
+
+.section .debug_abbrev
+	.type	.Ldebug_abbrevsection0,@object
+.Ldebug_abbrevsection0:
+	.type	.Ldebug_abbrev0,@object
+.Ldebug_abbrev0:
+
+.section .text
+.globl	DEBUGSTART_P$PROGRAM
+	.type	DEBUGSTART_P$PROGRAM,@object
+DEBUGSTART_P$PROGRAM:
+# End asmlist al_begin
+# Begin asmlist al_stabs
+# End asmlist al_stabs
+# Begin asmlist al_procedures
+
+.section .text
+	.balign 16,0x90
+.globl	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+	.type	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR,@function
+P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR:
+.Lc1:
+# Temps allocated between ebp-12 and ebp-12
+.Ll1:
+# [tgdbcc.pp]
+# [10] begin
+	pushl	%ebp
+.Lc3:
+.Lc4:
+	movl	%esp,%ebp
+.Lc5:
+	subl	$12,%esp
+# Var a located at ebp-4
+# Var b located at ebp-8
+# Var c located at ebp+20
+# Var d located at ebp+16
+# Var e located at ebp+12
+# Var f located at ebp+8
+# Var $result located at ebp-12
+	movl	%eax,-12(%ebp)
+	movb	%dl,-4(%ebp)
+	movb	%cl,-8(%ebp)
+.Ll2:
+# [11] fillchar(result.g,sizeof(result.g),0);
+	pushl	%edi
+	movl	-12(%ebp),%edi
+	leal	6(%edi),%edi
+	xorl	%eax,%eax
+	movl	$250,%ecx
+	rep	stosl
+	popl	%edi
+.Ll3:
+# [12] result.a:=a;
+	movl	-12(%ebp),%eax
+	movb	-4(%ebp),%dl
+	movb	%dl,(%eax)
+.Ll4:
+# [13] result.b:=b;
+	movl	-12(%ebp),%eax
+	movb	-8(%ebp),%dl
+	movb	%dl,1(%eax)
+.Ll5:
+# [14] result.c:=c;
+	movl	-12(%ebp),%eax
+	movb	20(%ebp),%dl
+	movb	%dl,2(%eax)
+.Ll6:
+# [15] result.d:=d;
+	movl	-12(%ebp),%eax
+	movb	16(%ebp),%dl
+	movb	%dl,3(%eax)
+.Ll7:
+# [16] result.e:=e;
+	movl	-12(%ebp),%eax
+	movb	12(%ebp),%dl
+	movb	%dl,4(%eax)
+.Ll8:
+# [17] result.f:=f;
+	movl	-12(%ebp),%eax
+	movb	8(%ebp),%dl
+	movb	%dl,5(%eax)
+.Ll9:
+# [18] end;
+	leave
+	ret	$16
+.Lc2:
+.Lt2:
+.Le0:
+	.size	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR, .Le0 - P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+.Ll10:
+
+.section .text
+	.balign 16,0x90
+.globl	PASCALMAIN
+	.type	PASCALMAIN,@function
+PASCALMAIN:
+.globl	main
+	.type	main,@function
+main:
+.Lc6:
+# Temps allocated between ebp-1008 and ebp+0
+.Ll11:
+# [20] begin
+	pushl	%ebp
+.Lc8:
+.Lc9:
+	movl	%esp,%ebp
+.Lc10:
+	subl	$1008,%esp
+.Ll12:
+# [21] func(255,254,253,252,251,250);
+	pushl	$253
+	pushl	$252
+	pushl	$251
+	pushl	$250
+	leal	-1008(%ebp),%eax
+	movb	$254,%cl
+	movb	$255,%dl
+	call	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+.Ll13:
+# [22] end.
+	xorl	%eax, %eax
+	leave
+	ret
+.Lc7:
+.Lt1:
+.Le1:
+	.size	main, .Le1 - main
+.Ll14:
+
+.section .fpc
+	.balign 8
+	.ascii	"FPC 2.5.1 [2009/09/12] for i386 - Linux"
+
+.section .debug_frame
+.Lc11:
+	.long	.Lc13-.Lc12
+.Lc12:
+	.long	-1
+	.byte	1
+	.byte	0
+	.uleb128	1
+	.sleb128	-4
+	.byte	8
+	.byte	12
+	.uleb128	4
+	.uleb128	4
+	.byte	5
+	.uleb128	8
+	.uleb128	1
+	.balign 4,0
+.Lc13:
+	.long	.Lc15-.Lc14
+.Lc14:
+	.long	.Lc11
+	.long	.Lc1
+	.long	.Lc2-.Lc1
+	.byte	4
+	.long	.Lc3-.Lc1
+	.byte	14
+	.uleb128	8
+	.byte	4
+	.long	.Lc4-.Lc3
+	.byte	5
+	.uleb128	5
+	.uleb128	2
+	.byte	4
+	.long	.Lc5-.Lc4
+	.byte	13
+	.uleb128	5
+	.balign 4,0
+.Lc15:
+	.long	.Lc17-.Lc16
+.Lc16:
+	.long	.Lc11
+	.long	.Lc6
+	.long	.Lc7-.Lc6
+	.byte	4
+	.long	.Lc8-.Lc6
+	.byte	14
+	.uleb128	8
+	.byte	4
+	.long	.Lc9-.Lc8
+	.byte	5
+	.uleb128	5
+	.uleb128	2
+	.byte	4
+	.long	.Lc10-.Lc9
+	.byte	13
+	.uleb128	5
+	.balign 4,0
+.Lc17:
+# End asmlist al_dwarf_frame
+# Begin asmlist al_dwarf_info
+
+.section .debug_info
+	.type	.Ldebug_info0,@object
+.Ldebug_info0:
+	.long	.Ledebug_info0-.Lf1
+.Lf1:
+	.short	2
+	.long	.Ldebug_abbrev0
+	.byte	4
+	.uleb128	1
+	.ascii	"tgdbcc.pp\000"
+	.ascii	"Free Pascal 2.5.1 2009/09/12\000"
+	.ascii	"/home/jmaebe/private/nobackup/fpc/test/\000"
+	.byte	9
+	.byte	3
+	.long	.Ldebug_line0
+	.long	DEBUGSTART_P$PROGRAM
+	.long	DEBUGEND_P$PROGRAM
+# Syms - Begin Staticsymtable
+# Symbol SYSTEM
+# Symbol FPINTRES
+# Symbol OBJPAS
+# Symbol PROGRAM
+# Symbol main
+# Symbol TR
+# Symbol FUNC
+# Symbol SI_PRC
+# Syms - End Staticsymtable
+# Procdef $main; Register;
+	.uleb128	2
+	.ascii	"main\000"
+	.byte	65
+	.byte	1
+	.long	main
+	.long	.Lt1
+	.byte	0
+# Procdef func(<var tr>,Byte,Byte,Byte,Byte,Byte,Byte):<record type>;
+	.uleb128	3
+	.ascii	"FUNC\000"
+	.byte	65
+	.byte	1
+	.long	_$PROGRAM$_Ld1
+	.long	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+	.long	.Lt2
+# Symbol A
+	.uleb128	4
+	.ascii	"A\000"
+	.byte	2
+	.byte	117
+	.sleb128	-4
+	.long	_$PROGRAM$_Ld3
+# Symbol B
+	.uleb128	5
+	.ascii	"B\000"
+	.byte	2
+	.byte	117
+	.sleb128	-8
+	.long	_$PROGRAM$_Ld3
+# Symbol C
+	.uleb128	6
+	.ascii	"C\000"
+	.byte	2
+	.byte	117
+	.sleb128	20
+	.long	_$PROGRAM$_Ld3
+# Symbol D
+	.uleb128	7
+	.ascii	"D\000"
+	.byte	2
+	.byte	117
+	.sleb128	16
+	.long	_$PROGRAM$_Ld3
+# Symbol E
+	.uleb128	8
+	.ascii	"E\000"
+	.byte	2
+	.byte	117
+	.sleb128	12
+	.long	_$PROGRAM$_Ld3
+# Symbol F
+	.uleb128	9
+	.ascii	"F\000"
+	.byte	2
+	.byte	117
+	.sleb128	8
+	.long	_$PROGRAM$_Ld3
+# Symbol result
+	.uleb128	10
+	.ascii	"result\000"
+	.byte	2
+	.byte	117
+	.sleb128	-12
+	.long	_$PROGRAM$_Ld2
+# Symbol FUNC
+	.uleb128	11
+	.ascii	"FUNC\000"
+	.byte	2
+	.byte	117
+	.sleb128	-12
+	.long	_$PROGRAM$_Ld2
+# Symbol RESULT
+	.uleb128	12
+	.ascii	"RESULT\000"
+	.byte	2
+	.byte	117
+	.sleb128	-12
+	.long	_$PROGRAM$_Ld2
+	.byte	0
+# Defs - Begin unit SYSTEM has index 1
+# Definition Byte
+	.type	_$PROGRAM$_Ld3,@object
+_$PROGRAM$_Ld3:
+	.uleb128	13
+	.ascii	"BYTE\000"
+	.long	.La1
+	.type	.La1,@object
+.La1:
+	.uleb128	14
+	.ascii	"BYTE\000"
+	.byte	7
+	.byte	1
+	.type	_$PROGRAM$_Ld4,@object
+_$PROGRAM$_Ld4:
+	.uleb128	15
+	.long	_$PROGRAM$_Ld3
+# Defs - End unit SYSTEM has index 1
+# Defs - Begin unit FPINTRES has index 2
+# Defs - End unit FPINTRES has index 2
+# Defs - Begin unit OBJPAS has index 3
+# Defs - End unit OBJPAS has index 3
+# Defs - Begin unit SI_PRC has index 3
+# Defs - End unit SI_PRC has index 3
+# Defs - Begin Staticsymtable
+# Definition tr
+	.type	_$PROGRAM$_Ld1,@object
+_$PROGRAM$_Ld1:
+	.uleb128	16
+	.ascii	"TR\000"
+	.long	.La2
+	.type	.La2,@object
+.La2:
+	.uleb128	17
+	.ascii	"TR\000"
+	.uleb128	1006
+	.uleb128	18
+	.ascii	"A\000"
+	.byte	2
+	.byte	35
+	.uleb128	0
+	.long	_$PROGRAM$_Ld3
+	.uleb128	19
+	.ascii	"B\000"
+	.byte	2
+	.byte	35
+	.uleb128	1
+	.long	_$PROGRAM$_Ld3
+	.uleb128	20
+	.ascii	"C\000"
+	.byte	2
+	.byte	35
+	.uleb128	2
+	.long	_$PROGRAM$_Ld3
+	.uleb128	21
+	.ascii	"D\000"
+	.byte	2
+	.byte	35
+	.uleb128	3
+	.long	_$PROGRAM$_Ld3
+	.uleb128	22
+	.ascii	"E\000"
+	.byte	2
+	.byte	35
+	.uleb128	4
+	.long	_$PROGRAM$_Ld3
+	.uleb128	23
+	.ascii	"F\000"
+	.byte	2
+	.byte	35
+	.uleb128	5
+	.long	_$PROGRAM$_Ld3
+	.uleb128	24
+	.ascii	"G\000"
+	.byte	2
+	.byte	35
+	.uleb128	6
+	.long	_$PROGRAM$_Ld5
+	.byte	0
+	.type	_$PROGRAM$_Ld2,@object
+_$PROGRAM$_Ld2:
+	.uleb128	25
+	.long	_$PROGRAM$_Ld1
+# Definition Array[0..999] Of Byte
+	.type	_$PROGRAM$_Ld5,@object
+_$PROGRAM$_Ld5:
+	.uleb128	26
+	.uleb128	1000
+	.long	_$PROGRAM$_Ld3
+	.uleb128	27
+	.sleb128	0
+	.sleb128	999
+	.uleb128	1
+	.long	_$PROGRAM$_Ld7
+	.byte	0
+	.type	_$PROGRAM$_Ld6,@object
+_$PROGRAM$_Ld6:
+	.uleb128	28
+	.long	_$PROGRAM$_Ld5
+# Defs - End Staticsymtable
+# Definition SmallInt
+	.type	_$PROGRAM$_Ld7,@object
+_$PROGRAM$_Ld7:
+	.uleb128	29
+	.ascii	"SMALLINT\000"
+	.long	.La3
+	.type	.La3,@object
+.La3:
+	.uleb128	30
+	.ascii	"SMALLINT\000"
+	.byte	5
+	.byte	2
+	.type	_$PROGRAM$_Ld8,@object
+_$PROGRAM$_Ld8:
+	.uleb128	31
+	.long	_$PROGRAM$_Ld7
+	.byte	0
+	.type	.Ledebug_info0,@object
+.Ledebug_info0:
+# End asmlist al_dwarf_info
+# Begin asmlist al_dwarf_abbrev
+
+.section .debug_abbrev
+# Abbrev 1
+	.uleb128	1
+	.uleb128	17
+	.byte	1
+	.uleb128	3
+	.uleb128	8
+	.uleb128	37
+	.uleb128	8
+	.uleb128	27
+	.uleb128	8
+	.uleb128	19
+	.uleb128	11
+	.uleb128	66
+	.uleb128	11
+	.uleb128	16
+	.uleb128	6
+	.uleb128	17
+	.uleb128	1
+	.uleb128	18
+	.uleb128	1
+	.byte	0
+	.byte	0
+# Abbrev 2
+	.uleb128	2
+	.uleb128	46
+	.byte	1
+	.uleb128	3
+	.uleb128	8
+	.uleb128	54
+	.uleb128	11
+	.uleb128	63
+	.uleb128	12
+	.uleb128	17
+	.uleb128	1
+	.uleb128	18
+	.uleb128	1
+	.byte	0
+	.byte	0
+# Abbrev 3
+	.uleb128	3
+	.uleb128	46
+	.byte	1
+	.uleb128	3
+	.uleb128	8
+	.uleb128	54
+	.uleb128	11
+	.uleb128	63
+	.uleb128	12
+	.uleb128	73
+	.uleb128	16
+	.uleb128	17
+	.uleb128	1
+	.uleb128	18
+	.uleb128	1
+	.byte	0
+	.byte	0
+# Abbrev 4
+	.uleb128	4
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 5
+	.uleb128	5
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 6
+	.uleb128	6
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 7
+	.uleb128	7
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 8
+	.uleb128	8
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 9
+	.uleb128	9
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 10
+	.uleb128	10
+	.uleb128	52
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 11
+	.uleb128	11
+	.uleb128	52
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 12
+	.uleb128	12
+	.uleb128	52
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 13
+	.uleb128	13
+	.uleb128	22
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 14
+	.uleb128	14
+	.uleb128	36
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	62
+	.uleb128	11
+	.uleb128	11
+	.uleb128	11
+	.byte	0
+	.byte	0
+# Abbrev 15
+	.uleb128	15
+	.uleb128	16
+	.byte	0
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 16
+	.uleb128	16
+	.uleb128	22
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 17
+	.uleb128	17
+	.uleb128	19
+	.byte	1
+	.uleb128	3
+	.uleb128	8
+	.uleb128	11
+	.uleb128	15
+	.byte	0
+	.byte	0
+# Abbrev 18
+	.uleb128	18
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 19
+	.uleb128	19
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 20
+	.uleb128	20
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 21
+	.uleb128	21
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 22
+	.uleb128	22
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 23
+	.uleb128	23
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 24
+	.uleb128	24
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 25
+	.uleb128	25
+	.uleb128	16
+	.byte	0
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 26
+	.uleb128	26
+	.uleb128	1
+	.byte	1
+	.uleb128	11
+	.uleb128	15
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 27
+	.uleb128	27
+	.uleb128	33
+	.byte	0
+	.uleb128	34
+	.uleb128	13
+	.uleb128	47
+	.uleb128	13
+	.uleb128	81
+	.uleb128	15
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 28
+	.uleb128	28
+	.uleb128	16
+	.byte	0
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 29
+	.uleb128	29
+	.uleb128	22
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 30
+	.uleb128	30
+	.uleb128	36
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	62
+	.uleb128	11
+	.uleb128	11
+	.uleb128	11
+	.byte	0
+	.byte	0
+# Abbrev 31
+	.uleb128	31
+	.uleb128	16
+	.byte	0
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+	.byte	0
+# End asmlist al_dwarf_abbrev
+# Begin asmlist al_dwarf_line
+
+.section .debug_line
+# === header start ===
+	.long	.Ledebug_line0-.Lf2
+.Lf2:
+	.short	2
+	.long	.Lehdebug_line0-.Lf3
+.Lf3:
+	.byte	1
+	.byte	1
+	.byte	1
+	.byte	255
+	.byte	13
+	.byte	0
+	.byte	1
+	.byte	1
+	.byte	1
+	.byte	1
+	.byte	0
+	.byte	0
+	.byte	0
+	.byte	1
+	.byte	0
+	.byte	0
+	.byte	1
+# include_directories
+	.byte	0
+# file_names
+	.ascii	"tgdbcc.pp\000"
+	.uleb128	0
+	.uleb128	0
+	.uleb128	0
+	.byte	0
+	.type	.Lehdebug_line0,@object
+.Lehdebug_line0:
+# === header end ===
+# function: P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+# [10:1]
+	.byte	0
+	.uleb128	5
+	.byte	2
+	.long	.Ll1
+	.byte	5
+	.uleb128	1
+	.byte	21
+# [11:18]
+	.byte	2
+	.uleb128	.Ll2-.Ll1
+	.byte	5
+	.uleb128	18
+	.byte	13
+# [12:9]
+	.byte	2
+	.uleb128	.Ll3-.Ll2
+	.byte	5
+	.uleb128	9
+	.byte	13
+# [13:9]
+	.byte	2
+	.uleb128	.Ll4-.Ll3
+	.byte	13
+# [14:9]
+	.byte	2
+	.uleb128	.Ll5-.Ll4
+	.byte	13
+# [15:9]
+	.byte	2
+	.uleb128	.Ll6-.Ll5
+	.byte	13
+# [16:9]
+	.byte	2
+	.uleb128	.Ll7-.Ll6
+	.byte	13
+# [17:9]
+	.byte	2
+	.uleb128	.Ll8-.Ll7
+	.byte	13
+# [18:1]
+	.byte	2
+	.uleb128	.Ll9-.Ll8
+	.byte	5
+	.uleb128	1
+	.byte	13
+	.byte	0
+	.uleb128	5
+	.byte	2
+	.long	.Ll10
+	.byte	0
+	.byte	1
+	.byte	1
+# ###################
+# function: PASCALMAIN
+# function: main
+# [20:1]
+	.byte	0
+	.uleb128	5
+	.byte	2
+	.long	.Ll11
+	.byte	5
+	.uleb128	1
+	.byte	31
+# [21:3]
+	.byte	2
+	.uleb128	.Ll12-.Ll11
+	.byte	5
+	.uleb128	3
+	.byte	13
+# [22:1]
+	.byte	2
+	.uleb128	.Ll13-.Ll12
+	.byte	5
+	.uleb128	1
+	.byte	13
+	.byte	0
+	.uleb128	5
+	.byte	2
+	.long	.Ll14
+	.byte	0
+	.byte	1
+	.byte	1
+# ###################
+	.type	.Ledebug_line0,@object
+.Ledebug_line0:
+# End asmlist al_dwarf_line
+# Begin asmlist al_picdata
+# End asmlist al_picdata
+# Begin asmlist al_resourcestrings
+# End asmlist al_resourcestrings
+# Begin asmlist al_objc_data
+# End asmlist al_objc_data
+# Begin asmlist al_end
+
+.section .text
+.globl	DEBUGEND_P$PROGRAM
+	.type	DEBUGEND_P$PROGRAM,@object
+DEBUGEND_P$PROGRAM:
+# End asmlist al_end
+.section .note.GNU-stack,"",%progbits
+
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.exp b/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.exp
new file mode 100644
index 0000000..6a18f53
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.exp
@@ -0,0 +1,52 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test Borland fastcall calling convention
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+    && ![istarget *-*-gnu*]
+    && ![istarget *-*-elf*]
+    && ![istarget *-*-openbsd*]} {
+    return 0;
+  }
+
+# This test can only be run on x86 targets.
+if {![istarget i?86-*]} {
+    return 0  
+}
+
+set testfile "dw2-borland_fastcall"
+set srcfile ${testfile}.S
+set binfile ${objdir}/${subdir}/${testfile}.x
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {nodebug}] != "" } {
+    return -1
+}
+
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if { ![runto_main] } {
+    gdb_suppress_tests;
+}
+
+
+gdb_test "p FUNC(1,2,3,4,5,6)" \
+    "= {A = 1, B = 2, C = 3, D = 4, E = 5, F = 6, G = #0 <repeats 999 times>}"

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



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

* Re: [patch] Set calling convention of methods
  2009-09-30 14:54                     ` Jonas Maebe
@ 2009-09-30 15:22                       ` Mark Kettenis
  2009-09-30 16:25                       ` Joel Brobecker
  1 sibling, 0 replies; 28+ messages in thread
From: Mark Kettenis @ 2009-09-30 15:22 UTC (permalink / raw)
  To: jonas.maebe; +Cc: brobecker, tromey, mark.kettenis, gdb-patches

Please don't send me mangled MIME attachements (quoted-printable in
this case) if you want to have your diffs reviewed.

Thanks,

Mark


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

* Re: [patch] Set calling convention of methods
  2009-09-30 11:18                   ` Jonas Maebe
  2009-09-30 14:54                     ` Jonas Maebe
@ 2009-09-30 16:10                     ` Joel Brobecker
  2009-09-30 17:36                       ` Joel Brobecker
  2009-09-30 16:47                     ` Tom Tromey
  2 siblings, 1 reply; 28+ messages in thread
From: Joel Brobecker @ 2009-09-30 16:10 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: tromey, Mark Kettenis, gdb-patches

>> As far as I am concerned, I can't see a problem with using DWARF
>> declarations even from stabs.
>
> We could include the dwarf2.h header in the stabs reader and set the  
> calling convention to DW_CC_normal in all cases.

That, or explicitly document that calling smash_to_method_type
with a calling_convention=0 means a normal calling convention.
We'd then just add an extra check at the beginning of this function
that translates calling_convention from zero to DW_CC_normal.
My money is on including dwarf2.h from stabsread.c.  We do this
from other places, so why not from stabsread.c?

>> This part is maintained by binutils, I believe.  You'll need
>> to ask them for approval of this change.
>
> Tom said it came from gcc 
> (http://sourceware.org/ml/gdb-patches/2009-04/msg00063.html) and I did 
> submit a patch there: 
> http://gcc.gnu.org/ml/gcc-patches/2009-04/msg00301.html . I did not get 
> any reaction to that patch (and I guess it's not been applied).

That's really strange, because if you look at include/MAINTAINERS:
    % cat include/MAINTAINERS
    See ../binutils/MAINTAINERS

So, my guess is that this file is maintained by binutils, and that
GCC should stay up to date. If they have local changes there, they
should merge them into binutils so that both copies stay in sync.

> Later on, Tom clarified that he thought that the gdb and gcc versions of 
> dwarf2.h should actually be merged into a single copy, but that I  
> shouldn't worry about this since the divergence started before my patch: 
> http://sourceware.org/ml/gdb-patches/2009-04/msg00099.html

Right, this shouldn't be your problem. But they should welcome your help
if you send patches to make things right again. Double-check with
the binutils people that they indeed "own" that file first.

-- 
Joel


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

* Re: [patch] Set calling convention of methods
  2009-09-30 14:54                     ` Jonas Maebe
  2009-09-30 15:22                       ` Mark Kettenis
@ 2009-09-30 16:25                       ` Joel Brobecker
  2009-10-01  9:18                         ` Jonas Maebe
  1 sibling, 1 reply; 28+ messages in thread
From: Joel Brobecker @ 2009-09-30 16:25 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: Tom Tromey, Mark Kettenis, gdb-patches ml

> Additionally, I've added a test, because even in my previous new version 
> I messed up struct returns. This test should prevent that from happening 
> again.

Thanks for doing that, we really like testcases, so I appreciate
the effort.

> 2009-09-30  Jonas Maebe  <jonas.maebe <at> elis.ugent.be>
>
> 	Add support for the "Borland fastcall" calling convention.
>
> 	* dwarf2.h: Add DW_CC_GNU_borland_fastcall_i386 constant.
> 	* i386-tdep.c: #include dwarf2.h
> 	(i386_borland_fastcall_push_dummy_call): New.
> 	(i386_push_dummy_generic_call): Renamed i386_push_dummy_call.
> 	(i386_push_dummy_call): New dispatch function that calls
> 	i386_generic_push_dummy_call or i386_push_dummy_borland_fast_call
> 	depending on the calling convention.

Overall, this looks OK to me, but Mark seemed interested in reviewing
this patch, so please wait for his comments as well. Again, I think
that dwarf2.h needs to be approved by binutils - it's probably going
to be routine, but you never know.

> 	* gdb.dwarf2/dw2-borland_fastcall.exp: New.
> 	* gdb.dwarf2/dw2-borland_fastcall.S: New.

The .S file needs a copyright header. Would you be able to re-generate
the file with -dA, by any chance. It makes the DWARF data more readable.
Otherwise, no problem, it's already fine as it is.

> +if { ![runto_main] } {
> +    gdb_suppress_tests;
> +}

We do not use gdb_suppress_tests anymore. runto_main already logs
a FAIL if it does not work, so you can simply return -1 for instance.
I don't think the return value makes any difference in our context.

-- 
Joel


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

* Re: [patch] Set calling convention of methods
  2009-09-30 11:18                   ` Jonas Maebe
  2009-09-30 14:54                     ` Jonas Maebe
  2009-09-30 16:10                     ` Joel Brobecker
@ 2009-09-30 16:47                     ` Tom Tromey
  2009-09-30 17:32                       ` Joel Brobecker
  2 siblings, 1 reply; 28+ messages in thread
From: Tom Tromey @ 2009-09-30 16:47 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: Joel Brobecker, Mark Kettenis, gdb-patches

>>>>> "Jonas" == Jonas Maebe <jonas.maebe@elis.ugent.be> writes:

>> diff --git a/include/elf/dwarf2.h b/include/elf/dwarf2.h
>>> index a7448dc..efa786e 100644
>>> --- a/include/elf/dwarf2.h
>>> +++ b/include/elf/dwarf2.h
>>> @@ -662,7 +662,8 @@ enum dwarf_calling_convention
>>> DW_CC_normal = 0x1,
>>> DW_CC_program = 0x2,
>>> DW_CC_nocall = 0x3,
>>> -    DW_CC_GNU_renesas_sh = 0x40
>>> +    DW_CC_GNU_renesas_sh = 0x40,
>>> +    DW_CC_GNU_borland_fastcall_i386 = 0x41

I am on a mission to ensure that all GNU extensions to DWARF are nicely
documented.  So, at the very least, this needs a comment explaining the
meaning of this flag; maybe mentioning the `fastcall' attribute in GCC
(if indeed this is the same thing).

Jonas> Later on, Tom clarified that he thought that the gdb and gcc versions
Jonas> of dwarf2.h should actually be merged into a single copy, but that I
Jonas> shouldn't worry about this since the divergence started before my
Jonas> patch: http://sourceware.org/ml/gdb-patches/2009-04/msg00099.html

I've merged these now.

I think the usual approach for such merged files is that GCC is the
master copy.

Tom


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

* Re: [patch] Set calling convention of methods
  2009-09-30 16:47                     ` Tom Tromey
@ 2009-09-30 17:32                       ` Joel Brobecker
  2009-09-30 17:35                         ` Tom Tromey
  2009-11-03  9:43                         ` Jonas Maebe
  0 siblings, 2 replies; 28+ messages in thread
From: Joel Brobecker @ 2009-09-30 17:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Jonas Maebe, Mark Kettenis, gdb-patches

> Jonas> Later on, Tom clarified that he thought that the gdb and gcc versions
> Jonas> of dwarf2.h should actually be merged into a single copy, but that I
> Jonas> shouldn't worry about this since the divergence started before my
> Jonas> patch: http://sourceware.org/ml/gdb-patches/2009-04/msg00099.html
> 
> I've merged these now.
> 
> I think the usual approach for such merged files is that GCC is the
> master copy.

Confirmed. It's written plain as day in the header.  The sticky part
is that Jonas does NOT have copyright assignment on file for GCC, as
far as I can tell...

-- 
Joel


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

* Re: [patch] Set calling convention of methods
  2009-09-30 17:32                       ` Joel Brobecker
@ 2009-09-30 17:35                         ` Tom Tromey
  2009-10-01  9:21                           ` Jonas Maebe
  2009-11-03  9:43                         ` Jonas Maebe
  1 sibling, 1 reply; 28+ messages in thread
From: Tom Tromey @ 2009-09-30 17:35 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Jonas Maebe, Mark Kettenis, gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> Confirmed. It's written plain as day in the header.  The sticky part
Joel> is that Jonas does NOT have copyright assignment on file for GCC, as
Joel> far as I can tell...

I think this patch is small enough not to matter.

Tom


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

* Re: [patch] Set calling convention of methods
  2009-09-30 16:10                     ` Joel Brobecker
@ 2009-09-30 17:36                       ` Joel Brobecker
  0 siblings, 0 replies; 28+ messages in thread
From: Joel Brobecker @ 2009-09-30 17:36 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: tromey, Mark Kettenis, gdb-patches

Jonas,

> >> As far as I am concerned, I can't see a problem with using DWARF
> >> declarations even from stabs.
> >
> > We could include the dwarf2.h header in the stabs reader and set the  
> > calling convention to DW_CC_normal in all cases.
> 
> That, or explicitly document that calling smash_to_method_type
> with a calling_convention=0 means a normal calling convention.
> We'd then just add an extra check at the beginning of this function
> that translates calling_convention from zero to DW_CC_normal.
> My money is on including dwarf2.h from stabsread.c.  We do this
> from other places, so why not from stabsread.c?

When you're ready, can you resubmit an updated version of your patch
that adds calling-convention support for methods? Tom and I discussed
the issue on IRC, and we think it's fine to include dwarf2.h from
stabsread.c.

-- 
Joel


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

* Re: [patch] Set calling convention of methods
  2009-09-30 16:25                       ` Joel Brobecker
@ 2009-10-01  9:18                         ` Jonas Maebe
  2009-10-01 22:04                           ` Joel Brobecker
  2009-10-02  9:21                           ` Mark Kettenis
  0 siblings, 2 replies; 28+ messages in thread
From: Jonas Maebe @ 2009-10-01  9:18 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, Mark Kettenis, gdb-patches ml


Sorry for the delayed reply. I recently moved and don't have Internet  
access yet at home.


On 30 Sep 2009, at 18:25, Joel Brobecker wrote:

> Thanks for doing that, we really like testcases, so I appreciate
> the effort.


Since I always insist on tests for new functionality added to our  
compiler, it's only reasonable to hold my own patches to other  
projects to the same standard :)

> Overall, this looks OK to me, but Mark seemed interested in reviewing
> this patch, so please wait for his comments as well.

Ok. Note that my mail client is known to wrap text at 80 columns (and  
adds a space at the end of each wrapped line for detecting this  
operation). This behaviour cannot be disabled afaik, and yes, one  
could certainly consider this to be a bug. At the same time, it  
however also adds '"Format="flowed"; DelSp="yes"' to the Content-Type  
header, so mail clients on the other side can reconstruct the original  
text (if those clients support these modifiers, which I hope is the  
case).

In case this fails, too, I've also placed the new patch for download  
at http://users.elis.ugent.be/~jmaebe/gdb/gdb_borland_fastcall7.patch.txt

> Again, I think
> that dwarf2.h needs to be approved by binutils - it's probably going
> to be routine, but you never know.

Given that it was later confirmed that the file does belong to gcc,  
should I resend my patch for dwarf2.h to the gcc patches list? I've  
also added a description of the Borland fastcall calling convention to  
dwarf2.h in the attached patch, as requested by Tom. Note that this  
calling convention is different from GCC's fastcall.

>> 	* gdb.dwarf2/dw2-borland_fastcall.S: New.
>
> The .S file needs a copyright header.

Added.

> Would you be able to re-generate
> the file with -dA, by any chance. It makes the DWARF data more  
> readable.
> Otherwise, no problem, it's already fine as it is.

The assembler file was generated by the Free Pascal Compiler, which is  
not gcc-based. It does not have an option to produce DWARF any  
prettier than this...

> We do not use gdb_suppress_tests anymore. runto_main already logs
> a FAIL if it does not work, so you can simply return -1 for instance.
> I don't think the return value makes any difference in our context.

Done.

Thanks for the feedback,


Jonas

2009-10-01  Jonas Maebe  <jonas.maebe <at> elis.ugent.be>

	Add support for the "Borland fastcall" calling convention.

	* dwarf2.h: Add DW_CC_GNU_borland_fastcall_i386 constant.
	* i386-tdep.c: #include dwarf2.h
	(i386_borland_fastcall_push_dummy_call): New.
	(i386_push_dummy_generic_call): Renamed i386_push_dummy_call.
	(i386_push_dummy_call): New dispatch function that calls
	i386_generic_push_dummy_call or i386_push_dummy_borland_fast_call
	depending on the calling convention.
	* gdb.dwarf2/dw2-borland_fastcall.exp: New.
	* gdb.dwarf2/dw2-borland_fastcall.S: New.

diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index b79bcd2..dbfcf31 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -53,6 +53,8 @@
  #include "record.h"
  #include <stdint.h>

+#include "dwarf2.h"
+
  /* Register names.  */

  static char *i386_register_names[] =
@@ -1426,7 +1428,7 @@ i386_frame_this_id (struct frame_info  
*this_frame, void **this_cache,
    if (cache->base == 0)
      return;

-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
    (*this_id) = frame_id_build (cache->base + 8, cache->pc);
  }

@@ -1620,7 +1622,7 @@ i386_sigtramp_frame_this_id (struct frame_info  
*this_frame, void **this_cache,
    struct i386_frame_cache *cache =
      i386_sigtramp_frame_cache (this_frame, this_cache);

-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
    (*this_id) = frame_id_build (cache->base + 8, get_frame_pc  
(this_frame));
  }

@@ -1697,7 +1699,7 @@ i386_dummy_id (struct gdbarch *gdbarch, struct  
frame_info *this_frame)

    fp = get_frame_register_unsigned (this_frame, I386_EBP_REGNUM);

-  /* See the end of i386_push_dummy_call.  */
+  /* See the end of i386_generic_push_dummy_call.  */
    return frame_id_build (fp + 8, get_frame_pc (this_frame));
  }
  \f
@@ -1765,10 +1767,10 @@ i386_16_byte_align_p (struct type *type)
  }

  static CORE_ADDR
-i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
-		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
-		      struct value **args, CORE_ADDR sp, int struct_return,
-		      CORE_ADDR struct_addr)
+i386_generic_push_dummy_call (struct gdbarch *gdbarch, struct value  
*function,
+			      struct regcache *regcache, CORE_ADDR bp_addr,
+			      int nargs, struct value **args, CORE_ADDR sp,
+			      int struct_return, CORE_ADDR struct_addr)
  {
    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
    gdb_byte buf[4];
@@ -1861,6 +1863,144 @@ i386_push_dummy_call (struct gdbarch *gdbarch,  
struct value *function,
    return sp + 8;
  }

+/* Borland fastcall: register parameters are passed from left to  
right, then
+   stack parameters also from left to right.  The first three  
unstructured
+   parameters <= 32 bits are passed in %eax, %edx and %ecx.  The  
others are
+   passed on the stack.  Furthermore, in case of a struct return by  
reference,
+   the address of this struct is passed as the first (register)   
parameter.  */
+static CORE_ADDR
+i386_borland_fastcall_push_dummy_call (struct gdbarch *gdbarch,
+				       struct value *function,
+				       struct regcache *regcache,
+				       CORE_ADDR bp_addr, int nargs,
+				       struct value **args, CORE_ADDR sp,
+				       int struct_return, CORE_ADDR struct_addr)
+{
+  static const int para_regs[3] = { I386_EAX_REGNUM, I386_EDX_REGNUM,
+      I386_ECX_REGNUM };
+
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  gdb_byte buf[4];
+  int reg_paras[3] = { -1, -1, -1 };
+  int i, j;
+  int write_pass;
+  int para_regnum = 0;
+
+  /* First assign the register parameters (left to right).  */
+  if (struct_return)
+    {
+      store_unsigned_integer (buf, 4, byte_order, struct_addr);
+      regcache_cooked_write (regcache, para_regs[para_regnum],
+				 buf);
+      /* Use the otherwise invalid "nargs" argument index to denote the
+         function result.  */
+      reg_paras[para_regnum] = nargs;
+      para_regnum++;
+    }
+
+  for (i = 0; i < nargs && para_regnum < 3; i++)
+    {
+      struct type *type = check_typedef (value_enclosing_type  
(args[i]));
+      int len = TYPE_LENGTH (type);
+
+      if (len <= 4
+	  && TYPE_CODE (type) != TYPE_CODE_ARRAY
+	  && TYPE_CODE (type) != TYPE_CODE_STRUCT
+	  && TYPE_CODE (type) != TYPE_CODE_FLT)
+	{
+	  regcache_cooked_write (regcache, para_regs[para_regnum],
+				 value_contents_all (args[i]));
+	  reg_paras[para_regnum] = i;
+	  para_regnum++;
+	}
+    }
+
+  /* Now process the stack parameters from left to right.  */
+  for (write_pass = 0; write_pass < 2; write_pass++)
+    {
+      int args_space = 0;
+      int have_16_byte_aligned_arg = 0;
+
+      for (i = nargs - 1; i >= 0; i--)
+	{
+	  struct type *type = check_typedef (value_enclosing_type (args[i]));
+	  int len = TYPE_LENGTH (type);
+	  int processed = 0;
+
+	  /* Skip parameters already assigned to registers.  */
+	  for (j = 0; j < para_regnum; j++)
+	    if (reg_paras[j] == i)
+	      {
+		processed = 1;
+		break;
+	      }
+	  if (processed)
+	    continue;
+
+	  if (i386_16_byte_align_p (value_enclosing_type (args[i])))
+	    {
+	      args_space = align_up (args_space, 16);
+	      have_16_byte_aligned_arg = 1;
+	    }
+	  if (write_pass)
+	    {
+	      write_memory (sp + args_space,
+			    value_contents_all (args[i]), len);
+	    }
+	  args_space += align_up (len, 4);
+	}
+
+      if (!write_pass)
+	{
+	  /* Early exit if nothing to do.  */
+	  if (!args_space)
+	    break;
+	  if (have_16_byte_aligned_arg)
+	    args_space = align_up (args_space, 16);
+	  sp -= args_space;
+	}
+    }
+
+  /* Store return address.  */
+  sp -= 4;
+  store_unsigned_integer (buf, 4, byte_order, bp_addr);
+  write_memory (sp, buf, 4);
+
+  /* Finally, update the stack pointer...  */
+  store_unsigned_integer (buf, 4, byte_order, sp);
+  regcache_cooked_write (regcache, I386_ESP_REGNUM, buf);
+
+  /* ...and fake a frame pointer.  */
+  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
+
+  /* See the end of i386_generic_push_dummy_call.  */
+  return sp + 8;
+}
+
+static CORE_ADDR
+i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
+		      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
+		      struct value **args, CORE_ADDR sp, int struct_return,
+		      CORE_ADDR struct_addr)
+{
+  struct type *type = check_typedef (value_type (function));
+
+  /* Look up the target type in case of a function/method pointer.  */
+  while (type && can_dereference (type))
+    type = TYPE_TARGET_TYPE (type);
+
+  /* Check calling convention.  */
+  if (type
+      && TYPE_CALLING_CONVENTION (type) ==  
DW_CC_GNU_borland_fastcall_i386)
+    return i386_borland_fastcall_push_dummy_call (gdbarch, function,  
regcache,
+					      bp_addr, nargs, args, sp,
+					      struct_return, struct_addr);
+  else
+    return i386_generic_push_dummy_call (gdbarch, function, regcache,  
bp_addr,
+					 nargs, args, sp, struct_return,
+					 struct_addr);
+}
+
  /* These registers are used for returning integers (and on some
     targets also for returning `struct' and `union' values when their
     size and alignment match an integer type).  */
diff --git a/include/dwarf2.h b/include/dwarf2.h
index 385ab22..7209a99 100644
--- a/include/dwarf2.h
+++ b/include/dwarf2.h
@@ -721,7 +721,14 @@ enum dwarf_calling_convention
      DW_CC_lo_user = 0x40,
      DW_CC_hi_user = 0xff,

-    DW_CC_GNU_renesas_sh = 0x40
+    DW_CC_GNU_renesas_sh = 0x40,
+    /* Borland fastcall: register parameters are passed from left to  
right,
+       then stack parameters also from left to right.  The first three
+       unstructured parameters <= 32 bits are passed in %eax, %edx  
and %ecx.
+       The others are passed on the stack.  Furthermore, in case of a  
struct
+       return by reference, the address of this struct is passed as  
the first
+       (register) parameter.  */
+    DW_CC_GNU_borland_fastcall_i386 = 0x41
    };

  /* Inline attribute.  */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.S b/gdb/ 
testsuite/gdb.dwarf2/dw2-borland_fastcall.S
new file mode 100644
index 0000000..ba88d14
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.S
@@ -0,0 +1,962 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/ 
 >.  */
+
+/* Test Borland fastcall calling convention.  */
+
+	.file "tgdbcc.pp"
+# Begin asmlist al_begin
+
+.section .debug_line
+	.type	.Ldebug_linesection0,@object
+.Ldebug_linesection0:
+	.type	.Ldebug_line0,@object
+.Ldebug_line0:
+
+.section .debug_abbrev
+	.type	.Ldebug_abbrevsection0,@object
+.Ldebug_abbrevsection0:
+	.type	.Ldebug_abbrev0,@object
+.Ldebug_abbrev0:
+
+.section .text
+.globl	DEBUGSTART_P$PROGRAM
+	.type	DEBUGSTART_P$PROGRAM,@object
+DEBUGSTART_P$PROGRAM:
+# End asmlist al_begin
+# Begin asmlist al_stabs
+# End asmlist al_stabs
+# Begin asmlist al_procedures
+
+.section .text
+	.balign 16,0x90
+.globl	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+	.type	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR,@function
+P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR:
+.Lc1:
+# Temps allocated between ebp-12 and ebp-12
+.Ll1:
+# [tgdbcc.pp]
+# [10] begin
+	pushl	%ebp
+.Lc3:
+.Lc4:
+	movl	%esp,%ebp
+.Lc5:
+	subl	$12,%esp
+# Var a located at ebp-4
+# Var b located at ebp-8
+# Var c located at ebp+20
+# Var d located at ebp+16
+# Var e located at ebp+12
+# Var f located at ebp+8
+# Var $result located at ebp-12
+	movl	%eax,-12(%ebp)
+	movb	%dl,-4(%ebp)
+	movb	%cl,-8(%ebp)
+.Ll2:
+# [11] fillchar(result.g,sizeof(result.g),0);
+	pushl	%edi
+	movl	-12(%ebp),%edi
+	leal	6(%edi),%edi
+	xorl	%eax,%eax
+	movl	$250,%ecx
+	rep	stosl
+	popl	%edi
+.Ll3:
+# [12] result.a:=a;
+	movl	-12(%ebp),%eax
+	movb	-4(%ebp),%dl
+	movb	%dl,(%eax)
+.Ll4:
+# [13] result.b:=b;
+	movl	-12(%ebp),%eax
+	movb	-8(%ebp),%dl
+	movb	%dl,1(%eax)
+.Ll5:
+# [14] result.c:=c;
+	movl	-12(%ebp),%eax
+	movb	20(%ebp),%dl
+	movb	%dl,2(%eax)
+.Ll6:
+# [15] result.d:=d;
+	movl	-12(%ebp),%eax
+	movb	16(%ebp),%dl
+	movb	%dl,3(%eax)
+.Ll7:
+# [16] result.e:=e;
+	movl	-12(%ebp),%eax
+	movb	12(%ebp),%dl
+	movb	%dl,4(%eax)
+.Ll8:
+# [17] result.f:=f;
+	movl	-12(%ebp),%eax
+	movb	8(%ebp),%dl
+	movb	%dl,5(%eax)
+.Ll9:
+# [18] end;
+	leave
+	ret	$16
+.Lc2:
+.Lt2:
+.Le0:
+	.size	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR, .Le0 - P 
$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+.Ll10:
+
+.section .text
+	.balign 16,0x90
+.globl	PASCALMAIN
+	.type	PASCALMAIN,@function
+PASCALMAIN:
+.globl	main
+	.type	main,@function
+main:
+.Lc6:
+# Temps allocated between ebp-1008 and ebp+0
+.Ll11:
+# [20] begin
+	pushl	%ebp
+.Lc8:
+.Lc9:
+	movl	%esp,%ebp
+.Lc10:
+	subl	$1008,%esp
+.Ll12:
+# [21] func(255,254,253,252,251,250);
+	pushl	$253
+	pushl	$252
+	pushl	$251
+	pushl	$250
+	leal	-1008(%ebp),%eax
+	movb	$254,%cl
+	movb	$255,%dl
+	call	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+.Ll13:
+# [22] end.
+	xorl	%eax, %eax
+	leave
+	ret
+.Lc7:
+.Lt1:
+.Le1:
+	.size	main, .Le1 - main
+.Ll14:
+
+.section .fpc
+	.balign 8
+	.ascii	"FPC 2.5.1 [2009/09/12] for i386 - Linux"
+
+.section .debug_frame
+.Lc11:
+	.long	.Lc13-.Lc12
+.Lc12:
+	.long	-1
+	.byte	1
+	.byte	0
+	.uleb128	1
+	.sleb128	-4
+	.byte	8
+	.byte	12
+	.uleb128	4
+	.uleb128	4
+	.byte	5
+	.uleb128	8
+	.uleb128	1
+	.balign 4,0
+.Lc13:
+	.long	.Lc15-.Lc14
+.Lc14:
+	.long	.Lc11
+	.long	.Lc1
+	.long	.Lc2-.Lc1
+	.byte	4
+	.long	.Lc3-.Lc1
+	.byte	14
+	.uleb128	8
+	.byte	4
+	.long	.Lc4-.Lc3
+	.byte	5
+	.uleb128	5
+	.uleb128	2
+	.byte	4
+	.long	.Lc5-.Lc4
+	.byte	13
+	.uleb128	5
+	.balign 4,0
+.Lc15:
+	.long	.Lc17-.Lc16
+.Lc16:
+	.long	.Lc11
+	.long	.Lc6
+	.long	.Lc7-.Lc6
+	.byte	4
+	.long	.Lc8-.Lc6
+	.byte	14
+	.uleb128	8
+	.byte	4
+	.long	.Lc9-.Lc8
+	.byte	5
+	.uleb128	5
+	.uleb128	2
+	.byte	4
+	.long	.Lc10-.Lc9
+	.byte	13
+	.uleb128	5
+	.balign 4,0
+.Lc17:
+# End asmlist al_dwarf_frame
+# Begin asmlist al_dwarf_info
+
+.section .debug_info
+	.type	.Ldebug_info0,@object
+.Ldebug_info0:
+	.long	.Ledebug_info0-.Lf1
+.Lf1:
+	.short	2
+	.long	.Ldebug_abbrev0
+	.byte	4
+	.uleb128	1
+	.ascii	"tgdbcc.pp\000"
+	.ascii	"Free Pascal 2.5.1 2009/09/12\000"
+	.ascii	"/home/jmaebe/private/nobackup/fpc/test/\000"
+	.byte	9
+	.byte	3
+	.long	.Ldebug_line0
+	.long	DEBUGSTART_P$PROGRAM
+	.long	DEBUGEND_P$PROGRAM
+# Syms - Begin Staticsymtable
+# Symbol SYSTEM
+# Symbol FPINTRES
+# Symbol OBJPAS
+# Symbol PROGRAM
+# Symbol main
+# Symbol TR
+# Symbol FUNC
+# Symbol SI_PRC
+# Syms - End Staticsymtable
+# Procdef $main; Register;
+	.uleb128	2
+	.ascii	"main\000"
+	.byte	65
+	.byte	1
+	.long	main
+	.long	.Lt1
+	.byte	0
+# Procdef func(<var tr>,Byte,Byte,Byte,Byte,Byte,Byte):<record type>;
+	.uleb128	3
+	.ascii	"FUNC\000"
+	.byte	65
+	.byte	1
+	.long	_$PROGRAM$_Ld1
+	.long	P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+	.long	.Lt2
+# Symbol A
+	.uleb128	4
+	.ascii	"A\000"
+	.byte	2
+	.byte	117
+	.sleb128	-4
+	.long	_$PROGRAM$_Ld3
+# Symbol B
+	.uleb128	5
+	.ascii	"B\000"
+	.byte	2
+	.byte	117
+	.sleb128	-8
+	.long	_$PROGRAM$_Ld3
+# Symbol C
+	.uleb128	6
+	.ascii	"C\000"
+	.byte	2
+	.byte	117
+	.sleb128	20
+	.long	_$PROGRAM$_Ld3
+# Symbol D
+	.uleb128	7
+	.ascii	"D\000"
+	.byte	2
+	.byte	117
+	.sleb128	16
+	.long	_$PROGRAM$_Ld3
+# Symbol E
+	.uleb128	8
+	.ascii	"E\000"
+	.byte	2
+	.byte	117
+	.sleb128	12
+	.long	_$PROGRAM$_Ld3
+# Symbol F
+	.uleb128	9
+	.ascii	"F\000"
+	.byte	2
+	.byte	117
+	.sleb128	8
+	.long	_$PROGRAM$_Ld3
+# Symbol result
+	.uleb128	10
+	.ascii	"result\000"
+	.byte	2
+	.byte	117
+	.sleb128	-12
+	.long	_$PROGRAM$_Ld2
+# Symbol FUNC
+	.uleb128	11
+	.ascii	"FUNC\000"
+	.byte	2
+	.byte	117
+	.sleb128	-12
+	.long	_$PROGRAM$_Ld2
+# Symbol RESULT
+	.uleb128	12
+	.ascii	"RESULT\000"
+	.byte	2
+	.byte	117
+	.sleb128	-12
+	.long	_$PROGRAM$_Ld2
+	.byte	0
+# Defs - Begin unit SYSTEM has index 1
+# Definition Byte
+	.type	_$PROGRAM$_Ld3,@object
+_$PROGRAM$_Ld3:
+	.uleb128	13
+	.ascii	"BYTE\000"
+	.long	.La1
+	.type	.La1,@object
+.La1:
+	.uleb128	14
+	.ascii	"BYTE\000"
+	.byte	7
+	.byte	1
+	.type	_$PROGRAM$_Ld4,@object
+_$PROGRAM$_Ld4:
+	.uleb128	15
+	.long	_$PROGRAM$_Ld3
+# Defs - End unit SYSTEM has index 1
+# Defs - Begin unit FPINTRES has index 2
+# Defs - End unit FPINTRES has index 2
+# Defs - Begin unit OBJPAS has index 3
+# Defs - End unit OBJPAS has index 3
+# Defs - Begin unit SI_PRC has index 3
+# Defs - End unit SI_PRC has index 3
+# Defs - Begin Staticsymtable
+# Definition tr
+	.type	_$PROGRAM$_Ld1,@object
+_$PROGRAM$_Ld1:
+	.uleb128	16
+	.ascii	"TR\000"
+	.long	.La2
+	.type	.La2,@object
+.La2:
+	.uleb128	17
+	.ascii	"TR\000"
+	.uleb128	1006
+	.uleb128	18
+	.ascii	"A\000"
+	.byte	2
+	.byte	35
+	.uleb128	0
+	.long	_$PROGRAM$_Ld3
+	.uleb128	19
+	.ascii	"B\000"
+	.byte	2
+	.byte	35
+	.uleb128	1
+	.long	_$PROGRAM$_Ld3
+	.uleb128	20
+	.ascii	"C\000"
+	.byte	2
+	.byte	35
+	.uleb128	2
+	.long	_$PROGRAM$_Ld3
+	.uleb128	21
+	.ascii	"D\000"
+	.byte	2
+	.byte	35
+	.uleb128	3
+	.long	_$PROGRAM$_Ld3
+	.uleb128	22
+	.ascii	"E\000"
+	.byte	2
+	.byte	35
+	.uleb128	4
+	.long	_$PROGRAM$_Ld3
+	.uleb128	23
+	.ascii	"F\000"
+	.byte	2
+	.byte	35
+	.uleb128	5
+	.long	_$PROGRAM$_Ld3
+	.uleb128	24
+	.ascii	"G\000"
+	.byte	2
+	.byte	35
+	.uleb128	6
+	.long	_$PROGRAM$_Ld5
+	.byte	0
+	.type	_$PROGRAM$_Ld2,@object
+_$PROGRAM$_Ld2:
+	.uleb128	25
+	.long	_$PROGRAM$_Ld1
+# Definition Array[0..999] Of Byte
+	.type	_$PROGRAM$_Ld5,@object
+_$PROGRAM$_Ld5:
+	.uleb128	26
+	.uleb128	1000
+	.long	_$PROGRAM$_Ld3
+	.uleb128	27
+	.sleb128	0
+	.sleb128	999
+	.uleb128	1
+	.long	_$PROGRAM$_Ld7
+	.byte	0
+	.type	_$PROGRAM$_Ld6,@object
+_$PROGRAM$_Ld6:
+	.uleb128	28
+	.long	_$PROGRAM$_Ld5
+# Defs - End Staticsymtable
+# Definition SmallInt
+	.type	_$PROGRAM$_Ld7,@object
+_$PROGRAM$_Ld7:
+	.uleb128	29
+	.ascii	"SMALLINT\000"
+	.long	.La3
+	.type	.La3,@object
+.La3:
+	.uleb128	30
+	.ascii	"SMALLINT\000"
+	.byte	5
+	.byte	2
+	.type	_$PROGRAM$_Ld8,@object
+_$PROGRAM$_Ld8:
+	.uleb128	31
+	.long	_$PROGRAM$_Ld7
+	.byte	0
+	.type	.Ledebug_info0,@object
+.Ledebug_info0:
+# End asmlist al_dwarf_info
+# Begin asmlist al_dwarf_abbrev
+
+.section .debug_abbrev
+# Abbrev 1
+	.uleb128	1
+	.uleb128	17
+	.byte	1
+	.uleb128	3
+	.uleb128	8
+	.uleb128	37
+	.uleb128	8
+	.uleb128	27
+	.uleb128	8
+	.uleb128	19
+	.uleb128	11
+	.uleb128	66
+	.uleb128	11
+	.uleb128	16
+	.uleb128	6
+	.uleb128	17
+	.uleb128	1
+	.uleb128	18
+	.uleb128	1
+	.byte	0
+	.byte	0
+# Abbrev 2
+	.uleb128	2
+	.uleb128	46
+	.byte	1
+	.uleb128	3
+	.uleb128	8
+	.uleb128	54
+	.uleb128	11
+	.uleb128	63
+	.uleb128	12
+	.uleb128	17
+	.uleb128	1
+	.uleb128	18
+	.uleb128	1
+	.byte	0
+	.byte	0
+# Abbrev 3
+	.uleb128	3
+	.uleb128	46
+	.byte	1
+	.uleb128	3
+	.uleb128	8
+	.uleb128	54
+	.uleb128	11
+	.uleb128	63
+	.uleb128	12
+	.uleb128	73
+	.uleb128	16
+	.uleb128	17
+	.uleb128	1
+	.uleb128	18
+	.uleb128	1
+	.byte	0
+	.byte	0
+# Abbrev 4
+	.uleb128	4
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 5
+	.uleb128	5
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 6
+	.uleb128	6
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 7
+	.uleb128	7
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 8
+	.uleb128	8
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 9
+	.uleb128	9
+	.uleb128	5
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 10
+	.uleb128	10
+	.uleb128	52
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 11
+	.uleb128	11
+	.uleb128	52
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 12
+	.uleb128	12
+	.uleb128	52
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	2
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 13
+	.uleb128	13
+	.uleb128	22
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 14
+	.uleb128	14
+	.uleb128	36
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	62
+	.uleb128	11
+	.uleb128	11
+	.uleb128	11
+	.byte	0
+	.byte	0
+# Abbrev 15
+	.uleb128	15
+	.uleb128	16
+	.byte	0
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 16
+	.uleb128	16
+	.uleb128	22
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 17
+	.uleb128	17
+	.uleb128	19
+	.byte	1
+	.uleb128	3
+	.uleb128	8
+	.uleb128	11
+	.uleb128	15
+	.byte	0
+	.byte	0
+# Abbrev 18
+	.uleb128	18
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 19
+	.uleb128	19
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 20
+	.uleb128	20
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 21
+	.uleb128	21
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 22
+	.uleb128	22
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 23
+	.uleb128	23
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 24
+	.uleb128	24
+	.uleb128	13
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	56
+	.uleb128	10
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 25
+	.uleb128	25
+	.uleb128	16
+	.byte	0
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 26
+	.uleb128	26
+	.uleb128	1
+	.byte	1
+	.uleb128	11
+	.uleb128	15
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 27
+	.uleb128	27
+	.uleb128	33
+	.byte	0
+	.uleb128	34
+	.uleb128	13
+	.uleb128	47
+	.uleb128	13
+	.uleb128	81
+	.uleb128	15
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 28
+	.uleb128	28
+	.uleb128	16
+	.byte	0
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 29
+	.uleb128	29
+	.uleb128	22
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+# Abbrev 30
+	.uleb128	30
+	.uleb128	36
+	.byte	0
+	.uleb128	3
+	.uleb128	8
+	.uleb128	62
+	.uleb128	11
+	.uleb128	11
+	.uleb128	11
+	.byte	0
+	.byte	0
+# Abbrev 31
+	.uleb128	31
+	.uleb128	16
+	.byte	0
+	.uleb128	73
+	.uleb128	16
+	.byte	0
+	.byte	0
+	.byte	0
+# End asmlist al_dwarf_abbrev
+# Begin asmlist al_dwarf_line
+
+.section .debug_line
+# === header start ===
+	.long	.Ledebug_line0-.Lf2
+.Lf2:
+	.short	2
+	.long	.Lehdebug_line0-.Lf3
+.Lf3:
+	.byte	1
+	.byte	1
+	.byte	1
+	.byte	255
+	.byte	13
+	.byte	0
+	.byte	1
+	.byte	1
+	.byte	1
+	.byte	1
+	.byte	0
+	.byte	0
+	.byte	0
+	.byte	1
+	.byte	0
+	.byte	0
+	.byte	1
+# include_directories
+	.byte	0
+# file_names
+	.ascii	"tgdbcc.pp\000"
+	.uleb128	0
+	.uleb128	0
+	.uleb128	0
+	.byte	0
+	.type	.Lehdebug_line0,@object
+.Lehdebug_line0:
+# === header end ===
+# function: P$PROGRAM_FUNC$BYTE$BYTE$BYTE$BYTE$BYTE$BYTE$$TR
+# [10:1]
+	.byte	0
+	.uleb128	5
+	.byte	2
+	.long	.Ll1
+	.byte	5
+	.uleb128	1
+	.byte	21
+# [11:18]
+	.byte	2
+	.uleb128	.Ll2-.Ll1
+	.byte	5
+	.uleb128	18
+	.byte	13
+# [12:9]
+	.byte	2
+	.uleb128	.Ll3-.Ll2
+	.byte	5
+	.uleb128	9
+	.byte	13
+# [13:9]
+	.byte	2
+	.uleb128	.Ll4-.Ll3
+	.byte	13
+# [14:9]
+	.byte	2
+	.uleb128	.Ll5-.Ll4
+	.byte	13
+# [15:9]
+	.byte	2
+	.uleb128	.Ll6-.Ll5
+	.byte	13
+# [16:9]
+	.byte	2
+	.uleb128	.Ll7-.Ll6
+	.byte	13
+# [17:9]
+	.byte	2
+	.uleb128	.Ll8-.Ll7
+	.byte	13
+# [18:1]
+	.byte	2
+	.uleb128	.Ll9-.Ll8
+	.byte	5
+	.uleb128	1
+	.byte	13
+	.byte	0
+	.uleb128	5
+	.byte	2
+	.long	.Ll10
+	.byte	0
+	.byte	1
+	.byte	1
+# ###################
+# function: PASCALMAIN
+# function: main
+# [20:1]
+	.byte	0
+	.uleb128	5
+	.byte	2
+	.long	.Ll11
+	.byte	5
+	.uleb128	1
+	.byte	31
+# [21:3]
+	.byte	2
+	.uleb128	.Ll12-.Ll11
+	.byte	5
+	.uleb128	3
+	.byte	13
+# [22:1]
+	.byte	2
+	.uleb128	.Ll13-.Ll12
+	.byte	5
+	.uleb128	1
+	.byte	13
+	.byte	0
+	.uleb128	5
+	.byte	2
+	.long	.Ll14
+	.byte	0
+	.byte	1
+	.byte	1
+# ###################
+	.type	.Ledebug_line0,@object
+.Ledebug_line0:
+# End asmlist al_dwarf_line
+# Begin asmlist al_picdata
+# End asmlist al_picdata
+# Begin asmlist al_resourcestrings
+# End asmlist al_resourcestrings
+# Begin asmlist al_objc_data
+# End asmlist al_objc_data
+# Begin asmlist al_end
+
+.section .text
+.globl	DEBUGEND_P$PROGRAM
+	.type	DEBUGEND_P$PROGRAM,@object
+DEBUGEND_P$PROGRAM:
+# End asmlist al_end
+.section .note.GNU-stack,"",%progbits
+
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.exp b/gdb/ 
testsuite/gdb.dwarf2/dw2-borland_fastcall.exp
new file mode 100644
index 0000000..bd30a20
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-borland_fastcall.exp
@@ -0,0 +1,52 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test Borland fastcall calling convention
+
+# This test can only be run on targets which support DWARF-2 and use  
gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+    && ![istarget *-*-gnu*]
+    && ![istarget *-*-elf*]
+    && ![istarget *-*-openbsd*]} {
+    return 0;
+  }
+
+# This test can only be run on x86 targets.
+if {![istarget i?86-*]} {
+    return 0
+}
+
+set testfile "dw2-borland_fastcall"
+set srcfile ${testfile}.S
+set binfile ${objdir}/${subdir}/${testfile}.x
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}"  
executable {nodebug}] != "" } {
+    return -1
+}
+
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if { ![runto_main] } {
+    return -1
+}
+
+
+gdb_test "p FUNC(1,2,3,4,5,6)" \
+    "= {A = 1, B = 2, C = 3, D = 4, E = 5, F = 6, G = #0 <repeats 999  
times>}"


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

* Re: [patch] Set calling convention of methods
  2009-09-30 17:35                         ` Tom Tromey
@ 2009-10-01  9:21                           ` Jonas Maebe
  0 siblings, 0 replies; 28+ messages in thread
From: Jonas Maebe @ 2009-10-01  9:21 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Joel Brobecker, Mark Kettenis, gdb-patches


On 30 Sep 2009, at 19:34, Tom Tromey wrote:

> Joel> Confirmed. It's written plain as day in the header.  The  
> sticky part
> Joel> is that Jonas does NOT have copyright assignment on file for  
> GCC, as
> Joel> far as I can tell...

That's correct, I only have them for binutils and gdb, afaik.

> I think this patch is small enough not to matter.

I hope so. I'll ask the FSF to also get a copyright assignment form  
for GCC (fortunately, that does not require an extra intervention from  
my employer).


Jonas


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

* Re: [patch] Set calling convention of methods
  2009-10-01  9:18                         ` Jonas Maebe
@ 2009-10-01 22:04                           ` Joel Brobecker
  2009-10-02  9:21                           ` Mark Kettenis
  1 sibling, 0 replies; 28+ messages in thread
From: Joel Brobecker @ 2009-10-01 22:04 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: Tom Tromey, Mark Kettenis, gdb-patches ml

> Ok. Note that my mail client is known to wrap text at 80 columns
[...]
If that's the case, then let's avoid inlined patches. We sometimes try
to apply your patch for various reasons such as testing, etc. I'd rather
have an encoded attachment rather than a malformed patch.

> Given that it was later confirmed that the file does belong to gcc,  
> should I resend my patch for dwarf2.h to the gcc patches list?

Yes please. Ping them until someone finally gives the OK. Do mention
that this needs to be accepted under the "tiny change" rule, as you
are still working on copyright assignment for GCC.

I'll review the rest of the patch hopefully tomorrow.

-- 
Joel


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

* Re: [patch] Set calling convention of methods
  2009-10-01  9:18                         ` Jonas Maebe
  2009-10-01 22:04                           ` Joel Brobecker
@ 2009-10-02  9:21                           ` Mark Kettenis
  1 sibling, 0 replies; 28+ messages in thread
From: Mark Kettenis @ 2009-10-02  9:21 UTC (permalink / raw)
  To: jonas.maebe; +Cc: brobecker, tromey, mark.kettenis, gdb-patches

> From: Jonas Maebe <jonas.maebe@elis.ugent.be>
> Date: Thu, 1 Oct 2009 11:17:54 +0200
> 
> > Overall, this looks OK to me, but Mark seemed interested in reviewing
> > this patch, so please wait for his comments as well.
> 
> Ok. Note that my mail client is known to wrap text at 80 columns (and  
> adds a space at the end of each wrapped line for detecting this  
> operation). This behaviour cannot be disabled afaik, and yes, one  
> could certainly consider this to be a bug. At the same time, it  
> however also adds '"Format="flowed"; DelSp="yes"' to the Content-Type  
> header, so mail clients on the other side can reconstruct the original  
> text (if those clients support these modifiers, which I hope is the  
> case).

It's sad that modern graphical e-mail clients get in the way here and
generate all this complicated crap.

Some people using similarly broken mail clients circumvent the problem
by including a diff both inline and as an attachment.  While not
ideal, that's an acceptable solution to me.

> 2009-10-01  Jonas Maebe  <jonas.maebe <at> elis.ugent.be>
> 
> 	Add support for the "Borland fastcall" calling convention.
> 
> 	* dwarf2.h: Add DW_CC_GNU_borland_fastcall_i386 constant.
> 	* i386-tdep.c: #include dwarf2.h
> 	(i386_borland_fastcall_push_dummy_call): New.
> 	(i386_push_dummy_generic_call): Renamed i386_push_dummy_call.
> 	(i386_push_dummy_call): New dispatch function that calls
> 	i386_generic_push_dummy_call or i386_push_dummy_borland_fast_call
> 	depending on the calling convention.
> 	* gdb.dwarf2/dw2-borland_fastcall.exp: New.
> 	* gdb.dwarf2/dw2-borland_fastcall.S: New.

The i386-tdep.c bits are fine with me.  I haven't been following the
dwarf2.h discussion too closely; whatever consensus that's reached
there is fine with me.


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

* Re: [patch] Set calling convention of methods
  2009-09-30 17:32                       ` Joel Brobecker
  2009-09-30 17:35                         ` Tom Tromey
@ 2009-11-03  9:43                         ` Jonas Maebe
  2009-11-03 14:19                           ` Joel Brobecker
  1 sibling, 1 reply; 28+ messages in thread
From: Jonas Maebe @ 2009-11-03  9:43 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, Mark Kettenis, gdb-patches


On 30 Sep 2009, at 19:32, Joel Brobecker wrote:

>> Jonas> Later on, Tom clarified that he thought that the gdb and gcc  
>> versions
>> Jonas> of dwarf2.h should actually be merged into a single copy,  
>> but that I
>> Jonas> shouldn't worry about this since the divergence started  
>> before my
>> Jonas> patch: http://sourceware.org/ml/gdb-patches/2009-04/msg00099.html
>>
>> I've merged these now.
>>
>> I think the usual approach for such merged files is that GCC is the
>> master copy.
>
> Confirmed. It's written plain as day in the header.  The sticky part
> is that Jonas does NOT have copyright assignment on file for GCC, as
> far as I can tell...

I've pinged my dwarf2.h thrice on the gcc-patches list in the mean  
time (always inline, because it doesn't contain any lines >= 80  
chars), the last time mentioning that I now also have a copyright  
assignment on file for GCC. I haven received so much as an  
acknowledgment.

Here's the last ping I did: http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01788.html 
  (it's only from Friday, but given my past experiences, I don't  
expect it suddenly to be picked up after getting buried under a couple  
days extra mail).

I don't know what else to do.


Jonas


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

* Re: [patch] Set calling convention of methods
  2009-11-03  9:43                         ` Jonas Maebe
@ 2009-11-03 14:19                           ` Joel Brobecker
  0 siblings, 0 replies; 28+ messages in thread
From: Joel Brobecker @ 2009-11-03 14:19 UTC (permalink / raw)
  To: Jonas Maebe; +Cc: Tom Tromey, Mark Kettenis, gdb-patches

> Here's the last ping I did: 
> http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01788.html (it's only from 
> Friday, but given my past experiences, I don't expect it suddenly to be 
> picked up after getting buried under a couple days extra mail).
> I don't know what else to do.

I've sent a request for someone to take a look. I don't think I'm any
more popular than you are, but I tried the good old pleading puppy eyes
strategy :). Let me know if we still don't get any answer within a week,
and I'll try to ask some of the AdaCore engineers who work on the GCC
side to help.

-- 
Joel


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

end of thread, other threads:[~2009-11-03 14:19 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-06 19:51 [patch] Set calling convention of methods Jonas Maebe
2009-04-10 17:34 ` Tom Tromey
2009-04-20  8:40   ` Jonas Maebe
2009-04-20 18:27     ` Tom Tromey
2009-04-22 17:45       ` Jonas Maebe
2009-04-22 19:22         ` Tom Tromey
2009-04-22 22:16         ` Mark Kettenis
2009-06-04  8:23           ` Jonas Maebe
2009-06-04 18:19             ` Tom Tromey
2009-06-10 20:44               ` Jonas Maebe
2009-06-18 21:45                 ` Fwd: " Jonas Maebe
2009-09-30  0:02                 ` Joel Brobecker
2009-09-30 11:18                   ` Jonas Maebe
2009-09-30 14:54                     ` Jonas Maebe
2009-09-30 15:22                       ` Mark Kettenis
2009-09-30 16:25                       ` Joel Brobecker
2009-10-01  9:18                         ` Jonas Maebe
2009-10-01 22:04                           ` Joel Brobecker
2009-10-02  9:21                           ` Mark Kettenis
2009-09-30 16:10                     ` Joel Brobecker
2009-09-30 17:36                       ` Joel Brobecker
2009-09-30 16:47                     ` Tom Tromey
2009-09-30 17:32                       ` Joel Brobecker
2009-09-30 17:35                         ` Tom Tromey
2009-10-01  9:21                           ` Jonas Maebe
2009-11-03  9:43                         ` Jonas Maebe
2009-11-03 14:19                           ` Joel Brobecker
2009-07-06 20:50               ` Jonas Maebe

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