This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Re: [PATCH] Fix for incorect breakpoint set in case of clang compiled binary
- From: KARTHIKVENKATESH BHAT <kv dot bhat at samsung dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Mon, 19 Nov 2012 15:19:20 +0000 (GMT)
- Subject: Re: Re: [PATCH] Fix for incorect breakpoint set in case of clang compiled binary
- Dlp-filter: Pass
- Msgkey: 20121119150652783@kv.bhat
- Reply-to: kv dot bhat at samsung dot com
Hi,
Yes the below code (uses symbol table to determine the end of prologue) may not be target dependent in this case.
But the same method in ARM for e.g.(arm-tdep.c /arm_skip_prologue) uses some target specific call such as -
(post_prologue_pc)
post_prologue_pc = arm_skip_stack_protector (post_prologue_pc, gdbarch);
so moving the function to a target-independent function may not be that useful. Hence added the same in i386-tdep.c.
Regards
Karthik
------- Original Message -------
Sender : H.J. Lu<hjl.tools@gmail.com>
Date : Nov 19, 2012 23:42 (GMT+09:00)
Title : Re: [PATCH] Fix for incorect breakpoint set in case of clang compiled binary
On Mon, Nov 19, 2012 at 12:06 AM, KARTHIKVENKATESH BHAT
wrote:
> Dear All,
> I wanted to add a patch in i386-tdep.c . Similar to what is done in other architectures such as ARM,
> instead of actually going through the complete prologue if we can use the symbol table information to resolve prologue end.
>
>
> Index: gdb/i386-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/i386-tdep.c,v
> retrieving revision 1.362
> diff -u -p -r1.362 i386-tdep.c
> --- gdb/i386-tdep.c 12 Nov 2012 21:59:06 -0000 1.362
> +++ gdb/i386-tdep.c 19 Nov 2012 07:56:45 -0000
> @@ -1582,8 +1582,30 @@ i386_skip_prologue (struct gdbarch *gdba
> CORE_ADDR pc;
> gdb_byte op;
> int i;
> + cache.locals = -1;
> + CORE_ADDR func_addr;
> + struct symtab *s = find_pc_symtab (func_addr);
> +
> + if (find_pc_partial_function (start_pc, NULL, &func_addr, NULL))
> + {
> + CORE_ADDR post_prologue_pc
> + = skip_prologue_using_sal (gdbarch, func_addr);
> +
> + /* GCC always emits a line note before the prologue and another
> + one after, even if the two are at the same address or on the
> + same line. Take advantage of this so that we do not need to
> + know every instruction that might appear in the prologue. We
> + will have producer information for most binaries; if it is
> + missing (e.g. for -gstabs), assuming the GNU tools. */
> + if (post_prologue_pc
> + && (s == NULL
> + || s->producer == NULL
> + || strncmp (s->producer, "GNU ", sizeof ("GNU ") - 1) == 0
> + || strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))
> + return max (start_pc, post_prologue_pc);
> + }
> +
>
>
It doesn't look like target-dependent. If we do this, why not
make it a target-independent function make all targets call it?
--
H.J.