This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Recognize branch instruction on MIPS in gdb.trace/entry-values.exp
- From: Yao Qi <yao at codesourcery dot com>
- To: "Maciej W. Rozycki" <macro at linux-mips dot org>
- Cc: <gdb-patches at sourceware dot org>
- Date: Thu, 8 Jan 2015 11:47:44 +0800
- Subject: Re: [PATCH] Recognize branch instruction on MIPS in gdb.trace/entry-values.exp
- Authentication-results: sourceware.org; auth=none
- References: <1419840861-10723-1-git-send-email-yao at codesourcery dot com> <alpine dot DEB dot 1 dot 10 dot 1412292255010 dot 19155 at tp dot orcam dot me dot uk> <87zja5uxjk dot fsf at codesourcery dot com> <alpine dot DEB dot 1 dot 10 dot 1412301401280 dot 19155 at tp dot orcam dot me dot uk> <87r3vbuecf dot fsf at codesourcery dot com> <alpine dot LFD dot 2 dot 11 dot 1501072207140 dot 27020 at eddie dot linux-mips dot org> <87oaqat6uj dot fsf at codesourcery dot com> <alpine dot LFD dot 2 dot 11 dot 1501080118280 dot 27020 at eddie dot linux-mips dot org>
"Maciej W. Rozycki" <macro@linux-mips.org> writes:
> Fair enough, the pattern matches more than necessary, but there are no
> MIPS instructions it would match that it shouldn't, so let's keep your
> proposal as it is for simplicity. I have no further concerns, thanks for
> your work and for getting through this review.
Patch below is what I pushed in. Thanks for your review, Maciej.
--
Yao (éå)
Subject: [PATCH] Recognize branch instruction on MIPS in gdb.trace/entry-values.exp
The test entry-values.exp doesn't recognize the call instructions
on MIPS, such as JAL, JALS and etc, so this patch sets call_insn
to match various jump and branch instructions first.
Currently, we assume the next instruction address of call instruction
is the address returned from foo, however it is not correct on MIPS
which has delay slot. We extend variable call_insn to match one
instruction after jump or branch instruction, so that
$returned_from_foo is correct on MIPS.
All tests in entry-values.exp are PASS.
gdb/testsuite:
2015-01-08 Yao Qi <yao@codesourcery.com>
* gdb.trace/entry-values.exp: Set call_insn for MIPS target.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 862f27c..2154036 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-01-08 Yao Qi <yao@codesourcery.com>
+
+ * gdb.trace/entry-values.exp: Set call_insn for MIPS target.
+
2015-01-07 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix testcase compilation.
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp
index e812241..2548e89 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -43,6 +43,20 @@ if { [istarget "arm*-*-*"] || [istarget "aarch64*-*-*"] } {
set call_insn "brasl"
} elseif { [istarget "powerpc*-*-*"] } {
set call_insn "bl"
+} elseif { [istarget "mips*-*-*"] } {
+ # Skip the delay slot after the instruction used to make a call
+ # (which can be a jump or a branch) if it has one.
+ #
+ # JUMP (or BRANCH) foo
+ # insn1
+ # insn2
+ #
+ # Most MIPS instructions used to make calls have a delay slot.
+ # These include JAL, JALS, JALX, JALR, JALRS, BAL and BALS.
+ # In this case the program continues from `insn2' when `foo'
+ # returns. The only exception is JALRC, in which case execution
+ # resumes from `insn1' instead.
+ set call_insn {jalrc|[jb]al[sxr]*[ \t][^\r\n]+\r\n}
} else {
set call_insn "call"
}