[Crash-utility] [PATCH v6 7/7] Add mod_symname_hash table dump to help -s

Tao Liu ltao at redhat.com
Sat Oct 16 05:21:17 UTC 2021


Previously, help -s only print out the dump status of symname_hash
table. Since we have mod_symname_hash table introduced, let's print
out mod_symname_hash in help -s as well.

Signed-off-by: Tao Liu <ltao at redhat.com>
---
 symbols.c | 57 ++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 35 insertions(+), 22 deletions(-)

diff --git a/symbols.c b/symbols.c
index 67b7014..3e6655f 100644
--- a/symbols.c
+++ b/symbols.c
@@ -3219,13 +3219,40 @@ kallsyms_module_function_size(struct syment *sp, struct load_module *lm, ulong *
 	return FALSE;
 }
 
+static void
+dump_symname_hash_table(struct syment *table[])
+{
+	int i, cnt, tot;
+	struct syment *sp;
+
+	fprintf(fp, "    ");
+	for (i = tot = 0; i < SYMNAME_HASH; i++) {
+		fprintf(fp, "[%3d]: ", i);
+		if ((sp = table[i]) == NULL) 
+			fprintf(fp, "%3d  ", 0);
+		else {
+			cnt = 1;
+			while (sp->name_hash_next) {
+				cnt++;
+				sp = sp->name_hash_next;
+			}
+			fprintf(fp, "%3d  ", cnt);
+			tot += cnt;
+		}
+		if (i && (((i+1) % 6) == 0))
+			fprintf(fp, "\n    ");
+	}
+	if (SYMNAME_HASH % 6)
+		fprintf(fp, "\n");
+}
+
 /*
  *  "help -s" output
  */
 void
 dump_symbol_table(void)
 {
-	int i, s, cnt, tot;
+	int i, s, cnt;
         struct load_module *lm;
 	struct syment *sp;
 	struct downsized *ds;
@@ -3355,28 +3382,14 @@ dump_symbol_table(void)
 
         fprintf(fp, "   symname_hash[%d]: %lx\n", SYMNAME_HASH,
                 (ulong)&st->symname_hash[0]);
+	if (CRASHDEBUG(1))
+		dump_symname_hash_table(st->symname_hash);
+
+	fprintf(fp, "mod_symname_hash[%d]: %lx\n", SYMNAME_HASH,
+		(ulong)&st->mod_symname_hash[0]);
+	if (CRASHDEBUG(1))
+		dump_symname_hash_table(st->mod_symname_hash);
 
-	if (CRASHDEBUG(1)) {
-		fprintf(fp, "    ");
-	        for (i = tot = 0; i < SYMNAME_HASH; i++) {
-	                fprintf(fp, "[%3d]: ", i);
-	                if ((sp = st->symname_hash[i]) == NULL) 
-	                        fprintf(fp, "%3d  ", 0);
-	                else {
-		                cnt = 1;
-		                while (sp->name_hash_next) {
-		                        cnt++;
-		                        sp = sp->name_hash_next;
-		                }
-		                fprintf(fp, "%3d  ", cnt);
-				tot += cnt;
-			}
-			if (i && (((i+1) % 6) == 0))
-				fprintf(fp, "\n    ");
-	        }
-		if (SYMNAME_HASH % 6)
-			fprintf(fp, "\n");
-	}
 	fprintf(fp, "    symbol_namespace: ");
 	fprintf(fp, "address: %lx  ", (ulong)st->kernel_namespace.address);
 	fprintf(fp, "index: %ld  ", st->kernel_namespace.index); 
-- 
2.29.2




More information about the Crash-utility mailing list