diff leo-obj/tool/disasm.c @ 211:71e25510f5af

tiobjd disasm -ll: show the actual line numbers
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sat, 26 Mar 2016 22:03:08 +0000
parents fcf1ef773a57
children
line wrap: on
line diff
--- a/leo-obj/tool/disasm.c	Sat Mar 05 02:51:04 2016 +0000
+++ b/leo-obj/tool/disasm.c	Sat Mar 26 22:03:08 2016 +0000
@@ -181,13 +181,14 @@
 	struct hint *hint = sec->hints;
 	u_char *asciz_end;
 	unsigned asciz_len;
-	unsigned *lineno_arr;
+	struct internal_lineno *lineno_arr;
 	unsigned lineno_cur, lineno_total;
 
 	if (sec->nreloc)
 		get_relocs_of_sec(sec);
 	if (disasm_lineno && sec->nlineent)
-		get_lineno_addrs(sec, &lineno_arr, &lineno_total);
+		get_lineno_array(sec, &lineno_arr, &lineno_total,
+				 disasm_lineno >= 2);
 	else {
 		lineno_arr = 0;
 		lineno_total = 0;
@@ -230,13 +231,20 @@
 			gothint = 0;
 		if (gothint && pos == hint->pos && hint->linebrk)
 			putchar('\n');
-		if (lineno_cur < lineno_total) {
-			if (pos >= lineno_arr[lineno_cur]) {
-				puts("; line");
+		while (lineno_cur < lineno_total) {
+			if (pos >= lineno_arr[lineno_cur].location) {
+				if (disasm_lineno >= 2)
+					printf("; line %u\n",
+						lineno_arr[lineno_cur].lineno);
+				else
+					puts("; line");
 				lineno_cur++;
 			} else {
-				if (lineno_arr[lineno_cur] - pos < headroom)
-					headroom = lineno_arr[lineno_cur] - pos;
+				if (lineno_arr[lineno_cur].location - pos <
+				    headroom)
+					headroom =
+					  lineno_arr[lineno_cur].location - pos;
+				break;
 			}
 		}
 		printf("%8x:\t", pos);