From: Simon Marchi <simon.marchi@polymtl.ca>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: Pedro Alves <palves@redhat.com>,
Lionel Flandrin <lionel@svkt.org>,
Simon Marchi <simon.marchi@ericsson.com>,
gdb-patches@sourceware.org
Subject: Re: Check for truncated registers in process_g_packet
Date: Fri, 25 Aug 2017 21:05:00 -0000 [thread overview]
Message-ID: <99a028d3486fedc258429c8c22e4777c@polymtl.ca> (raw)
In-Reply-To: <CAH=s-PM=2E-RHJeqDX=GVibaZP8s5mPmViFjOZnGCfqZ138JFQ@mail.gmail.com>
On 2017-08-25 12:53, Yao Qi wrote:
> This patch 9dc193c causes a regression,
>
> $ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver
> multi-arch-exec.exp"
> FAIL: gdb.multi/multi-arch-exec.exp: continue across exec that changes
> architecture
>
> This test passes on the previous commit. The test
> passes also if I revert this commit on mainline.
From what I can see, the line that causes the problem is
stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
at infrun.c:5321. At this point, the process we are debugging has
exec'ed. It used to be a 64-bits process, it is now a 32-bits process.
However, current_inferior_->gdbarch still points to the 64-bits gdbarch.
It's only the follow_exec call a few lines below that will update it to
the new gdbarch. By reading the PC, we send a g packet. The response
contains the registers of a 32-bits process, but we interpret them as
those of a 64-bits process (because get_remote_arch_state uses
current_inferior_->gdbarch).
If I move the line mentioned above just after the follow_exec call, gdb
interprets the g reply with the right/new gdbarch, so the test case
works. I don't know if it breaks anything else, but so far I didn't
find anything before that point that relied on stop_pc. I sent that
change to the buildbot to check.
So from what I understand, it looks like a pre-existing bug that this
patch uncovered. I think we were interpreting the g reply containing
32-bits registers using the 64-bits register map all along, which that
stop_pc had a bogus value.
To confirm this, I checked out the commit just prior this patch. I see
stop_pc having a value of 0 (it could be anything I guess). If I move
the assignment of stop_pc just after follow_exec, I see a value of
0xf7fd9a20. That value is the mapping address of the dynamic loader in
the process:
f7fd9000-f7ffb000 r-xp 00000000 fc:01 395792
/lib/i386-linux-gnu/ld-2.23.so
plus the entry point in it:
Entry point address: 0xa20
so it makes sense that the process is stopped at this address.
Simon
next prev parent reply other threads:[~2017-08-25 21:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 11:10 Lionel Flandrin
2016-10-18 15:50 ` Simon Marchi
2016-10-18 16:07 ` Lionel Flandrin
2016-10-27 15:23 ` Lionel Flandrin
2016-11-08 10:37 ` Pedro Alves
2017-08-25 10:53 ` Yao Qi
2017-08-25 21:05 ` Simon Marchi [this message]
2017-08-25 22:55 ` Simon Marchi
2017-08-27 10:16 ` [PATCH 0/4] Try to fix the gdb.multi/multi-arch-exec.exp failure Simon Marchi
2017-08-27 10:16 ` [PATCH 3/4] Add thread after updating gdbarch when exec'ing Simon Marchi
2017-09-05 10:37 ` Yao Qi
2017-09-05 15:30 ` Simon Marchi
2017-09-05 15:44 ` Simon Marchi
2017-08-27 10:16 ` [PATCH 2/4] Read stop_pc after updating the " Simon Marchi
2017-09-05 10:12 ` Yao Qi
2017-08-27 10:16 ` [PATCH 4/4] Test different follow-exec-mode settings in gdb.multi/multi-arch-exec.exp Simon Marchi
2017-09-05 10:40 ` Yao Qi
2017-09-05 15:40 ` Simon Marchi
2017-08-27 10:16 ` [PATCH 1/4] Improve "'g' reply is is to long" error message Simon Marchi
2017-09-05 9:49 ` Yao Qi
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=99a028d3486fedc258429c8c22e4777c@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=lionel@svkt.org \
--cc=palves@redhat.com \
--cc=qiyaoltc@gmail.com \
--cc=simon.marchi@ericsson.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