Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <muller@ics.u-strasbg.fr>
To: <gdb-patches@sourceware.org>
Cc: <gpc@gnu.de>
Subject: [RFC] Handle GPC specific name for main function
Date: Wed, 26 Sep 2007 14:40:00 -0000	[thread overview]
Message-ID: <003901c8004b$2f9a55d0$8ecf0170$@u-strasbg.fr> (raw)

  This patch looks up for
GPC specific minimal symbols
and assumes that if they are present,
the executable was compiled by GPC.
  GPC used 'pascal_main_program' and now
uses '_p__M0_main_program'.

  Is there some other way to check that the 
program was really compiled by GPC?
(Any C compiled program could have a
'pascal_main_program' function...)

  Maybe by looking up some other symbol?
I found 'GPC_init' as a possible candidate,
but I am not sure that this symbol is 
defined for all versions of GPC, so I did not 
include it in the present RFC.

  I tested the patch on Cygwin and it
allows to use 'start' command and get
directly at the right location.

  This will also help to reduce the gap between
GPC and FreePascal for the (not yet committed)
gdb.pascal testsuite directory.

  Any feedback from GPC users would be most helpful here.

Pierre Muller
Pascal language maintainer.



ChangeLog entry:

2007-09-26  Pierre Muller  <muller@ics.u-strasbg.fr>
	* p-lang.h (pascal_main_name): New function.
	p-lang.c (GPC_MAIN_PROGRAM_NAME_1,
	GPC_MAIN_PROGRAM_NAME_2): New char array constants
	corresponding to the two minimal symbols used 
	by GPC compiler.
	(pascal_main_name): Try to find minimal symbol
	corresponding to the entry of GPC compiled programs.
	symtab.c (find_main_name): Try to find
	pascal specific main name by calling pascal_main_name.



$ cvs diff -up p-lang.h p-lang.c symtab.c
Index: p-lang.h
===================================================================
RCS file: /cvs/src/src/gdb/p-lang.h,v
retrieving revision 1.12
diff -u -p -r1.12 p-lang.h
--- p-lang.h    23 Aug 2007 18:08:36 -0000      1.12
+++ p-lang.h    26 Sep 2007 14:26:08 -0000
@@ -21,6 +21,8 @@

 struct value;

+extern char *pascal_main_name (void);
+
 extern int pascal_parse (void);        /* Defined in p-exp.y */

$
Index: p-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/p-lang.c,v
retrieving revision 1.33
diff -u -p -r1.33 p-lang.c
--- p-lang.c    23 Sep 2007 16:25:05 -0000      1.33
+++ p-lang.c    26 Sep 2007 14:26:09 -0000
@@ -35,6 +35,43 @@
 extern void _initialize_pascal_language (void);


+/* The name of the symbol used by GPC compiler.  */
+
+static const char GPC_MAIN_PROGRAM_NAME_1[]
+  = "pascal_main_program";
+static const char GPC_MAIN_PROGRAM_NAME_2[]
+  = "_p__M0_main_program";
+
+char *
+pascal_main_name (void)
+{
+  struct minimal_symbol *msym;
+  CORE_ADDR main_program_name_addr;
+  static char main_program_name[1024];
+
+  /* For GPC, main procedure s a special name.
+     .  */
+
+
+  msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_1, NULL, NULL);
+
+  if (msym != NULL)
+    {
+      return (char *)GPC_MAIN_PROGRAM_NAME_1;
+    }
+
+  msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_2, NULL, NULL);
+
+  if (msym != NULL)
+    {
+      return (char *)GPC_MAIN_PROGRAM_NAME_2;
+    }
+
+  /* The main procedure doesn't seem to be in GPC.
+     Thus default "main" should work.  */
+  return NULL;
+}
+
 /* Determines if type TYPE is a pascal string type.
    Returns 1 if the type is a known pascal type
    This function is used by p-valprint.c code to allow better string
display.
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.165
diff -u -p -r1.165 symtab.c
--- symtab.c    24 Sep 2007 07:40:32 -0000      1.165
+++ symtab.c    26 Sep 2007 14:26:10 -0000
@@ -40,6 +40,7 @@
 #include "filenames.h"         /* for FILENAME_CMP */
 #include "objc-lang.h"
 #include "ada-lang.h"
+#include "p-lang.h"

 #include "hashtab.h"

@@ -4151,6 +4152,13 @@ find_main_name (void)
       return;
     }

+  new_main_name = pascal_main_name ();
+  if (new_main_name != NULL)
+    {
+      set_main_name (new_main_name);
+      return;
+    }
+
   /* The languages above didn't identify the name of the main procedure.
      Fallback to "main".  */
   set_main_name ("main");



             reply	other threads:[~2007-09-26 14:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 14:40 Pierre Muller [this message]
2007-09-26 15:03 ` Eli Zaretskii
2007-09-26 15:32   ` Pierre Muller
2007-09-26 17:48     ` Eli Zaretskii
2007-09-26 17:58 ` Joel Brobecker
2007-09-26 19:39   ` Pierre Muller
2007-09-26 19:50     ` Joel Brobecker
2007-09-26 22:06       ` Pierre Muller
2007-09-26 22:39         ` [RFC-2] " Pierre Muller
2007-09-27  6:03           ` Joel Brobecker
2007-09-27  7:29             ` [RFC-3] " Pierre Muller
     [not found]               ` <46FB5E2C.6080606@microbizz.nl>
     [not found]                 ` <46FB5F76.9050501@microbizz.nl>
2007-09-27  7:57                   ` Pierre Muller
2007-09-27 12:11                     ` Daniel Jacobowitz
2007-09-27 12:35                       ` Pierre Muller
2007-09-27 12:40                         ` 'Daniel Jacobowitz'
2007-09-27 16:20                           ` Joel Brobecker
2007-09-27 16:32                             ` Joel Brobecker
2007-09-27 21:36                               ` Pierre Muller
2007-09-28 18:31                                 ` Joel Brobecker
2007-09-27  8:02                 ` Pierre Muller
2007-09-27 13:01                   ` Waldek Hebisch
2007-09-27  7:20           ` [RFC-2] " Eli Zaretskii
2007-09-27  1:58 ` [RFC] " Waldek Hebisch
2007-09-27  5:52   ` Joel Brobecker
2007-09-27 17:17     ` Thiago Jung Bauermann
2007-09-27 19:50       ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='003901c8004b$2f9a55d0$8ecf0170$@u-strasbg.fr' \
    --to=muller@ics.u-strasbg.fr \
    --cc=gdb-patches@sourceware.org \
    --cc=gpc@gnu.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox