Commit 9f349498af2194915f37f99b67f709ff27458dd2

Authored by Jan Kiszka
Committed by Anthony Liguori
1 parent 0fe6a7f2

slirp: Cleanup and basic reanimation of debug code

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Makefile
... ... @@ -190,7 +190,7 @@ ifdef CONFIG_SLIRP
190 190 CPPFLAGS+=-I$(SRC_PATH)/slirp
191 191 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
192 192 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
193   -tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
  193 +tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
194 194 OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
195 195 endif
196 196  
... ...
slirp/bootp.c
... ... @@ -42,7 +42,7 @@ static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE };
42 42  
43 43 #ifdef DEBUG
44 44 #define dprintf(fmt, ...) \
45   -if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## __VA_ARGS__); fflush(dfd); }
  45 +do if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## __VA_ARGS__); fflush(dfd); } while (0)
46 46 #else
47 47 #define dprintf(fmt, ...)
48 48 #endif
... ...
slirp/debug.c deleted 100644 → 0
1   -/*
2   - * Copyright (c) 1995 Danny Gasparovski.
3   - * Portions copyright (c) 2000 Kelly Price.
4   - *
5   - * Please read the file COPYRIGHT for the
6   - * terms and conditions of the copyright.
7   - */
8   -
9   -#include <slirp.h>
10   -
11   -FILE *dfd = NULL;
12   -int slirp_debug = 0;
slirp/debug.h
... ... @@ -5,25 +5,24 @@
5 5 * terms and conditions of the copyright.
6 6 */
7 7  
8   -#define PRN_STDERR 1
9   -#define PRN_SPRINTF 2
  8 +//#define DEBUG 1
10 9  
11   -extern FILE *dfd;
12   -extern int slirp_debug;
  10 +#ifdef DEBUG
13 11  
14 12 #define DBG_CALL 0x1
15 13 #define DBG_MISC 0x2
16 14 #define DBG_ERROR 0x4
17   -#define DEBUG_DEFAULT DBG_CALL|DBG_MISC|DBG_ERROR
18 15  
19   -#ifdef DEBUG
  16 +#define dfd stderr
  17 +
  18 +extern int slirp_debug;
  19 +
20 20 #define DEBUG_CALL(x) if (slirp_debug & DBG_CALL) { fprintf(dfd, "%s...\n", x); fflush(dfd); }
21 21 #define DEBUG_ARG(x, y) if (slirp_debug & DBG_CALL) { fputc(' ', dfd); fprintf(dfd, x, y); fputc('\n', dfd); fflush(dfd); }
22 22 #define DEBUG_ARGS(x) if (slirp_debug & DBG_CALL) { fprintf x ; fflush(dfd); }
23 23 #define DEBUG_MISC(x) if (slirp_debug & DBG_MISC) { fprintf x ; fflush(dfd); }
24 24 #define DEBUG_ERROR(x) if (slirp_debug & DBG_ERROR) {fprintf x ; fflush(dfd); }
25 25  
26   -
27 26 #else
28 27  
29 28 #define DEBUG_CALL(x)
... ... @@ -33,5 +32,3 @@ extern int slirp_debug;
33 32 #define DEBUG_ERROR(x)
34 33  
35 34 #endif
36   -
37   -void debug_init _P((char *, int));
... ...
slirp/misc.c
... ... @@ -10,6 +10,10 @@
10 10  
11 11 #include "monitor.h"
12 12  
  13 +#ifdef DEBUG
  14 +int slirp_debug = DBG_CALL|DBG_MISC|DBG_ERROR;
  15 +#endif
  16 +
13 17 u_int curtime, time_fasttimo, last_slowtimo;
14 18  
15 19 /*
... ...
slirp/slirp.h
1 1 #ifndef __COMMON_H__
2 2 #define __COMMON_H__
3 3  
4   -//#define DEBUG 1
5   -
6 4 #include "config-host.h"
7 5 #include "slirp_config.h"
8 6  
... ...
slirp/socket.c
... ... @@ -584,7 +584,8 @@ tcp_listen(u_int32_t haddr, u_int hport, u_int32_t laddr, u_int lport, int flags
584 584 socklen_t addrlen = sizeof(addr);
585 585  
586 586 DEBUG_CALL("tcp_listen");
587   - DEBUG_ARG("port = %d", port);
  587 + DEBUG_ARG("haddr = %x", haddr);
  588 + DEBUG_ARG("hport = %d", hport);
588 589 DEBUG_ARG("laddr = %x", laddr);
589 590 DEBUG_ARG("lport = %d", lport);
590 591 DEBUG_ARG("flags = %x", flags);
... ...