* [RFA] mingw64: Skip over __main in main
@ 2010-09-27 17:43 Pierre Muller
2010-09-27 19:01 ` Mark Kettenis
0 siblings, 1 reply; 3+ messages in thread
From: Pierre Muller @ 2010-09-27 17:43 UTC (permalink / raw)
To: gdb-patches
This patch enables recognition of call to __main
as part of the prologue of main for mingw64 binaries.
It's almost a copy of the i386-tdep.c counterpart
(expect that I removed the 32-bit specific overflow code).
It makes things more consistent with the way 32-bit binaries
are treated and allows to run testsuite on Cygwin
(after a few tricks ...).
Is this patch OK?
2010-09-27 Pierre Muller <muller@ics.u-strasbg.fr>
* src/gdb/amd64-windows-tdep.c (amd64_skip_main_prologue): New function.
(amd64_windows_init_abi): Register amd64_skip_main_prologue
as gdbarch skip_main_prologue method.
Index: src/gdb/amd64-windows-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64-windows-tdep.c,v
retrieving revision 1.6
diff -u -p -r1.6 amd64-windows-tdep.c
--- src/gdb/amd64-windows-tdep.c 29 Jan 2010 05:29:21 -0000 1.6
+++ src/gdb/amd64-windows-tdep.c 27 Sep 2010 16:15:28 -0000
@@ -122,6 +122,38 @@ amd64_windows_return_value (struct gdbar
}
}
+/* Check that the code pointed to by PC corresponds to a call to
+ __main, skip it if so. Return PC otherwise. */
+
+static CORE_ADDR
+amd64_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ gdb_byte op;
+
+ target_read_memory (pc, &op, 1);
+ if (op == 0xe8)
+ {
+ gdb_byte buf[4];
+
+ if (target_read_memory (pc + 1, buf, sizeof buf) == 0)
+ {
+ struct minimal_symbol *s;
+ CORE_ADDR call_dest;
+
+ call_dest = pc + 5 + extract_signed_integer (buf, 4, byte_order);
+ s = lookup_minimal_symbol_by_pc (call_dest);
+ if (s != NULL
+ && SYMBOL_LINKAGE_NAME (s) != NULL
+ && strcmp (SYMBOL_LINKAGE_NAME (s), "__main") == 0)
+ pc += 5;
+ }
+ }
+
+ return pc;
+}
+
+
static void
amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
@@ -140,6 +172,7 @@ amd64_windows_init_abi (struct gdbarch_i
tdep->memory_args_by_pointer = 1;
tdep->integer_param_regs_saved_in_caller_frame = 1;
set_gdbarch_return_value (gdbarch, amd64_windows_return_value);
+ set_gdbarch_skip_main_prologue (gdbarch, amd64_skip_main_prologue);
set_solib_ops (gdbarch, &solib_target_so_ops);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] mingw64: Skip over __main in main
2010-09-27 17:43 [RFA] mingw64: Skip over __main in main Pierre Muller
@ 2010-09-27 19:01 ` Mark Kettenis
2010-09-28 9:21 ` Pierre Muller
0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2010-09-27 19:01 UTC (permalink / raw)
To: pierre.muller; +Cc: gdb-patches
> From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> Date: Mon, 27 Sep 2010 18:25:25 +0200
>
> This patch enables recognition of call to __main
> as part of the prologue of main for mingw64 binaries.
>
> It's almost a copy of the i386-tdep.c counterpart
> (expect that I removed the 32-bit specific overflow code).
>
> It makes things more consistent with the way 32-bit binaries
> are treated and allows to run testsuite on Cygwin
> (after a few tricks ...).
>
> Is this patch OK?
Fine with me.
> 2010-09-27 Pierre Muller <muller@ics.u-strasbg.fr>
>
> * src/gdb/amd64-windows-tdep.c (amd64_skip_main_prologue): New function.
> (amd64_windows_init_abi): Register amd64_skip_main_prologue
> as gdbarch skip_main_prologue method.
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [RFA] mingw64: Skip over __main in main
2010-09-27 19:01 ` Mark Kettenis
@ 2010-09-28 9:21 ` Pierre Muller
0 siblings, 0 replies; 3+ messages in thread
From: Pierre Muller @ 2010-09-28 9:21 UTC (permalink / raw)
To: 'Mark Kettenis'; +Cc: gdb-patches
> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Mark Kettenis
> Envoyé : Monday, September 27, 2010 7:43 PM
> À : pierre.muller@ics-cnrs.unistra.fr
> Cc : gdb-patches@sourceware.org
> Objet : Re: [RFA] mingw64: Skip over __main in main
>
> > From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> > Date: Mon, 27 Sep 2010 18:25:25 +0200
> >
> > This patch enables recognition of call to __main
> > as part of the prologue of main for mingw64 binaries.
> >
> > It's almost a copy of the i386-tdep.c counterpart
> > (expect that I removed the 32-bit specific overflow code).
> >
> > It makes things more consistent with the way 32-bit binaries
> > are treated and allows to run testsuite on Cygwin
> > (after a few tricks ...).
> >
> > Is this patch OK?
>
> Fine with me.
Thanks for the approval,
patch committed.
http://sourceware.org/ml/gdb-cvs/2010-09/msg00166.html
Pierre
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-27 22:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-27 17:43 [RFA] mingw64: Skip over __main in main Pierre Muller
2010-09-27 19:01 ` Mark Kettenis
2010-09-28 9:21 ` Pierre Muller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox