[Crash-utility] [PATCH] Fix gcc_version character display

Youling Tang tangyouling at loongson.cn
Sun Apr 25 05:50:04 UTC 2021


When using the "help -k" command in the 5.12 kernel, it was found that the
gcc_version character string was displayed as 0.0.0.
Check the value of the proc_version string to know,
  crash> help -k
  ...
  proc_version: Linux version 5.12.0-rc2kexec+ (root at bogon) (gcc (GCC) 7.3.1
  20180303 (Red  Hat 7.3.1-6), GNU ld version 2.28-13.fc21.loongson.6) #30
  SMP PREEMPT Thu Apr 22 09:04:57 HKT 2021
  ...

Therefore, the "gcc (GCC)" character should be searched to obtain the correct
character string "gcc_version" value.

Signed-off-by: Youling Tang <tangyouling at loongson.cn>
---
 kernel.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel.c b/kernel.c
index 528f6ee..a1872c2 100644
--- a/kernel.c
+++ b/kernel.c
@@ -1103,9 +1103,13 @@ verify_version(void)
 	/*
 	 *  Keeping the gcc version with #define's is getting out of hand.
 	 */
-	if ((p1 = strstr(kt->proc_version, "gcc version "))) {
+	if ((p1 = strstr(kt->proc_version, "gcc version ")) ||
+	     (p1 = strstr(kt->proc_version, "gcc (GCC) "))) {
 		BZERO(buf, BUFSIZE);
-		p1 += strlen("gcc version ");
+		if (strstr(kt->proc_version, "gcc version "))
+			p1 += strlen("gcc version ");
+		else
+			p1 += strlen("gcc (GCC) ");
 		p2 = buf;
 		while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 == '.')) {
 			if (*p1 == '.')
@@ -3661,7 +3665,7 @@ module_init(void)
 					modules_found = TRUE;
 					break;
 				}
-			} 
+			}
 
 			if (!modules_found) {
                         	error(WARNING,
-- 
2.1.0




More information about the Crash-utility mailing list