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

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