Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] DW_AT_calling_convention support
@ 2002-07-09 14:08 Petr Sorfa
  2002-07-09 14:24 ` Daniel Jacobowitz
  0 siblings, 1 reply; 18+ messages in thread
From: Petr Sorfa @ 2002-07-09 14:08 UTC (permalink / raw)
  To: gdb-patches

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

Hi,

Patch for supporting DW_AT_calling_convention. This helps GDB identify
the "main" program for languages that do not have a starting subroutine
called "main". The patch also adds a new type flag,
TYPE_FLAG_MAIN_PROGRAM which is set if the type is describing a "main"
entry point. This can be used, for example, in noting a subroutine type
as a FORTRAN PROGRAM.

2002-07-09 Petr Sorfa (petrs@caldera.com)

        *  dwarf2read.c (read_subroutine_type): Expanded to recognize
           the DW_AT_calling_convention DWARF attribute and for
           DW_CC_program set the TYPE_FLAG_MAIN_PROGRAM type flag
           and call set_main_name ().
           (read_partial_die): Now recognizes the
           DW_AT_calling_convention attribute and calls set_main_name().
           Note that TYPE_FLAG_MAIN_PROGRAM type flag is not set, as
           the partial_die might not denote a subroutine type.

        *  gdbtypes.h (TYPE_FLAG_MAIN_PROGRAM): New type flag which
           indicates whether the type denotes a main program subroutine.
           (TYPE_MAIN_PROGRAM): New macro that returns a non-zero value
           if the type describes a main program subroutine.

[-- Attachment #2: calling_convention.patch --]
[-- Type: text/plain, Size: 3308 bytes --]

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.60
diff -c -p -r1.60 dwarf2read.c
*** dwarf2read.c	22 Jun 2002 00:05:59 -0000	1.60
--- dwarf2read.c	9 Jul 2002 20:42:35 -0000
*************** read_subroutine_type (struct die_info *d
*** 3026,3031 ****
--- 3026,3053 ----
        || cu_language == language_cplus)
      TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
  
+   /* Check for the calling convention. A DW_CC_program indicates that
+      the subroutine is the the "main" of the program. This needs
+      to be set for languages that don't have a predefined name
+      for the starting subroutines, such as FORTRAN. */
+   attr = dwarf_attr (die, DW_AT_calling_convention);
+   if (attr && (DW_UNSND (attr) != 0))
+     {
+       switch (DW_UNSND (attr))
+         {
+           case DW_CC_program:
+             /* Set this subroutine as the "main" subroutine
+                for the program. */
+             TYPE_FLAGS (ftype) |= TYPE_FLAG_MAIN_PROGRAM;
+             set_main_name (TYPE_NAME (ftype));
+             break;
+           case DW_CC_normal:
+           case DW_CC_nocall:
+           default:
+             break;
+         }
+     }
+ 
    if (die->has_children)
      {
        struct die_info *child_die;
*************** read_partial_die (struct partial_die_inf
*** 3414,3419 ****
--- 3436,3442 ----
    int found_spec_attr = 0;
    int has_low_pc_attr = 0;
    int has_high_pc_attr = 0;
+   int is_main_program = 0;
  
    *part_die = zeroed_partial_die;
    abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
*************** read_partial_die (struct partial_die_inf
*** 3446,3451 ****
--- 3469,3486 ----
  	  if (part_die->name == NULL)
  	    part_die->name = DW_STRING (&attr);
  	  break;
+         case DW_AT_calling_convention:
+           switch (DW_UNSND (&attr))
+             {
+             case DW_CC_program:
+               is_main_program = 1;
+               break;
+             case DW_CC_normal:
+             case DW_CC_nocall:
+             default:
+               break;
+             }
+           break;
  	case DW_AT_MIPS_linkage_name:
  	  part_die->name = DW_STRING (&attr);
  	  break;
*************** read_partial_die (struct partial_die_inf
*** 3489,3494 ****
--- 3524,3534 ----
  	default:
  	  break;
  	}
+     }
+ 
+   if (is_main_program)
+     {
+       set_main_name (part_die->name);
      }
  
    /* If we found a reference attribute and the die has no name, try
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.33
diff -c -p -r1.33 gdbtypes.h
*** gdbtypes.h	14 Jun 2002 14:34:24 -0000	1.33
--- gdbtypes.h	9 Jul 2002 20:42:35 -0000
*************** enum type_code
*** 252,257 ****
--- 252,263 ----
  #define TYPE_FLAG_VECTOR	(1 << 12)
  #define TYPE_VECTOR(t)		(TYPE_FLAGS (t) & TYPE_FLAG_VECTOR)
  
+ /* This flag is to indicate that the subprogram type indicates
+    a the main program. Mainly used to indicate FORTRAN program
+    scopes. */
+ #define TYPE_FLAG_MAIN_PROGRAM	(1 << 13)
+ #define TYPE_MAIN_PROGRAM(t)	(TYPE_FLAGS (t) & TYPE_FLAG_MAIN_PROGRAM)
+ 
  struct main_type
  {
    /* Code for kind of type */

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

end of thread, other threads:[~2002-07-10 19:32 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-09 14:08 [PATCH] DW_AT_calling_convention support Petr Sorfa
2002-07-09 14:24 ` Daniel Jacobowitz
2002-07-09 14:58   ` Petr Sorfa
2002-07-09 15:05     ` Daniel Jacobowitz
2002-07-10  7:03       ` Petr Sorfa
2002-07-10  7:19         ` Daniel Jacobowitz
2002-07-10  7:25           ` Petr Sorfa
2002-07-10  8:02             ` Daniel Jacobowitz
2002-07-10  9:07               ` Jim Blandy
2002-07-10 10:00                 ` Petr Sorfa
2002-07-10 10:18                   ` Petr Sorfa
2002-07-10 10:33                     ` Jim Blandy
2002-07-10 11:32                       ` Petr Sorfa
2002-07-10 11:47                         ` Jim Blandy
2002-07-10 11:49                           ` Daniel Jacobowitz
2002-07-10 12:35                             ` Jim Blandy
2002-07-10 12:27                           ` Daniel Berlin
2002-07-10  8:26           ` Andrew Cagney

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