This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PING2] : [RFC/RFA] PING: skip __main
Thanks for the fast reply.
> I'm afraid I think that skip_main_constructor_call is too long as a name.
I am perfectly willing to use something shorter,
the only problem is to find something that would still be
of clear meaning.
maybe
skip_main_prologue
would be better?
> I'd also appreciate it if you could seperate local variable
> declarations from the stations that follow by a blank line. Otherwise
> this looks ok to me.
Does this apply to both uninitialized and initialized variables?
Would the code hereafter be correct, or did I add too many empty lines?
+/* Check that the code pointed to by PC corresponds to a call to
+ __main, skip it if so. Return PC otherwise. */
+
+CORE_ADDR
+i386_skip_main_constructor_call (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ 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)
+ {
+ CORE_ADDR call_dest = pc + 5 + extract_unsigned_integer (buf, 4);
+
+ struct minimal_symbol *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;
+}
+
Thanks again for the reply.
Pierre Muller
Pascal language support maintainer for GDB