From: Jack Lange Date: Fri, 21 Aug 2009 05:07:15 +0000 (-0500) Subject: cleanup of debugging functions X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=4f0bb09709fcff0e08aef60c1f0253bbef91f608 cleanup of debugging functions --- diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index 9898066..878966f 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -38,57 +38,34 @@ /* utility definitions */ +#define V3_Print(fmt, args...) \ + do { \ + extern struct v3_os_hooks * os_hooks; \ + if ((os_hooks) && (os_hooks)->print) { \ + (os_hooks)->print((fmt), ##args); \ + } \ + } while (0) + + #define PrintDebug(fmt, args...) \ do { \ extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print_debug) { \ - (os_hooks)->print_debug((fmt), ##args); \ + if ((os_hooks) && (os_hooks)->print) { \ + (os_hooks)->print((fmt), ##args); \ } \ } while (0) -#if 1 -#else -#define PrintDebug(fmt,args ...) -#endif - - #define PrintError(fmt, args...) \ do { \ extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print_debug) { \ - (os_hooks)->print_debug("%s(%d): " fmt, __FILE__, __LINE__, ##args); \ + if ((os_hooks) && (os_hooks)->print) { \ + (os_hooks)->print("%s(%d): " fmt, __FILE__, __LINE__, ##args); \ } \ } while (0) -#ifdef VMM_INFO -#define PrintInfo(fmt, args...) \ - do { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print_info) { \ - (os_hooks)->print_info((fmt), ##args); \ - } \ - } while (0) -#else -#define PrintInfo(fmt, args...) -#endif - - -#ifdef VMM_TRACE -#define PrintTrace(fmt, args...) \ - do { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print_trace) { \ - (os_hooks)->print_trace(fmt, ##args); \ - } \ - } while (0) -#else -#define PrintTrace(fmt, args...) -#endif - - #define V3_AllocPages(num_pages) \ ({ \ extern struct v3_os_hooks * os_hooks; \ @@ -229,11 +206,7 @@ struct guest_info; /* This will contain function pointers that provide OS services */ struct v3_os_hooks { - void (*print_info)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); - void (*print_debug)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); - void (*print_trace)(const char * format, ...) + void (*print)(const char * format, ...) __attribute__ ((format (printf, 1, 2))); void *(*allocate_pages)(int numPages); diff --git a/palacios/include/palacios/vmm_util.h b/palacios/include/palacios/vmm_util.h index 80a36c7..c6111d2 100644 --- a/palacios/include/palacios/vmm_util.h +++ b/palacios/include/palacios/vmm_util.h @@ -36,26 +36,12 @@ typedef union reg_ex { -// These are the GPRs layed out according to 'pusha' -struct VMM_GPRs { - uint_t edi; - uint_t esi; - uint_t ebp; - uint_t esp; - uint_t ebx; - uint_t edx; - uint_t ecx; - uint_t eax; -}; - - #define GET_LOW_32(x) (*((uint_t*)(&(x)))) #define GET_HIGH_32(x) (*((uint_t*)(((uchar_t*)(&(x)))+4))) -void PrintTraceHex(uchar_t x); -void PrintTraceLL(ullong_t num); -void PrintTraceMemDump(uchar_t * start, int n); + +void v3_dump_mem(uint8_t * start, int n); @@ -78,22 +64,6 @@ void PrintTraceMemDump(uchar_t * start, int n); val = tsc; \ } while (0) -/* - #if __V3_32BIT__ - - #define rdtscll(val) \ - __asm__ __volatile__("rdtsc" : "=A" (val)) - - #elif __V3_64BIT__ - - #define rdtscll(val) do { \ - unsigned int a,d; \ - asm volatile("rdtsc" : "=a" (a), "=d" (d)); \ - (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \ - } while(0) - - #endif -*/ diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 4a2d3b9..96ab2cf 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -358,7 +358,7 @@ static int start_svm_guest(struct guest_info *info) { PrintDebug("Host Address of rip = 0x%p\n", (void *)host_addr); PrintDebug("Instr (15 bytes) at %p:\n", (void *)host_addr); - PrintTraceMemDump((uchar_t *)host_addr, 15); + v3_dump_mem((uint8_t *)host_addr, 15); break; } diff --git a/palacios/src/palacios/vmm_socket.c b/palacios/src/palacios/vmm_socket.c index eeb38ae..acf881d 100644 --- a/palacios/src/palacios/vmm_socket.c +++ b/palacios/src/palacios/vmm_socket.c @@ -27,7 +27,6 @@ struct v3_socket_hooks * sock_hooks = 0; void V3_Init_Sockets(struct v3_socket_hooks * hooks) { - PrintInfo("Initializing Socket Interface\n"); sock_hooks = hooks; PrintDebug("V3 sockets inited\n"); diff --git a/palacios/src/palacios/vmm_util.c b/palacios/src/palacios/vmm_util.c index 5d51666..8fecd3c 100644 --- a/palacios/src/palacios/vmm_util.c +++ b/palacios/src/palacios/vmm_util.c @@ -16,51 +16,28 @@ * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "V3VEE_LICENSE". */ - - #include #include -extern struct v3_os_hooks * os_hooks; - - -void PrintTraceHex(unsigned char x) { - unsigned char z; - - z = (x >> 4) & 0xf; - PrintTrace("%x", z); - z = x & 0xf; - PrintTrace("%x", z); -} - -void PrintTraceLL(ullong_t num) { - unsigned char * z = (unsigned char *)# - int i; - - for (i = 7; i >= 0; i--) { - PrintTraceHex(*(z + i)); - } -} - -void PrintTraceMemDump(uchar_t * start, int n) { +void v3_dump_mem(uint8_t * start, int n) { int i, j; for (i = 0; i < n; i += 16) { - PrintTrace("%p", (void *)(start + i)); + V3_Print("%p", (void *)(start + i)); for (j = i; (j < (i + 16)) && (j < n); j += 2) { - PrintTrace(" "); - PrintTraceHex(*(uchar_t *)(start + j)); + V3_Print(" "); + V3_Print("%x", *(uint8_t *)(start + j)); if ((j + 1) < n) { - PrintTraceHex(*((uchar_t *)(start + j + 1))); + V3_Print("%x", *((uint8_t *)(start + j + 1))); } } - PrintTrace(" "); + V3_Print(" "); for (j = i; (j < (i + 16)) && (j < n); j++) { - PrintTrace("%c", ((start[j] >= 32) && (start[j] <= 126)) ? start[j] : '.'); + V3_Print("%c", ((start[j] >= 32) && (start[j] <= 126)) ? start[j] : '.'); } - PrintTrace("\n"); + V3_Print("\n"); } } diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index 14f6bdc..632daab 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -710,7 +710,7 @@ int v3_is_vmx_capable() { if (ecx & CPUID_1_ECX_VTXFLAG) { v3_get_msr(VMX_FEATURE_CONTROL_MSR, &(feature_msr.hi), &(feature_msr.lo)); - PrintTrace("MSRREGlow: 0x%.8x\n", feature_msr.lo); + PrintDebug("MSRREGlow: 0x%.8x\n", feature_msr.lo); if ((feature_msr.lo & FEATURE_CONTROL_VALID) != FEATURE_CONTROL_VALID) { PrintDebug("VMX is locked -- enable in the BIOS\n");