7 debug_(int level, const char *file, int line, const char *fmt, ...) {
11 if (!(options.debug & level)) {
15 vsnprintf(buf, 1024, fmt, args);
18 output_line(NULL, "DEBUG: %s:%d: %s", file, line, buf);
22 * The following section provides a way to print things, like hex dumps,
23 * with out using buffered output. This was written by Steve Munroe of IBM.
30 #include <sys/ptrace.h>
37 unsigned long temp = (unsigned long)i;
39 for (j = 15; j >= 0; j--) {
41 c = (char)((temp & 0x0f) + '0');
43 c = (char)(c + ('a' - '9' - 1));
49 rc = write(1, text, 16);
58 rc = write(1, text, 1);
68 xwritedump(void *ptr, long addr, int len) {
70 long *tprt = (long *)ptr;
73 for (i = 0; i < len; i += 8) {
86 xinfdump(long pid, void *ptr, int len) {
93 wrdcnt = len / sizeof(long) + 1;
94 infwords = malloc(wrdcnt * sizeof(long));
96 perror("ltrace: malloc");
101 addr = ((addr + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
103 for (i = 0; i < wrdcnt; ++i) {
104 infwords[i] = ptrace(PTRACE_PEEKTEXT, pid, addr);
105 addr += sizeof(long);
108 rc = xwritedump(infwords, (long)ptr, len);