[Crash-utility] Re: crash8.0.4 cannot get source line nums of functions from ko on android15-k6.6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024/03/01 12:21, tianming.wang@xxxxxxxxxx wrote:
> 
> The log was not cut off last time. This is the entire log.
> it seems ".text" exit in the list.

Hmm, it looks no ".text" section to me..  a ".text" section exists like 
this in a vmcore on hand:

crash> mod -s xfs
ffffffffc07a3000 .note.gnu.build-id
ffffffffc07a3024 .note.Linux
ffffffffc0578000 .text               << this one
ffffffffc067bb44 .static_call.text
ffffffffc054a000 .init.text
...

It looks like each function has its own section in your vmcore.  I found 
-ffunction-sections option of gcc, do you use this?  probably the 
current crash does not support this gcc option.

Just an experiment, how does the attached patch work?

Thanks,
Kazu


> crash_latest_fix_k66> mod -d sysdump
> crash_latest_fix_k66> set debug 1
> debug: 1
> crash_latest_fix_k66> mod -s sysdump
> ffffffc07afb8000 __ksymtab
> ffffffc07afb8060 __kcrctab
> ffffffc07afb8080 .altinstructions
> ffffffc07afa8000 __bug_table
> ffffffc07afbc000 __jump_table
> ffffffc07afa8010 .bss
> ffffffc07afa84b8 .data
> ffffffc07afb8248 .rodata
> ffffffc07afa0000 .plt
> ffffffc07afbe000 .init.plt
> ffffffc07afa0a8c .text.ftrace_trampoline
> ffffffc07afc9000 .init.eh_frame
> ffffffc07afba370 .export_symbol
> ffffffc07afa0a98 .text.sysdump_callback_register
> ffffffc07afa0aa8 .text.sysdump_callback_unregiste
> ffffffc07afa0ab8 .text.sprd_debug_check_crash_key
> ffffffc07afa0c04 .text.sprd_vmalloc_or_module_add
> ffffffc07afa0c40 .text.unisoc_virt_to_phys
> ffffffc07afa0d0c .text.minidump_save_extend_infor
> ffffffc07afa1080 .text.minidump_change_extend_inf
> ffffffc07afa11bc .text.crash_note_save_cpu
> ffffffc07afa1494 .text.sysdump_ipi
> ffffffc07afa17cc .text.prepare_minidump_reg_memor
> ffffffc07afa1aec .text.show_minidump_info
> ffffffc07afa21d0 .text.minidump_init
> ffffffc07afa25dc .text.show_exception_info
> ffffffc07afa27dc .text.get_file_line_info
> ffffffc07afa2830 .text.get_exception_stack_info
> ffffffc07afa2af4 .text.prepare_dump_info_for_wdh
> ffffffc07afa2b30 .text.prepare_minidump_info
> ffffffc07afa2bd8 .text.prepare_exception_info
> ffffffc07afa2da0 .text.sysdump_sysctl_exit
> ffffffc07afa2f50 .text.init_module
> ffffffc07afa3f30 .text.rcu_lock_acquire
> ffffffc07afa3f70 .text.rcu_lock_release
> ffffffc07afa3f9c .text.minidump_info_open
> ffffffc07afa3fcc .text.minidump_info_read
> ffffffc07afa4020 .text.ylog_buffer_map
> ffffffc07afa40a8 .text.ylog_buffer_open
> ffffffc07afa40b4 .text.dump_die_cb
> ffffffc07afa4118 .text.sysdump_event
> ffffffc07afa4150 .text.sysdump_connect
> ffffffc07afa420c .text.sysdump_disconnect
> ffffffc07afa4240 .text.sysdump_panic_event
> ffffffc07afa4980 .text.per_cpu_funcs_register
> ffffffc07afa49fc .text.sprd_sysdump_open
> ffffffc07afa4a2c .text.sprd_sysdump_write
> ffffffc07afa4ce8 .text.sprd_sysdump_read
> ffffffc07afb01d0 __dyndbg
> ffffffc07afc0000 .init.data
> ffffffc07afb0ba8 .exit.data
> ffffffc07afa4d24 .text.append_elf_note
> ffffffc07afa4dbc .text.final_note
> ffffffc07afa4dcc .text.update_vmcoreinfo_note
> ffffffc07afa4e24 .text.crash_update_vmcoreinfo_sa
> ffffffc07afa4e70 .text.crash_save_vmcoreinfo
> ffffffc07afa4ef8 .text.vmcoreinfo_append_str
> ffffffc07afa5008 .text.paddr_vmcoreinfo_note
> ffffffc07afa5048 .text.crash_save_vmcoreinfo_init
> ffffffc07afa5594 .text.crash_save_vmcoreinfo_exit
> ffffffc07afa55e0 .text.sysdump_get_kmsg_to_buffer
> ffffffc07afa5680 .text.last_kmsg_init
> ffffffc07afa5b90 .text.last_kmsg_exit
> ffffffc07afa5ca0 .text.kmsg_get_thread
> ffffffc07afa5db0 .text.save_log_to_partition_hand
> ffffffc07afa6040 .text.get_last_kmsg
> ffffffc07afa6120 .text.last_kmsg_handler
> ffffffc07afba3f0 __ksymtab_strings
> ffffffc07afba4c4 .note.Linux
> ffffffc07afb0bc0 .gnu.linkonce.this_module
> ffffffc07afba4f4 .note.gnu.build-id
> ffffffc07afba518 .note.gnu.property
> ffffffc07afc0008 .symtab
> ffffffc07afc4928 .strtab
> /home/tianming.wang/workdir/kernel_6.6/sysdump.ko: add_symbol_file_kallsyms failed
> add-symbol-file /home/tianming.wang/workdir/kernel_6.6/sysdump.ko 0xffffffc07afa0000  -s .data 0xffffffc07afa84b8 -s .bss 0xffffffc07afa8010 -s .rodata 0xffffffc07afb8248
> add symbol table from file "/home/tianming.wang/workdir/kernel_6.6/sysdump.ko" at
>          .text_addr = 0xffffffc07afa0000
>          .data_addr = 0xffffffc07afa84b8
>          .bss_addr = 0xffffffc07afa8010
>          .rodata_addr = 0xffffffc07afb8248
>       MODULE       NAME                           TEXT_BASE         SIZE  OBJECT FILE
> ffffffc07afb0bc0  sysdump                     ffffffc07afa0000   106496  /home/tianming.wang/workdir/kernel_6.6/sysdump.ko
> --
> Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
> https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
> Contribution Guidelines: https://github.com/crash-utility/crash/wiki
diff --git a/defs.h b/defs.h
index 98650e8..9f40045 100644
--- a/defs.h
+++ b/defs.h
@@ -2240,6 +2240,9 @@ struct offset_table {                    /* stash of commonly-used offsets */
 	long mnt_namespace_nr_mounts;
 	long mount_mnt_node;
 	long log_caller_id;
+	long module_sect_attr_battr;
+	long bin_attribute_attr;
+	long attribute_name;
 };
 
 struct size_table {         /* stash of commonly-used sizes */
@@ -2911,8 +2914,9 @@ struct symbol_table_data {
 #define MODSECT_V1      (0x2000)
 #define MODSECT_V2      (0x4000)
 #define MODSECT_V3      (0x8000)
-#define MODSECT_VMASK   (MODSECT_V1|MODSECT_V2|MODSECT_V3)
 #define NO_STRIP       (0x10000)
+#define MODSECT_V4     (0x20000)
+#define MODSECT_VMASK  (MODSECT_V1|MODSECT_V2|MODSECT_V3|MODSECT_V4)
 
 #define NO_LINE_NUMBERS() ((st->flags & GDB_SYMS_PATCHED) && !(kt->flags2 & KASLR))
 
diff --git a/symbols.c b/symbols.c
index cbc9ed1..19f7dd0 100644
--- a/symbols.c
+++ b/symbols.c
@@ -3812,6 +3812,8 @@ dump_symbol_table(void)
                 fprintf(fp, "%sMODSECT_V2", others++ ? "|" : "");
         if (st->flags & MODSECT_V3)
                 fprintf(fp, "%sMODSECT_V3", others++ ? "|" : "");
+        if (st->flags & MODSECT_V4)
+                fprintf(fp, "%sMODSECT_V4", others++ ? "|" : "");
         if (st->flags & MODSECT_UNKNOWN)
                 fprintf(fp, "%sMODSECT_UNKNOWN", others++ ? "|" : "");
         if (st->flags & NO_STRIP)
@@ -10233,6 +10235,7 @@ dump_offset_table(char *spec, ulong makestruct)
         	OFFSET(module_sect_attrs_attrs));
 	fprintf(fp, "   module_sect_attrs_nsections: %ld\n",
         	OFFSET(module_sect_attrs_nsections));
+	fprintf(fp, "        module_sect_attr_battr: %ld\n", OFFSET(module_sect_attr_battr));
 	fprintf(fp, "        module_sect_attr_mattr: %ld\n",
         	OFFSET(module_sect_attr_mattr));
 	fprintf(fp, "         module_sect_attr_name: %ld\n",
@@ -10241,12 +10244,14 @@ dump_offset_table(char *spec, ulong makestruct)
         	OFFSET(module_sect_attr_address));
 	fprintf(fp, "               attribute_owner: %ld\n",
         	OFFSET(attribute_owner));
+	fprintf(fp, "                attribute_name: %ld\n", OFFSET(attribute_name));
 	fprintf(fp, "         module_sect_attr_attr: %ld\n",
         	OFFSET(module_sect_attr_attr));
 	fprintf(fp, "         module_sections_attrs: %ld\n",
         	OFFSET(module_sections_attrs));
 	fprintf(fp, "         module_attribute_attr: %ld\n",
         	OFFSET(module_attribute_attr));
+	fprintf(fp, "            bin_attribute_attr: %ld\n", OFFSET(bin_attribute_attr));
 
         fprintf(fp, "         module_kallsyms_start: %ld\n",
         	OFFSET(module_kallsyms_start));
@@ -13165,7 +13170,14 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
 		MEMBER_OFFSET_INIT(attribute_owner,
 			"attribute", "owner");
 
-		if (VALID_MEMBER(module_sect_attrs_attrs) &&
+		/* Linux 5.8 and later */
+		MEMBER_OFFSET_INIT(module_sect_attr_battr, "module_sect_attr", "battr");
+		MEMBER_OFFSET_INIT(bin_attribute_attr, "bin_attribute", "attr");
+		MEMBER_OFFSET_INIT(attribute_name, "attribute", "name");
+
+		if (VALID_MEMBER(module_sect_attr_battr))
+			st->flags |= MODSECT_V4;
+		else if (VALID_MEMBER(module_sect_attrs_attrs) &&
 		    VALID_MEMBER(module_sect_attr_mattr) &&
 		    VALID_MEMBER(module_attribute_attr) &&
 		    VALID_MEMBER(module_sect_attrs_nsections))
@@ -13185,7 +13197,7 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
 		    (INVALID_MEMBER(attribute_owner) && 
 		     (st->flags & (MODSECT_V1|MODSECT_V2))) ||
 		    INVALID_MEMBER(module_sect_attrs) ||
-		    INVALID_MEMBER(module_sect_attr_name) ||
+		    (INVALID_MEMBER(module_sect_attr_name) && !(st->flags & MODSECT_V4)) ||
 		    INVALID_MEMBER(module_sect_attr_address)) {
 			if (CRASHDEBUG(1)) 
 				error(WARNING, 
@@ -13216,6 +13228,7 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
 		nsections = UNUSED;
 		break;
 	case MODSECT_V3:
+	case MODSECT_V4:
 		array_entry = vaddr + OFFSET(module_sect_attrs_attrs);
 		if (!readmem(vaddr + OFFSET(module_sect_attrs_nsections),
 	    	    KVADDR, &nsections, sizeof(int), 
@@ -13229,7 +13242,10 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
 	if (CRASHDEBUG(2))
 		fprintf(fp, "%s:\n", lm->mod_namelist);
 
-	name_type = MEMBER_TYPE("module_sect_attr", "name");
+	name_type = TYPE_CODE_UNDEF;
+	if (!(st->flags & MODSECT_V4))
+		name_type = MEMBER_TYPE("module_sect_attr", "name");
+
 	req->buf = GETBUF(buflen = 1024);
 	retval = FALSE;
 
@@ -13245,6 +13261,10 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
 			attribute = array_entry + OFFSET(module_sect_attr_mattr) 
 				+ OFFSET(module_attribute_attr);
 			break;
+		case MODSECT_V4:
+			attribute = array_entry + OFFSET(module_sect_attr_battr)
+				+ OFFSET(bin_attribute_attr);
+			break;
 		}
 	
 		if (st->flags & (MODSECT_V1|MODSECT_V2))
@@ -13253,23 +13273,35 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
 			owner = UNUSED;
 
 		address = array_entry + OFFSET(module_sect_attr_address);
-		switch (name_type)
-		{
-		case TYPE_CODE_ARRAY:
-			name = array_entry + OFFSET(module_sect_attr_name);
-			break;
-		case TYPE_CODE_PTR:
-			if (!readmem(array_entry + OFFSET(module_sect_attr_name),
-			    KVADDR, &name, sizeof(void *), 
-		 	    "module_sect_attr.name", RETURN_ON_ERROR|QUIET)) {
+
+		if (st->flags & MODSECT_V4) {
+			if (!readmem(array_entry + OFFSET(module_sect_attr_battr)
+			    + OFFSET(bin_attribute_attr) + OFFSET(attribute_name),
+			    KVADDR, &name, sizeof(void *),
+			    "module_sect_attr.battr.attr.name", RETURN_ON_ERROR|QUIET)) {
 				done = TRUE;
 				retval = FALSE;
 				continue;
 			}
-			break;
-		default:
-			done = TRUE;
-			retval = FALSE;
+		} else {
+			switch (name_type)
+			{
+			case TYPE_CODE_ARRAY:
+				name = array_entry + OFFSET(module_sect_attr_name);
+				break;
+			case TYPE_CODE_PTR:
+				if (!readmem(array_entry + OFFSET(module_sect_attr_name),
+				    KVADDR, &name, sizeof(void *),
+				    "module_sect_attr.name", RETURN_ON_ERROR|QUIET)) {
+					done = TRUE;
+					retval = FALSE;
+					continue;
+				}
+				break;
+			default:
+				done = TRUE;
+				retval = FALSE;
+			}
 		}
 
 		if (CRASHDEBUG(2)) {
@@ -13341,12 +13373,24 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
 	}
 
 	if (retval == FALSE) {
+		sprintf(buf, "add-symbol-file %s 0x%lx %s",
+			lm->mod_namelist, lm->mod_text_start,
+			pc->curcmd_flags & MOD_READNOW ? "-readnow" : "");
+		len = strlen(req->buf);
+		while ((len + strlen(buf)) >= buflen) {
+			RESIZEBUF(req->buf, buflen, buflen * 2);
+			buflen *= 2;
+		}
+		shift_string_right(req->buf, strlen(buf));
+		BCOPY(buf, req->buf, strlen(buf));
+		/*
 		if (CRASHDEBUG(1))
 			fprintf(fp, "%s: add_symbol_file_kallsyms failed\n", 
 				lm->mod_namelist);
 		FREEBUF(req->buf);
 		req->buf = NULL;
 		return FALSE;
+		*/
 	}
 
 	/* 
--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux