From: Mark Williams <mark@myosotissp.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix assertion fi->level
Date: Sun, 19 Jan 2020 17:27:00 -0000 [thread overview]
Message-ID: <CAN0QdPUhv1maL+0B2B1t0GabB8-aTQ=f+VAu8cVNHwA6GV2c-Q@mail.gmail.com> (raw)
In-Reply-To: <CAN0QdPVcg7_tewDDRXU+1cRJZqQvA4yG7y4i4rZjXbCmpMjXww@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 55 bytes --]
Add a test case, and more detail to the commit message
[-- Attachment #2: 0001-gdb-Fix-Assertion-fi-level-0-failed.patch --]
[-- Type: application/octet-stream, Size: 4548 bytes --]
From ee4c0dafb5495c1492709cc606a0542771315fe2 Mon Sep 17 00:00:00 2001
From: mwilliams <mwilliams@fb.com>
Date: Sun, 19 Jan 2020 09:14:12 -0800
Subject: [PATCH] gdb: Fix "Assertion 'fi->level == 0' failed."
At the point that python unwinders are called to determine if they
want to handle a frame, calling value_of_register_lazy can fail in
the caller of an inlined function, because the inlined function's
frame id has not yet been computed.
However, there's no need to call value_of_register_lazy because the
very next statement is value_fetch_lazy, and the two calls together
are identical to a call to get_frame_register_value, except that the
latter doesn't need a frame id.
An existing test case already stopped in an inlined function and
inspected various frames, so just add a dummy unwinder to it. The
presence of the dummy unwinder should not affect the existing test,
because all it does is tell gdb that it does not want to handle
the current frame. But without this fix, gdb crashes, breaking the
test.
gdb/Changelog
2020-01-19 Mark Williams <mark@myosotissp.com>
PR gdb/22748
* findvar.c call get_frame_register_value instead of
value_of_register_lazy/value_fetch_lazy so it works
without a frame id.
gdb/testsuite/Changelog
2020-01-19 Mark Williams <mark@myosotissp.com>
PR gdb/22748
* gdb.python/py-frame-inline.exp modified to load
the new dummy unwinder to expose the bug
* gdb.python/py-frame-inline.py new file, implementing
a dummy unwinder.
---
gdb/findvar.c | 5 +---
gdb/testsuite/gdb.python/py-frame-inline.exp | 4 ++++
gdb/testsuite/gdb.python/py-frame-inline.py | 24 ++++++++++++++++++++
3 files changed, 29 insertions(+), 4 deletions(-)
create mode 100644 gdb/testsuite/gdb.python/py-frame-inline.py
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 5cf1cd4137..0cddebc12b 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -263,16 +263,13 @@ struct value *
value_of_register (int regnum, struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- struct value *reg_val;
/* User registers lie completely outside of the range of normal
registers. Catch them early so that the target never sees them. */
if (regnum >= gdbarch_num_cooked_regs (gdbarch))
return value_of_user_reg (regnum, frame);
- reg_val = value_of_register_lazy (frame, regnum);
- value_fetch_lazy (reg_val);
- return reg_val;
+ return get_frame_register_value (frame, regnum);
}
/* Return a `value' with the contents of (virtual or cooked) register
diff --git a/gdb/testsuite/gdb.python/py-frame-inline.exp b/gdb/testsuite/gdb.python/py-frame-inline.exp
index 71bffd375d..488346e651 100644
--- a/gdb/testsuite/gdb.python/py-frame-inline.exp
+++ b/gdb/testsuite/gdb.python/py-frame-inline.exp
@@ -24,6 +24,10 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
+set remote_python_file [gdb_remote_download host \
+ ${srcdir}/${subdir}/${testfile}.py]
+gdb_test_no_output "source ${remote_python_file}" "load python file"
+
if ![runto main] then {
fail "can't run to function f"
return 0
diff --git a/gdb/testsuite/gdb.python/py-frame-inline.py b/gdb/testsuite/gdb.python/py-frame-inline.py
new file mode 100644
index 0000000000..56be6d3523
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-frame-inline.py
@@ -0,0 +1,24 @@
+# Copyright (C) 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite.
+from gdb.unwinder import Unwinder, register_unwinder
+class DummyUnwinder(Unwinder):
+ def __init__(self):
+ super(DummyUnwinder, self).__init__('dummy_unwinder')
+ def __call__(self, pending_frame):
+ fp = pending_frame.read_register('pc')
+ return None
+register_unwinder(None, DummyUnwinder())
--
2.17.1
next prev parent reply other threads:[~2020-01-19 17:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-18 23:04 Mark Williams
2020-01-19 17:27 ` Mark Williams [this message]
2020-02-03 3:05 ` Mark Williams
2020-02-07 21:04 ` Tom Tromey
2020-02-07 21:09 ` Mark Williams
2020-02-09 18:57 ` Mark Williams
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='CAN0QdPUhv1maL+0B2B1t0GabB8-aTQ=f+VAu8cVNHwA6GV2c-Q@mail.gmail.com' \
--to=mark@myosotissp.com \
--cc=gdb-patches@sourceware.org \
/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