This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfc] Teach i386 prologue reader about _alloca and __main


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]