winedbg: Fix compilation with gcc 2.95 and non-GNU compilers.

Francois Gouget fgouget at free.fr
Sat Mar 27 10:55:27 CDT 2010


gcc 2.95 does not support attributes on function pointers.
Also the semi-colon was missing in the non-GNU case.
---

gcc 2.95 not supporting attributes on function pointers is kind of 
annoying. Let me know if I should resubmit the patch to just fix the 
non-GNU compiler case.

 programs/winedbg/db_disasm64.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/programs/winedbg/db_disasm64.c b/programs/winedbg/db_disasm64.c
index d7f7c03..98f7ef2 100644
--- a/programs/winedbg/db_disasm64.c
+++ b/programs/winedbg/db_disasm64.c
@@ -32,11 +32,25 @@
 #include <stdio.h>
 #include "debugger.h"
 
-static int	        (*db_printf)(const char* format, ...)
-#ifdef __GNUC__
-                                                              __attribute__((format (printf,1,2)));
+#ifndef __GNUC__
+#define __attribute__(X)
 #endif
-static int	        no_printf(const char* format, ...) {return 0;}
+
+static int db_debug = 0;
+static int db_printf(const char* format, ...) __attribute__((format (printf,1,2)));
+int db_printf(const char* format, ...)
+{
+    va_list valist;
+    int len = 0;
+    if (db_debug)
+    {
+        va_start(valist, format);
+        len = dbg_printf(format, valist);
+        va_end(valist);
+    }
+    return len;
+}
+
 typedef DWORD_PTR db_addr_t;
 typedef BOOL boolean_t;
 
@@ -79,7 +93,7 @@ static ULONG64  db_get_value(db_addr_t addr, int size, int is_signed)
 
 static void db_printsym(db_addr_t addr, unsigned unused)
 {
-    if (db_printf != no_printf)
+    if (db_debug)
     {
         ADDRESS64   a;
 
@@ -1642,6 +1656,6 @@ db_disasm(db_addr_t loc, boolean_t altfmt)
 
 void be_x86_64_disasm_one_insn(ADDRESS64 *addr, int display)
 {
-    db_printf = display ? dbg_printf : no_printf;
+    db_debug = display;
     addr->Offset = db_disasm(addr->Offset, TRUE);
 }
-- 
1.7.0



More information about the wine-patches mailing list