Blame SOURCES/0019-x86_64-Correct-the-identifier-when-locating-the-call.patch

acf3ec
From 93cd670426aaf4951bceb8f24f0ce63c24e16f5d Mon Sep 17 00:00:00 2001
acf3ec
From: Tao Liu <ltao@redhat.com>
acf3ec
Date: Wed, 16 Nov 2022 20:09:22 +0800
acf3ec
Subject: [PATCH 19/28] x86_64: Correct the identifier when locating the call
acf3ec
 instruction
acf3ec
acf3ec
The previous implementation to locate the call instruction is
acf3ec
to strstr "call", then check whether the previous char is ' '
acf3ec
or '\t'. The implementation is problematic. For example it
acf3ec
cannot resolve the following disassembly string:
acf3ec
acf3ec
"0xffffffffc0995378 <nfs41_callback_svc+344>:\tcall   0xffffffff8ecfa4c0 <schedule>\n"
acf3ec
acf3ec
strstr will locate the "_call" and char check fails,
acf3ec
as a result, extract_hex fails to get the calling address.
acf3ec
acf3ec
NOTE: the issue is more likely to be reproduced when patch[1] applied.
acf3ec
Because without patch[1], the disassembly string will be as follows,
acf3ec
so the issue is no longer reproducible.
acf3ec
acf3ec
"0xffffffffc0995378:\tcall   0xffffffff8ecfa4c0 <schedule>\n"
acf3ec
acf3ec
Before the patch:
acf3ec
    crash> bt 1472
acf3ec
    PID: 1472     TASK: ffff8c121fa72f70  CPU: 18   COMMAND: "nfsv4.1-svc"
acf3ec
     #0 [ffff8c16231a3db8] __schedule at ffffffff8ecf9ef3
acf3ec
     #1 [ffff8c16231a3e40] schedule at ffffffff8ecfa4e9
acf3ec
acf3ec
After the patch:
acf3ec
    crash> bt 1472
acf3ec
    PID: 1472     TASK: ffff8c121fa72f70  CPU: 18   COMMAND: "nfsv4.1-svc"
acf3ec
     #0 [ffff8c16231a3db8] __schedule at ffffffff8ecf9ef3
acf3ec
     #1 [ffff8c16231a3e40] schedule at ffffffff8ecfa4e9
acf3ec
     #2 [ffff8c16231a3e50] nfs41_callback_svc at ffffffffc099537d [nfsv4]
acf3ec
     #3 [ffff8c16231a3ec8] kthread at ffffffff8e6b966f
acf3ec
     #4 [ffff8c16231a3f50] ret_from_fork at ffffffff8ed07898
acf3ec
acf3ec
This patch fix the issue by strstr "\tcall" and " call", to
acf3ec
locate the correct call instruction.
acf3ec
acf3ec
[1]: https://listman.redhat.com/archives/crash-utility/2022-August/010085.html
acf3ec
acf3ec
Signed-off-by: Tao Liu <ltao@redhat.com>
acf3ec
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
acf3ec
---
acf3ec
 x86_64.c | 3 +--
acf3ec
 1 file changed, 1 insertion(+), 2 deletions(-)
acf3ec
acf3ec
diff --git a/x86_64.c b/x86_64.c
acf3ec
index b2a536e4b19c..292c240e887e 100644
acf3ec
--- a/x86_64.c
acf3ec
+++ b/x86_64.c
acf3ec
@@ -4429,8 +4429,7 @@ x86_64_function_called_by(ulong rip)
acf3ec
 	if (gdb_pass_through(buf, pc->tmpfile2, GNU_RETURN_ON_ERROR)) {
acf3ec
 	        rewind(pc->tmpfile2);
acf3ec
 	        while (fgets(buf, BUFSIZE, pc->tmpfile2)) {
acf3ec
-			if ((p1 = strstr(buf, "callq")) &&
acf3ec
-			    whitespace(*(p1-1))) { 
acf3ec
+			if ((p1 = strstr(buf, " callq")) || (p1 = strstr(buf, "\tcallq"))) {
acf3ec
 				if (extract_hex(p1, &value, NULLCHAR, TRUE)) 
acf3ec
 					break;
acf3ec
 			}
acf3ec
-- 
acf3ec
2.37.1
acf3ec