From: "Petr Hluzín" <petr.hluzin@gmail.com>
To: gdb@sourceware.org
Cc: Tristan Gingold <gingold@adacore.com>
Subject: a review and questions on avr_scan_prologue()
Date: Sat, 13 Feb 2010 23:56:00 -0000 [thread overview]
Message-ID: <6a6f635a1002131556sc428adfu6033489930eca7b6@mail.gmail.com> (raw)
Hello
I took a look at avr-tdep.c [1] and I found some places which are
either bug or are not clear to me. Here it goes:
else if (len >= sizeof (img) - 2
&& memcmp (img + 2, prologue, sizeof (img) - 2) == 0)
{
info->prologue_type = AVR_PROLOGUE_SIG;
vpc += sizeof (img) - 2;
info->saved_regs[AVR_SREG_REGNUM].addr = 3;
info->saved_regs[0].addr = 2;
info->saved_regs[1].addr = 1;
- info->size += 3;
+ info->size += 2;
}
Since the "img + 2" skips "push r1" I believe the scan should record
smaller size.
if (vpc >= AVR_MAX_PROLOGUE_SIZE)
fprintf_unfiltered (gdb_stderr,
_("Hit end of prologue while scanning pushes\n"));
This condition is never true due to a way `len' is calculated and
`vpc' always being less than `len'. (This is not a bug but per se but
the author might expected something what is not true.)
else if (insn == 0x920f) /* push r0 */
{
info->size += 1;
vpc += 2;
}
The condition is never true because of the preceding "Scan pushes
(saved registers)" loop's exit condition.
Also:
The avr_scan_prologue()'s recognizes several well-known prologues. Is
there a reason why it does not use the general prologue analysis
algorithm as described in the documentation [2]?
I think universal prologue analysis is quite easy with AVR arch. The
code might be shorter (though less clear).
I might try to write the code if you are interested.
(The current prologue scan code chokes on hand-crafted assembly.)
[1] http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/avr-tdep.c?cvsroot=src
[2] http://sources.redhat.com/gdb/current/onlinedocs/gdbint/Algorithms.html
--
Petr Hluzin
next reply other threads:[~2010-02-13 23:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-13 23:56 Petr Hluzín [this message]
2010-02-16 5:13 ` Weddington, Eric
2010-02-17 9:02 ` Tristan Gingold
2010-02-20 23:20 ` Petr Hluzín
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=6a6f635a1002131556sc428adfu6033489930eca7b6@mail.gmail.com \
--to=petr.hluzin@gmail.com \
--cc=gdb@sourceware.org \
--cc=gingold@adacore.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