From: Joel Brobecker <brobecker@adacore.com>
To: Anthony Green <green@moxielogic.com>
Cc: gdb-patches@sourceware.org
Subject: Re: PATCH: new gdb port: moxie-elf
Date: Fri, 24 Apr 2009 03:28:00 -0000 [thread overview]
Message-ID: <20090424032759.GM7552@adacore.com> (raw)
In-Reply-To: <49F123A2.7060904@moxielogic.com>
> Final patch, as committed. Thanks Joel!
Great! Just to be certain, please do not forget about sending an RFA
for a NEWS entry. Eli, who is our documentation master, would be very
disappointed in me if you didn't...
Just something you said:
> No, I changed this function to use skip_prologue_using_sal()./
Ah ha, I missed that part. And indeed, if I look closer, I see it now:
> +static CORE_ADDR
> +moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
> +{
> + CORE_ADDR func_addr = 0, func_end = 0;
> + char *func_name;
> +
> + /* See if we can determine the end of the prologue via the symbol table.
> + If so, then return either PC, or the PC after the prologue, whichever
> + is greater. */
> + if (find_pc_partial_function (pc, &func_name, &func_addr, &func_end))
> + {
> + CORE_ADDR post_prologue_pc = skip_prologue_using_sal (func_addr);
> + if (post_prologue_pc != 0)
> + return max (pc, post_prologue_pc);
> + else
> + {
> + /* Can't determine prologue from the symbol table, need to examine
> + instructions. */
> + struct symtab_and_line sal;
> + struct symbol *sym;
> + struct moxie_frame_cache cache;
> + CORE_ADDR plg_end;
> +
> + memset (&cache, 0, sizeof cache);
> +
> + plg_end = moxie_analyze_prologue (func_addr,
> + func_end, &cache, NULL);
> + /* Found a function. */
> + sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL);
> + /* Don't use line number debug info for assembly source
> + files. */
> + if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
> + {
> + sal = find_pc_line (func_addr, 0);
> + if (sal.end && sal.end < func_end)
> + {
> + /* Found a line number, use it as end of
> + prologue. */
> + return sal.end;
> + }
> + }
> + /* No useable line symbol. Use result of prologue parsing
> + method. */
> + return plg_end;
> + }
> + }
> +
> + /* No function symbol -- just return the PC. */
> + return (CORE_ADDR) pc;
The following is just an observation, not a request to change your code.
That's a unusual implementation, more specifically in the second part
where skip_prologue_using_sal fails. I am trying to find a case where
skip_prologue_using_sal would return zero and yet you'd be able to
find a prologue end suing the line table and the only thing I can
find is when the function starts with line 2, then goes into line 1.
skip_prologue_using_sal would consider lines 2 and 1 to be part of the
prologue whereas the second part of your function would only consider
the code for line 2. That would probably be wrong.
Most implementations I remember that use skip_prologue_using_sal
actually look like this:
> static CORE_ADDR
> rs6000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
> {
> struct rs6000_framedata frame;
> CORE_ADDR limit_pc, func_addr;
>
> /* See if we can determine the end of the prologue via the symbol table.
> If so, then return either PC, or the PC after the prologue, whichever
> is greater. */
> if (find_pc_partial_function (pc, NULL, &func_addr, NULL))
> {
> CORE_ADDR post_prologue_pc = skip_prologue_using_sal (func_addr);
> if (post_prologue_pc != 0)
> return max (pc, post_prologue_pc);
> }
>
> /* Can't determine prologue from the symbol table, need to examine
> instructions. */
>
> /* Find an upper limit on the function prologue using the debug
> information. If the debug information could not be used to provide
> that bound, then use an arbitrary large number as the upper bound. */
> limit_pc = skip_prologue_using_sal (pc);
> if (limit_pc == 0)
> limit_pc = pc + 100; /* Magic. */
>
> pc = skip_prologue (gdbarch, pc, limit_pc, &frame);
> return pc;
The idea is: Try skip_prologue_using_sal. If that doesn't work,
then try to find an upper bound for our prologue, again using sals.
If not, then use an arbitrary maximum size for our prologue. Then
skip the prologue by doing instruction analysis. In your case,
you don't seem to need to have an upper bound in order to do prologue
analysis, so you can skiip the part that compute the limit_pc.
Just my 2 cents :)
--
Joel
next prev parent reply other threads:[~2009-04-24 3:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-23 11:57 green
2009-04-23 18:29 ` Joel Brobecker
2009-04-23 21:25 ` Anthony Green
2009-04-23 23:41 ` Anthony Green
2009-04-24 0:01 ` Joel Brobecker
2009-04-24 1:02 ` Anthony Green
2009-04-24 2:27 ` Anthony Green
2009-04-24 3:28 ` Joel Brobecker [this message]
2009-05-01 3:20 ` Anthony Green
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=20090424032759.GM7552@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=green@moxielogic.com \
/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