Re: Francois Gouget : winedbg: Fix compilation with gcc 2. 95 and non-GNU compilers.
On Wed, 21 Apr 2010, Eric Pouech wrote: Francois Gouget a écrit : There were two problems: * the semi-colon was missing for non-GNUC compilers as you mentioned * gcc 2.95 does not support __attribute__() on function pointers Unfortunately your patch does not fix the second issue. A solution that would not require dbg_vprintf() would be to check the gcc version before trying to use __attribute__(). [...] does the attached patch works better ? (I tried your suggestion starting at gcc 3.0) Yes, that works. It means that we won't get the benefit of printf format checking on gcc 2.95 but that does not matter since pretty much everyone will do these checks already. And your patch is simpler than mine (and more importantly works). -- Francois Gouget fgou...@free.fr http://fgouget.free.fr/ Stolen from an Internet user: f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng !
Re: Francois Gouget : winedbg: Fix compilation with gcc 2. 95 and non-GNU compilers.
Francois Gouget a écrit : There were two problems: * the semi-colon was missing for non-GNUC compilers as you mentioned * gcc 2.95 does not support __attribute__() on function pointers Unfortunately your patch does not fix the second issue. A solution that would not require dbg_vprintf() would be to check the gcc version before trying to use __attribute__(). does the attached patch works better ? (I tried your suggestion starting at gcc 3.0) A+ -- Eric Pouech The problem with designing something completely foolproof is to underestimate the ingenuity of a complete idiot. (Douglas Adams) diff --git a/programs/winedbg/db_disasm64.c b/programs/winedbg/db_disasm64.c index 98f7ef2..7cf1394 100644 --- a/programs/winedbg/db_disasm64.c +++ b/programs/winedbg/db_disasm64.c @@ -32,24 +32,13 @@ #include stdio.h #include debugger.h -#ifndef __GNUC__ -#define __attribute__(X) +#if defined(__GNUC__) (GCC_VERSION = 3) +static int (*db_printf)(const char* format, ...) __attribute__((format (printf,1,2))); +#else +static int (*db_printf)(const char* format, ...); #endif -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; -} +static int no_printf(const char* format, ...) {return 0;} typedef DWORD_PTR db_addr_t; typedef BOOL boolean_t; @@ -93,7 +82,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_debug) +if (db_printf != no_printf) { ADDRESS64 a; @@ -1656,6 +1645,6 @@ db_disasm(db_addr_t loc, boolean_t altfmt) void be_x86_64_disasm_one_insn(ADDRESS64 *addr, int display) { -db_debug = display; +db_printf = display ? dbg_printf : no_printf; addr-Offset = db_disasm(addr-Offset, TRUE); }
Re: Francois Gouget : winedbg: Fix compilation with gcc 2. 95 and non-GNU compilers.
Alexandre Julliard a écrit : Module: wine Branch: master Commit: 51dfd9adb11885daec878737f18f89fb05c1516c URL: http://source.winehq.org/git/wine.git/?a=commit;h=51dfd9adb11885daec878737f18f89fb05c1516c Author: Francois Gouget fgou...@free.fr Date: Sat Mar 27 16:55:27 2010 +0100 winedbg: Fix compilation with gcc 2.95 and non-GNU compilers. François, what was the exact issue here ? I guess that the ; at the end of the attribute definition for GNUCC compiler was missing for the non gnu C compilers ? your fix is wrong as dbg_printf doesn't take a va_list as argument (you'd want dbg_vprintf which doesn't exist) does the attached patch work in your configuration ? A+ -- Eric Pouech The problem with designing something completely foolproof is to underestimate the ingenuity of a complete idiot. (Douglas Adams) diff --git a/programs/winedbg/db_disasm64.c b/programs/winedbg/db_disasm64.c index 98f7ef2..88fa0dd 100644 --- a/programs/winedbg/db_disasm64.c +++ b/programs/winedbg/db_disasm64.c @@ -32,24 +32,13 @@ #include stdio.h #include debugger.h -#ifndef __GNUC__ -#define __attribute__(X) +#ifdef __GNUC__ +static int (*db_printf)(const char* format, ...) __attribute__((format (printf,1,2))); +#else +static int (*db_printf)(const char* format, ...); #endif -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; -} +static int no_printf(const char* format, ...) {return 0;} typedef DWORD_PTR db_addr_t; typedef BOOL boolean_t; @@ -93,7 +82,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_debug) +if (db_printf != no_printf) { ADDRESS64 a; @@ -1656,6 +1645,6 @@ db_disasm(db_addr_t loc, boolean_t altfmt) void be_x86_64_disasm_one_insn(ADDRESS64 *addr, int display) { -db_debug = display; +db_printf = display ? dbg_printf : no_printf; addr-Offset = db_disasm(addr-Offset, TRUE); }
Re: Francois Gouget : winedbg: Fix compilation with gcc 2. 95 and non-GNU compilers.
On Sat, 17 Apr 2010, Eric Pouech wrote: [...] winedbg: Fix compilation with gcc 2.95 and non-GNU compilers. François, what was the exact issue here ? I guess that the ; at the end of the attribute definition for GNUCC compiler was missing for the non gnu C compilers ? There were two problems: * the semi-colon was missing for non-GNUC compilers as you mentioned * gcc 2.95 does not support __attribute__() on function pointers Unfortunately your patch does not fix the second issue. A solution that would not require dbg_vprintf() would be to check the gcc version before trying to use __attribute__(). -- Francois Gouget fgou...@free.fr http://fgouget.free.fr/ Broadcast message : fin du monde dans cinq minutes, repentez vous !