Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro_alves@portugalmail.pt>
To: gdb-patches@sourceware.org
Subject: Re: [rfc] Teach i386 prologue reader about _alloca and __main
Date: Sat, 13 Oct 2007 23:20:00 -0000	[thread overview]
Message-ID: <471134B9.5060609@portugalmail.pt> (raw)
In-Reply-To: <20071013202615.GA9946@caradoc.them.org>

Daniel Jacobowitz wrote:
> On Sat, Oct 13, 2007 at 08:54:45PM +0100, Pedro Alves wrote:
>> 	* gdbarch.sh (gdbarch_skip___main_call): New.
>> 	* gdbarch.h, gdbarch.c: Regenerate.
> 
> I don't have time or experience to look at this thoroughly right now,
> but I did notice this: you can just put this in i386's gdbarch_tdep.
> 

The __main call is not i386 specific.  Eg. arm-wince has the same problem.

More precisely, it matches the targets where this is true in gcc/function.c.

void
expand_main_function (void)
{
#if (defined(INVOKE__main)                              \
      || (!defined(HAS_INIT_SECTION)                     \
          && !defined(INIT_SECTION_ASM_OP)               \
          && !defined(INIT_ARRAY_SECTION_ASM_OP)))
   emit_library_call (init_one_libfunc (NAME__MAIN), LCT_NORMAL, VOIDmode, 0);
#endif
}

I've also experimented with calling skip__main_call from
find_function_start_sal, but later moved it into i386-tdep.c.
That's still an open issue for me.

--- symtab.c    2007-10-13 20:08:38.000000000 +0100
+++ symtab.c.skip_main  2007-10-13 20:08:32.000000000 +0100
@@ -2493,6 +2493,16 @@ find_function_start_sal (struct symbol *
        /* Recalculate the line number (might not be N+1).  */
        sal = find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0);
      }
+
+  /* Skip __main call in targets without .init section and/or that
+   emit a call to __main in main as the first thing after the
+   prologue, before user code.  */
+  if (funfirstline
+      && gdbarch_skip___main_call_p (current_gdbarch)
+      && SYMBOL_LINKAGE_NAME (sym)
+      && strcmp (SYMBOL_LINKAGE_NAME (sym), "main") == 0)
+    pc = gdbarch_skip___main_call (current_gdbarch, pc);
+
    sal.pc = pc;

    return sal;

I'll experiment a bit more with it.

I'm mostly asking for advice on:

- Is the gdb-only solution preferable?  That is, the line info
   currently marks the prologue ending *before* the __main call.
   Last year's version changed that, this one doesn't.  Does anyone
   see any problem with that?

Cheers,
Pedro Alves



  reply	other threads:[~2007-10-13 21:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-13 20:26 Pedro Alves
2007-10-13 21:09 ` Daniel Jacobowitz
2007-10-13 23:20   ` Pedro Alves [this message]
2007-10-14 15:55     ` Daniel Jacobowitz
2007-10-13 21:14 ` Mark Kettenis
2007-10-14  2:24   ` Pedro Alves
2007-12-05 10:11 ` [RFC] testsuite: Skip over function prologue in runto and runto_main Pierre Muller
2007-12-05 22:56   ` Pedro Alves
2007-12-06 16:34     ` Pierre Muller
2007-12-06 17:07       ` Daniel Jacobowitz

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=471134B9.5060609@portugalmail.pt \
    --to=pedro_alves@portugalmail.pt \
    --cc=gdb-patches@sourceware.org \
    /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