File sysklogd-1.4.1-sparc.patch of Package syslogd

--- ksym.c
+++ ksym.c	2001-05-23 18:50:36.000000000 +0000
@@ -130,6 +130,7 @@
 #include <stdlib.h>
 #include <malloc.h>
 #include <sys/utsname.h>
+#include <ctype.h>
 #include "klogd.h"
 #include "ksyms.h"
 #include "module.h"
@@ -809,6 +810,84 @@ extern char * ExpandKadds(line, el)
 	if ( (num_syms == 0) ||
 	     (kp = strstr(line, "[<")) == (char *) 0 )
 	{
+#ifdef __sparc__
+		if (num_syms) {
+			/*
+			 * On SPARC, register dumps do not have the [< >] characters in it.
+			 */
+			static struct sparc_tests {
+				char *str;
+				int len;
+			} tests[] = { { "PC: ", 4 },
+				      { " o7: ", 5 },
+				      { " ret_pc: ", 9 },
+				      { " i7: ", 5 },
+				      { "Caller[", 7 }
+				    };
+			int i, j, ndigits;
+			char *kp2;
+			for (i = 0; i < 5; i++) {
+				kp = strstr(line, tests[i].str);
+				if (!kp) continue;
+				kp2 = kp + tests[i].len;
+				if (!isxdigit(*kp2)) continue;
+				for (ndigits = 1; isxdigit(kp2[ndigits]); ndigits++);
+				if (ndigits != 8 && ndigits != 16) continue;
+				/* On sparc64, all kernel addresses are in first 4GB */
+				if (ndigits == 16) {
+					if (strncmp (kp2, "00000000", 8)) continue;
+					kp2 += 8;
+				}
+				if (!i) {
+					char *kp3;
+					if (ndigits == 16 && kp > line && kp[-1L] != 'T') continue;
+					kp3 = kp2 + 8;
+					if (ndigits == 16) {
+						if (strncmp (kp3, " TNPC: 00000000", 15) || !isxdigit(kp3[15]))
+							continue;
+						kp3 += 15;
+					} else {
+						if (strncmp (kp3, " NPC: ", 6) || !isxdigit(kp3[6]))
+							continue;
+						kp3 += 6;
+					}
+					for (j = 0; isxdigit(kp3[j]); j++);
+					if (j != 8) continue;
+					strncpy(elp, line, kp2 + 8 - line);
+					elp += kp2 + 8 - line;
+					value = strtol(kp2, (char **) 0, 16);
+					if ( (symbol = LookupSymbol(value, &sym)) ) {
+						if (sym.size)
+							elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
+						else
+							elp += sprintf(elp, " (%s)", symbol);
+					}
+					strncpy(elp, kp2 + 8, kp3 - kp2);
+					elp += kp3 - kp2;
+					value = strtol(kp3, (char **) 0, 16);
+					if ( (symbol = LookupSymbol(value, &sym)) ) {
+						if (sym.size)
+							elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
+						else
+							elp += sprintf(elp, " (%s)", symbol);
+					}
+					strcpy(elp, kp3 + 8);
+				} else {
+					strncpy(elp, line, kp2 + 8 - line);
+					elp += kp2 + 8 - line;
+					value = strtol(kp2, (char **) 0, 16);
+					if ( (symbol = LookupSymbol(value, &sym)) ) {
+						if (sym.size)
+							elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
+						else
+							elp += sprintf(elp, " (%s)", symbol);
+					}
+					strcpy(elp, kp2 + 8);
+				}
+				return el;
+			}
+		}
+#endif	
 		strcpy(el, line);
 		return(el);
 	}
openSUSE Build Service is sponsored by