mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 09:43:38 +00:00
winedump: Use the shared tools functions.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9e3959bd9b
commit
3cdc6d682c
|
@ -41,6 +41,7 @@
|
|||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "../tools.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winedump.h"
|
||||
|
@ -683,7 +684,7 @@ void dump_stabs(const void* pv_stabs, unsigned szstabs, const char* stabstr,
|
|||
* where the stab is continued over multiple lines.
|
||||
*/
|
||||
stabbufflen = 65536;
|
||||
stabbuff = malloc(stabbufflen);
|
||||
stabbuff = xmalloc(stabbufflen);
|
||||
|
||||
stabbuff[0] = '\0';
|
||||
|
||||
|
@ -707,7 +708,7 @@ void dump_stabs(const void* pv_stabs, unsigned szstabs, const char* stabstr,
|
|||
if (strlen(stabbuff) + len > stabbufflen)
|
||||
{
|
||||
stabbufflen += 65536;
|
||||
stabbuff = realloc(stabbuff, stabbufflen);
|
||||
stabbuff = xrealloc(stabbuff, stabbufflen);
|
||||
}
|
||||
strcat(stabbuff, ptr);
|
||||
continue;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "../tools.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winedump.h"
|
||||
|
@ -287,7 +288,7 @@ BOOL dump_analysis(const char *name, file_dumper fn, enum FileSig wanted_sig)
|
|||
if (fstat(fd, &s) < 0) fatal("Can't get size");
|
||||
dump_total_len = s.st_size;
|
||||
|
||||
if (!(dump_base = malloc( dump_total_len ))) fatal( "Out of memory" );
|
||||
dump_base = xmalloc( dump_total_len );
|
||||
if ((unsigned long)read( fd, dump_base, dump_total_len ) != dump_total_len) fatal( "Cannot read file" );
|
||||
|
||||
printf("Contents of %s: %ld bytes\n\n", name, dump_total_len);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include "../tools.h"
|
||||
#include "winedump.h"
|
||||
|
||||
_globals globals; /* All global variables */
|
||||
|
@ -28,15 +29,10 @@ _globals globals; /* All global variables */
|
|||
|
||||
static void do_include (const char *arg)
|
||||
{
|
||||
char *newIncludes;
|
||||
|
||||
if (!globals.directory)
|
||||
globals.directory = strdup(arg);
|
||||
else {
|
||||
newIncludes = str_create (3,globals.directory," ",arg);
|
||||
free(globals.directory);
|
||||
globals.directory = newIncludes;
|
||||
}
|
||||
globals.directory = xstrdup(arg);
|
||||
else
|
||||
globals.directory = strmake( "%s %s", globals.directory, arg );
|
||||
globals.do_code = TRUE;
|
||||
}
|
||||
|
||||
|
@ -47,7 +43,7 @@ static inline const char* strip_ext (const char *str)
|
|||
if (len>4 && strcmp(str+len-4,".dll") == 0)
|
||||
return str_substring (str, str+len-4);
|
||||
else
|
||||
return strdup (str);
|
||||
return xstrdup (str);
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,8 +141,7 @@ static void do_symfile (const char *arg)
|
|||
while (1 == fscanf(f, "%255s", symstring)) /* keep count with [<width>] above */
|
||||
{
|
||||
symstring[sizeof(symstring)-1] = '\0';
|
||||
if (!(symbolp = malloc(sizeof(*symbolp) + strlen(symstring))))
|
||||
fatal ("Out of memory");
|
||||
symbolp = xmalloc(sizeof(*symbolp) + strlen(symstring));
|
||||
strcpy(symbolp->symbolname, symstring);
|
||||
symbolp->found = FALSE;
|
||||
symbolp->next = NULL;
|
||||
|
@ -322,26 +317,11 @@ static void parse_options (char *argv[])
|
|||
|
||||
static void set_module_name(BOOL setUC)
|
||||
{
|
||||
const char* ptr;
|
||||
char* buf;
|
||||
int len;
|
||||
|
||||
/* FIXME: we shouldn't assume all module extensions are .dll in winedump
|
||||
* in some cases, we could have some .drv for example
|
||||
*/
|
||||
/* get module name from name */
|
||||
if ((ptr = strrchr (globals.input_name, '/')))
|
||||
ptr++;
|
||||
else
|
||||
ptr = globals.input_name;
|
||||
len = strlen(ptr);
|
||||
if (len > 4 && strcmp(ptr + len - 4, ".dll") == 0)
|
||||
len -= 4;
|
||||
buf = malloc(len + 1);
|
||||
memcpy(buf, (const void*)ptr, len);
|
||||
buf[len] = 0;
|
||||
globals.input_module = buf;
|
||||
OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( strdup (OUTPUT_DLL_NAME)) : "";
|
||||
globals.input_module = replace_extension( get_basename( globals.input_name ), ".dll", "" );
|
||||
OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( xstrdup (OUTPUT_DLL_NAME)) : "";
|
||||
}
|
||||
|
||||
/* Marks the symbol as 'found'! */
|
||||
|
|
|
@ -21,72 +21,10 @@
|
|||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include "../tools.h"
|
||||
#include "winedump.h"
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* str_create
|
||||
*
|
||||
* Create a single string from many substrings
|
||||
*/
|
||||
char *str_create(size_t num_str, ...)
|
||||
{
|
||||
va_list args;
|
||||
size_t len = 1, i = 0;
|
||||
char *tmp, *t;
|
||||
|
||||
va_start (args, num_str);
|
||||
for (i = 0; i < num_str; i++)
|
||||
if ((t = va_arg(args, char *)))
|
||||
len += strlen (t);
|
||||
va_end (args);
|
||||
|
||||
if (!(tmp = malloc (len)))
|
||||
fatal ("Out of memory");
|
||||
|
||||
tmp[0] = '\0';
|
||||
|
||||
va_start (args, num_str);
|
||||
for (i = 0; i < num_str; i++)
|
||||
if ((t = va_arg(args, char *)))
|
||||
strcat (tmp, t);
|
||||
va_end (args);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* str_create_num
|
||||
*
|
||||
* Create a single string from many substrings, terminating in a number
|
||||
*/
|
||||
char *str_create_num(size_t num_str, int num, ...)
|
||||
{
|
||||
va_list args;
|
||||
size_t len = 8, i = 0;
|
||||
char *tmp, *t;
|
||||
|
||||
va_start (args, num);
|
||||
for (i = 0; i < num_str; i++)
|
||||
if ((t = va_arg(args, char *)))
|
||||
len += strlen (t);
|
||||
va_end (args);
|
||||
|
||||
if (!(tmp = malloc (len)))
|
||||
fatal ("Out of memory");
|
||||
|
||||
tmp[0] = '\0';
|
||||
|
||||
va_start (args, num);
|
||||
for (i = 0; i < num_str; i++)
|
||||
if ((t = va_arg(args, char *)))
|
||||
strcat (tmp, t);
|
||||
va_end (args);
|
||||
sprintf (tmp + len - 8, "%d", num);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* str_substring
|
||||
*
|
||||
|
@ -98,9 +36,7 @@ char *str_substring(const char *start, const char *end)
|
|||
|
||||
assert (start && end && end > start);
|
||||
|
||||
if (!(newstr = malloc (end - start + 1)))
|
||||
fatal ("Out of memory");
|
||||
|
||||
newstr = xmalloc (end - start + 1);
|
||||
memcpy (newstr, start, end - start);
|
||||
newstr [end - start] = '\0';
|
||||
|
||||
|
@ -196,12 +132,10 @@ char *str_toupper (char *str)
|
|||
*/
|
||||
FILE *open_file (const char *name, const char *ext, const char *mode)
|
||||
{
|
||||
char fname[128];
|
||||
char *fname;
|
||||
FILE *fp;
|
||||
|
||||
if (((unsigned)snprintf (fname, sizeof (fname), "%s%s%s",
|
||||
*mode == 'w' ? "./" : "", name, ext) > sizeof (fname)))
|
||||
fatal ("File name too long");
|
||||
fname = strmake( "%s%s%s", *mode == 'w' ? "./" : "", name, ext);
|
||||
|
||||
if (VERBOSE)
|
||||
printf ("Open file %s\n", fname);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "../tools.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winedump.h"
|
||||
|
@ -1364,7 +1365,7 @@ BOOL codeview_dump_symbols(const void* root, unsigned long size)
|
|||
p_string(&sym->thunk_v1.p_name),
|
||||
sym->thunk_v1.segment, sym->thunk_v1.offset,
|
||||
sym->thunk_v1.thunk_len, sym->thunk_v1.thtype);
|
||||
curr_func = strdup(p_string(&sym->thunk_v1.p_name));
|
||||
curr_func = xstrdup(p_string(&sym->thunk_v1.p_name));
|
||||
break;
|
||||
|
||||
case S_THUNK32:
|
||||
|
@ -1372,7 +1373,7 @@ BOOL codeview_dump_symbols(const void* root, unsigned long size)
|
|||
sym->thunk_v3.name,
|
||||
sym->thunk_v3.segment, sym->thunk_v3.offset,
|
||||
sym->thunk_v3.thunk_len, sym->thunk_v3.thtype);
|
||||
curr_func = strdup(sym->thunk_v3.name);
|
||||
curr_func = xstrdup(sym->thunk_v3.name);
|
||||
break;
|
||||
|
||||
/* Global and static functions */
|
||||
|
@ -1391,7 +1392,7 @@ BOOL codeview_dump_symbols(const void* root, unsigned long size)
|
|||
printf(">>> prev func '%s' still has nest_block %u count\n", curr_func, nest_block);
|
||||
nest_block = 0;
|
||||
}
|
||||
curr_func = strdup(p_string(&sym->proc_v1.p_name));
|
||||
curr_func = xstrdup(p_string(&sym->proc_v1.p_name));
|
||||
/* EPP unsigned int pparent; */
|
||||
/* EPP unsigned int pend; */
|
||||
/* EPP unsigned int next; */
|
||||
|
@ -1412,7 +1413,7 @@ BOOL codeview_dump_symbols(const void* root, unsigned long size)
|
|||
printf(">>> prev func '%s' still has nest_block %u count\n", curr_func, nest_block);
|
||||
nest_block = 0;
|
||||
}
|
||||
curr_func = strdup(p_string(&sym->proc_v2.p_name));
|
||||
curr_func = xstrdup(p_string(&sym->proc_v2.p_name));
|
||||
/* EPP unsigned int pparent; */
|
||||
/* EPP unsigned int pend; */
|
||||
/* EPP unsigned int next; */
|
||||
|
@ -1433,7 +1434,7 @@ BOOL codeview_dump_symbols(const void* root, unsigned long size)
|
|||
printf(">>> prev func '%s' still has nest_block %u count\n", curr_func, nest_block);
|
||||
nest_block = 0;
|
||||
}
|
||||
curr_func = strdup(sym->proc_v3.name);
|
||||
curr_func = xstrdup(sym->proc_v3.name);
|
||||
/* EPP unsigned int pparent; */
|
||||
/* EPP unsigned int pend; */
|
||||
/* EPP unsigned int next; */
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include "../tools.h"
|
||||
#include "winedump.h"
|
||||
|
||||
/* Type for parsing mangled types */
|
||||
|
@ -94,73 +95,73 @@ BOOL symbol_demangle (parsed_symbol *sym)
|
|||
/* C++ operator code (one character, or two if the first is '_') */
|
||||
switch (*++name)
|
||||
{
|
||||
case '0': function_name = strdup ("ctor"); break;
|
||||
case '1': function_name = strdup ("dtor"); break;
|
||||
case '2': function_name = strdup ("operator_new"); break;
|
||||
case '3': function_name = strdup ("operator_delete"); break;
|
||||
case '4': function_name = strdup ("operator_equals"); break;
|
||||
case '5': function_name = strdup ("operator_shiftright"); break;
|
||||
case '6': function_name = strdup ("operator_shiftleft"); break;
|
||||
case '7': function_name = strdup ("operator_not"); break;
|
||||
case '8': function_name = strdup ("operator_equalsequals"); break;
|
||||
case '9': function_name = strdup ("operator_notequals"); break;
|
||||
case 'A': function_name = strdup ("operator_array"); break;
|
||||
case 'C': function_name = strdup ("operator_dereference"); break;
|
||||
case 'D': function_name = strdup ("operator_multiply"); break;
|
||||
case 'E': function_name = strdup ("operator_plusplus"); break;
|
||||
case 'F': function_name = strdup ("operator_minusminus"); break;
|
||||
case 'G': function_name = strdup ("operator_minus"); break;
|
||||
case 'H': function_name = strdup ("operator_plus"); break;
|
||||
case 'I': function_name = strdup ("operator_address"); break;
|
||||
case 'J': function_name = strdup ("operator_dereferencememberptr"); break;
|
||||
case 'K': function_name = strdup ("operator_divide"); break;
|
||||
case 'L': function_name = strdup ("operator_modulo"); break;
|
||||
case 'M': function_name = strdup ("operator_lessthan"); break;
|
||||
case 'N': function_name = strdup ("operator_lessthanequal"); break;
|
||||
case 'O': function_name = strdup ("operator_greaterthan"); break;
|
||||
case 'P': function_name = strdup ("operator_greaterthanequal"); break;
|
||||
case 'Q': function_name = strdup ("operator_comma"); break;
|
||||
case 'R': function_name = strdup ("operator_functioncall"); break;
|
||||
case 'S': function_name = strdup ("operator_complement"); break;
|
||||
case 'T': function_name = strdup ("operator_xor"); break;
|
||||
case 'U': function_name = strdup ("operator_logicalor"); break;
|
||||
case 'V': function_name = strdup ("operator_logicaland"); break;
|
||||
case 'W': function_name = strdup ("operator_or"); break;
|
||||
case 'X': function_name = strdup ("operator_multiplyequals"); break;
|
||||
case 'Y': function_name = strdup ("operator_plusequals"); break;
|
||||
case 'Z': function_name = strdup ("operator_minusequals"); break;
|
||||
case '0': function_name = xstrdup ("ctor"); break;
|
||||
case '1': function_name = xstrdup ("dtor"); break;
|
||||
case '2': function_name = xstrdup ("operator_new"); break;
|
||||
case '3': function_name = xstrdup ("operator_delete"); break;
|
||||
case '4': function_name = xstrdup ("operator_equals"); break;
|
||||
case '5': function_name = xstrdup ("operator_shiftright"); break;
|
||||
case '6': function_name = xstrdup ("operator_shiftleft"); break;
|
||||
case '7': function_name = xstrdup ("operator_not"); break;
|
||||
case '8': function_name = xstrdup ("operator_equalsequals"); break;
|
||||
case '9': function_name = xstrdup ("operator_notequals"); break;
|
||||
case 'A': function_name = xstrdup ("operator_array"); break;
|
||||
case 'C': function_name = xstrdup ("operator_dereference"); break;
|
||||
case 'D': function_name = xstrdup ("operator_multiply"); break;
|
||||
case 'E': function_name = xstrdup ("operator_plusplus"); break;
|
||||
case 'F': function_name = xstrdup ("operator_minusminus"); break;
|
||||
case 'G': function_name = xstrdup ("operator_minus"); break;
|
||||
case 'H': function_name = xstrdup ("operator_plus"); break;
|
||||
case 'I': function_name = xstrdup ("operator_address"); break;
|
||||
case 'J': function_name = xstrdup ("operator_dereferencememberptr"); break;
|
||||
case 'K': function_name = xstrdup ("operator_divide"); break;
|
||||
case 'L': function_name = xstrdup ("operator_modulo"); break;
|
||||
case 'M': function_name = xstrdup ("operator_lessthan"); break;
|
||||
case 'N': function_name = xstrdup ("operator_lessthanequal"); break;
|
||||
case 'O': function_name = xstrdup ("operator_greaterthan"); break;
|
||||
case 'P': function_name = xstrdup ("operator_greaterthanequal"); break;
|
||||
case 'Q': function_name = xstrdup ("operator_comma"); break;
|
||||
case 'R': function_name = xstrdup ("operator_functioncall"); break;
|
||||
case 'S': function_name = xstrdup ("operator_complement"); break;
|
||||
case 'T': function_name = xstrdup ("operator_xor"); break;
|
||||
case 'U': function_name = xstrdup ("operator_logicalor"); break;
|
||||
case 'V': function_name = xstrdup ("operator_logicaland"); break;
|
||||
case 'W': function_name = xstrdup ("operator_or"); break;
|
||||
case 'X': function_name = xstrdup ("operator_multiplyequals"); break;
|
||||
case 'Y': function_name = xstrdup ("operator_plusequals"); break;
|
||||
case 'Z': function_name = xstrdup ("operator_minusequals"); break;
|
||||
case '_':
|
||||
switch (*++name)
|
||||
{
|
||||
case '0': function_name = strdup ("operator_divideequals"); break;
|
||||
case '1': function_name = strdup ("operator_moduloequals"); break;
|
||||
case '2': function_name = strdup ("operator_shiftrightequals"); break;
|
||||
case '3': function_name = strdup ("operator_shiftleftequals"); break;
|
||||
case '4': function_name = strdup ("operator_andequals"); break;
|
||||
case '5': function_name = strdup ("operator_orequals"); break;
|
||||
case '6': function_name = strdup ("operator_xorequals"); break;
|
||||
case '7': function_name = strdup ("vftable"); data_flags = DATA_VTABLE; break;
|
||||
case '8': function_name = strdup ("vbtable"); data_flags = DATA_VTABLE; break;
|
||||
case '9': function_name = strdup ("vcall"); data_flags = DATA_VTABLE; break;
|
||||
case 'A': function_name = strdup ("typeof"); data_flags = DATA_VTABLE; break;
|
||||
case 'B': function_name = strdup ("local_static_guard"); data_flags = DATA_VTABLE; break;
|
||||
case 'C': function_name = strdup ("string"); data_flags = DATA_VTABLE; break;
|
||||
case 'D': function_name = strdup ("vbase_dtor"); data_flags = DATA_VTABLE; break;
|
||||
case 'E': function_name = strdup ("vector_dtor"); break;
|
||||
case 'G': function_name = strdup ("scalar_dtor"); break;
|
||||
case 'H': function_name = strdup ("vector_ctor_iter"); break;
|
||||
case 'I': function_name = strdup ("vector_dtor_iter"); break;
|
||||
case 'J': function_name = strdup ("vector_vbase_ctor_iter"); break;
|
||||
case 'L': function_name = strdup ("eh_vector_ctor_iter"); break;
|
||||
case 'M': function_name = strdup ("eh_vector_dtor_iter"); break;
|
||||
case 'N': function_name = strdup ("eh_vector_vbase_ctor_iter"); break;
|
||||
case 'O': function_name = strdup ("copy_ctor_closure"); break;
|
||||
case 'S': function_name = strdup ("local_vftable"); data_flags = DATA_VTABLE; break;
|
||||
case 'T': function_name = strdup ("local_vftable_ctor_closure"); break;
|
||||
case 'U': function_name = strdup ("operator_new_vector"); break;
|
||||
case 'V': function_name = strdup ("operator_delete_vector"); break;
|
||||
case 'X': function_name = strdup ("placement_new_closure"); break;
|
||||
case 'Y': function_name = strdup ("placement_delete_closure"); break;
|
||||
case '0': function_name = xstrdup ("operator_divideequals"); break;
|
||||
case '1': function_name = xstrdup ("operator_moduloequals"); break;
|
||||
case '2': function_name = xstrdup ("operator_shiftrightequals"); break;
|
||||
case '3': function_name = xstrdup ("operator_shiftleftequals"); break;
|
||||
case '4': function_name = xstrdup ("operator_andequals"); break;
|
||||
case '5': function_name = xstrdup ("operator_orequals"); break;
|
||||
case '6': function_name = xstrdup ("operator_xorequals"); break;
|
||||
case '7': function_name = xstrdup ("vftable"); data_flags = DATA_VTABLE; break;
|
||||
case '8': function_name = xstrdup ("vbtable"); data_flags = DATA_VTABLE; break;
|
||||
case '9': function_name = xstrdup ("vcall"); data_flags = DATA_VTABLE; break;
|
||||
case 'A': function_name = xstrdup ("typeof"); data_flags = DATA_VTABLE; break;
|
||||
case 'B': function_name = xstrdup ("local_static_guard"); data_flags = DATA_VTABLE; break;
|
||||
case 'C': function_name = xstrdup ("string"); data_flags = DATA_VTABLE; break;
|
||||
case 'D': function_name = xstrdup ("vbase_dtor"); data_flags = DATA_VTABLE; break;
|
||||
case 'E': function_name = xstrdup ("vector_dtor"); break;
|
||||
case 'G': function_name = xstrdup ("scalar_dtor"); break;
|
||||
case 'H': function_name = xstrdup ("vector_ctor_iter"); break;
|
||||
case 'I': function_name = xstrdup ("vector_dtor_iter"); break;
|
||||
case 'J': function_name = xstrdup ("vector_vbase_ctor_iter"); break;
|
||||
case 'L': function_name = xstrdup ("eh_vector_ctor_iter"); break;
|
||||
case 'M': function_name = xstrdup ("eh_vector_dtor_iter"); break;
|
||||
case 'N': function_name = xstrdup ("eh_vector_vbase_ctor_iter"); break;
|
||||
case 'O': function_name = xstrdup ("copy_ctor_closure"); break;
|
||||
case 'S': function_name = xstrdup ("local_vftable"); data_flags = DATA_VTABLE; break;
|
||||
case 'T': function_name = xstrdup ("local_vftable_ctor_closure"); break;
|
||||
case 'U': function_name = xstrdup ("operator_new_vector"); break;
|
||||
case 'V': function_name = xstrdup ("operator_delete_vector"); break;
|
||||
case 'X': function_name = xstrdup ("placement_new_closure"); break;
|
||||
case 'Y': function_name = xstrdup ("placement_delete_closure"); break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -184,7 +185,7 @@ BOOL symbol_demangle (parsed_symbol *sym)
|
|||
/* Either a class name, or '@' if the symbol is not a class member */
|
||||
if (*name == '@')
|
||||
{
|
||||
class_name = strdup ("global"); /* Non member function (or a datatype) */
|
||||
class_name = xstrdup ("global"); /* Non member function (or a datatype) */
|
||||
name++;
|
||||
}
|
||||
else
|
||||
|
@ -224,9 +225,9 @@ BOOL symbol_demangle (parsed_symbol *sym)
|
|||
}
|
||||
sym->flags |= SYM_DATA;
|
||||
sym->argc = 1;
|
||||
sym->arg_name[0] = str_create (5, OUTPUT_UC_DLL_NAME, "_", class_name,
|
||||
is_static ? "static_" : "_", function_name);
|
||||
sym->arg_text[0] = str_create (3, ct.expression, " ", sym->arg_name[0]);
|
||||
sym->arg_name[0] = strmake( "%s_%s%s_%s", OUTPUT_UC_DLL_NAME, class_name,
|
||||
is_static ? "static" : "", function_name );
|
||||
sym->arg_text[0] = strmake( "%s %s", ct.expression, sym->arg_name[0] );
|
||||
FREE_CT (ct);
|
||||
free (function_name);
|
||||
free (class_name);
|
||||
|
@ -238,9 +239,8 @@ BOOL symbol_demangle (parsed_symbol *sym)
|
|||
{
|
||||
sym->flags |= SYM_DATA;
|
||||
sym->argc = 1;
|
||||
sym->arg_name[0] = str_create (5, OUTPUT_UC_DLL_NAME, "_", class_name,
|
||||
"_", function_name);
|
||||
sym->arg_text[0] = str_create (2, "void *", sym->arg_name[0]);
|
||||
sym->arg_name[0] = strmake( "%s_%s_%s", OUTPUT_UC_DLL_NAME, class_name, function_name );
|
||||
sym->arg_text[0] = strmake( "void *%s", sym->arg_name[0] );
|
||||
|
||||
if (VERBOSE)
|
||||
puts ("Demangled symbol OK [vtable]");
|
||||
|
@ -272,10 +272,10 @@ BOOL symbol_demangle (parsed_symbol *sym)
|
|||
case 'Q' : /* public */
|
||||
case 'R' : /* public */
|
||||
/* Implicit 'this' pointer */
|
||||
sym->arg_text [sym->argc] = str_create (3, "struct ", class_name, " *");
|
||||
sym->arg_text [sym->argc] = strmake( "struct %s *", class_name );
|
||||
sym->arg_type [sym->argc] = ARG_POINTER;
|
||||
sym->arg_flag [sym->argc] = 0;
|
||||
sym->arg_name [sym->argc++] = strdup ("_this");
|
||||
sym->arg_name [sym->argc++] = xstrdup ("_this");
|
||||
/* New struct definitions can be 'grep'ed out for making a fixup header */
|
||||
if (VERBOSE)
|
||||
printf ("struct %s { void **vtable; /*FIXME: class definition */ };\n", class_name);
|
||||
|
@ -348,7 +348,7 @@ BOOL symbol_demangle (parsed_symbol *sym)
|
|||
/* Return type, or @ if 'void' */
|
||||
if (*name == '@')
|
||||
{
|
||||
sym->return_text = strdup ("void");
|
||||
sym->return_text = xstrdup ("void");
|
||||
sym->return_type = ARG_VOID;
|
||||
name++;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ BOOL symbol_demangle (parsed_symbol *sym)
|
|||
ct.expression = NULL;
|
||||
sym->arg_type [sym->argc] = get_type_constant (ct.dest_type, ct.flags);
|
||||
sym->arg_flag [sym->argc] = ct.flags;
|
||||
sym->arg_name[sym->argc] = str_create_num (1, sym->argc, "arg");
|
||||
sym->arg_name[sym->argc] = strmake( "arg%u", sym->argc );
|
||||
sym->argc++;
|
||||
}
|
||||
else
|
||||
|
@ -420,8 +420,8 @@ BOOL symbol_demangle (parsed_symbol *sym)
|
|||
case CT_VOLATILE: const_status = "_volatile"; break;
|
||||
default: const_status = "_"; break;
|
||||
}
|
||||
sym->function_name = str_create_num (4, hash, class_name, "_",
|
||||
function_name, is_static ? "_static" : const_status);
|
||||
sym->function_name = strmake( "%s_%s%s%u", class_name, function_name,
|
||||
is_static ? "_static" : const_status, hash );
|
||||
|
||||
assert (sym->return_text);
|
||||
assert (sym->flags);
|
||||
|
@ -491,7 +491,7 @@ static char *demangle_datatype (char **str, compound_type *ct,
|
|||
|
||||
iter++;
|
||||
/* Apply our constraints to the base type (struct xxx *) */
|
||||
stripped = strdup (sym->arg_text [0]);
|
||||
stripped = xstrdup (sym->arg_text [0]);
|
||||
if (!stripped)
|
||||
fatal ("Out of Memory");
|
||||
|
||||
|
@ -499,8 +499,8 @@ static char *demangle_datatype (char **str, compound_type *ct,
|
|||
if (!(ct->flags & CT_BY_REFERENCE))
|
||||
stripped[ strlen (stripped) - 2] = '\0'; /* otherwise, strip it */
|
||||
|
||||
ct->expression = str_create (2, ct->flags & CT_CONST ? "const " :
|
||||
ct->flags & CT_VOLATILE ? "volatile " : "", stripped);
|
||||
ct->expression = strmake( "%s%s", ct->flags & CT_CONST ? "const " :
|
||||
ct->flags & CT_VOLATILE ? "volatile " : "", stripped);
|
||||
free (stripped);
|
||||
}
|
||||
else if (*iter != '@')
|
||||
|
@ -511,8 +511,8 @@ static char *demangle_datatype (char **str, compound_type *ct,
|
|||
if (*iter++ != '@')
|
||||
return NULL;
|
||||
struct_name = str_substring (struct_name, iter - 2);
|
||||
ct->expression = str_create (4, ct->flags & CT_CONST ? "const " :
|
||||
ct->flags & CT_VOLATILE ? "volatile " : "", "struct ",
|
||||
ct->expression = strmake( "%sstruct %s%s", ct->flags & CT_CONST ? "const " :
|
||||
ct->flags & CT_VOLATILE ? "volatile " : "",
|
||||
struct_name, ct->flags & CT_BY_REFERENCE ? " *" : "");
|
||||
free (struct_name);
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ static char *demangle_datatype (char **str, compound_type *ct,
|
|||
iter += iter[1] == 'A' ? 2 : 3; /* FIXME */
|
||||
if (!demangle_datatype (&iter, &sub_ct, sym))
|
||||
return NULL;
|
||||
ct->expression = str_create(2, sub_ct.expression, " (*)(");
|
||||
ct->expression = strmake( "%s (*)(", sub_ct.expression );
|
||||
if (*iter != '@')
|
||||
{
|
||||
while (*iter != 'Z')
|
||||
|
@ -550,15 +550,15 @@ static char *demangle_datatype (char **str, compound_type *ct,
|
|||
if (!demangle_datatype (&iter, &sub_ct, sym))
|
||||
return NULL;
|
||||
if (sub_expressions)
|
||||
ct->expression = str_create(3, ct->expression, ", ", sub_ct.expression);
|
||||
ct->expression = strmake( "%s, %s", ct->expression, sub_ct.expression );
|
||||
else
|
||||
ct->expression = str_create(2, ct->expression, sub_ct.expression);
|
||||
ct->expression = strmake( "%s%s", ct->expression, sub_ct.expression );
|
||||
while (*iter == '@') iter++;
|
||||
sub_expressions++;
|
||||
}
|
||||
} else while (*iter == '@') iter++;
|
||||
iter++;
|
||||
ct->expression = str_create(2, ct->expression, ")");
|
||||
ct->expression = strmake( "%s)", ct->expression );
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
@ -581,7 +581,7 @@ static char *demangle_datatype (char **str, compound_type *ct,
|
|||
if (sym->argc >= (size_t)('0' - *iter))
|
||||
return NULL;
|
||||
ct->dest_type = sym->arg_type ['0' - *iter];
|
||||
ct->expression = strdup (sym->arg_text ['0' - *iter]);
|
||||
ct->expression = xstrdup (sym->arg_text ['0' - *iter]);
|
||||
iter++;
|
||||
break;
|
||||
default :
|
||||
|
@ -739,16 +739,16 @@ static char *get_type_string (const char c, const int constraints)
|
|||
/* FIXME: T = union */
|
||||
case 'U':
|
||||
case 'V': type_string = "struct"; break;
|
||||
case 'X': return strdup ("void");
|
||||
case 'Z': return strdup ("...");
|
||||
case 'X': return xstrdup ("void");
|
||||
case 'Z': return xstrdup ("...");
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return str_create (3, constraints & CT_CONST ? "const " :
|
||||
constraints & CT_VOLATILE ? "volatile " : "", type_string,
|
||||
constraints & CT_BY_REFERENCE ? " *" : "");
|
||||
return strmake( "%s%s%s", constraints & CT_CONST ? "const " :
|
||||
constraints & CT_VOLATILE ? "volatile " : "", type_string,
|
||||
constraints & CT_BY_REFERENCE ? " *" : "" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -794,8 +794,8 @@ static char *get_pointer_type_string (compound_type *ct,
|
|||
const char *expression)
|
||||
{
|
||||
/* FIXME: set a compound flag for bracketing expression if needed */
|
||||
return str_create (3, ct->flags & CT_CONST ? "const " :
|
||||
ct->flags & CT_VOLATILE ? "volatile " : "", expression,
|
||||
ct->flags & CT_BY_REFERENCE ? " **" : " *");
|
||||
return strmake( "%s%s%s", ct->flags & CT_CONST ? "const " :
|
||||
ct->flags & CT_VOLATILE ? "volatile " : "", expression,
|
||||
ct->flags & CT_BY_REFERENCE ? " **" : " *" );
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../tools.h"
|
||||
#include "windef.h"
|
||||
#include "winedump.h"
|
||||
|
||||
|
@ -368,7 +369,7 @@ static void dump_norm(void)
|
|||
{
|
||||
unsigned int pos, len = (dump_total_len - info->comp_seq * offset_scale) / sizeof(WCHAR);
|
||||
const WCHAR *seq = GET_TABLE( info, comp_seq );
|
||||
unsigned int *map = malloc( len * sizeof(*map) );
|
||||
unsigned int *map = xmalloc( len * sizeof(*map) );
|
||||
|
||||
printf( "\nCompositions:\n\n" );
|
||||
|
||||
|
@ -710,9 +711,7 @@ static void dump_sort( int old_version )
|
|||
|
||||
void nls_dump(void)
|
||||
{
|
||||
const char *name = strrchr( globals.input_name, '/' );
|
||||
if (name) name++;
|
||||
else name = globals.input_name;
|
||||
const char *name = get_basename( globals.input_name );
|
||||
if (!strcasecmp( name, "l_intl.nls" )) return dump_casemap();
|
||||
if (!strncasecmp( name, "c_", 2 )) return dump_codepage();
|
||||
if (!strncasecmp( name, "norm", 4 )) return dump_norm();
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#define NONAMELESSUNION
|
||||
|
||||
#include "../tools.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winedump.h"
|
||||
|
@ -75,7 +76,7 @@ static void* pdb_jg_read(const struct PDB_JG_HEADER* pdb, const WORD* block_list
|
|||
if (!size) return NULL;
|
||||
|
||||
nBlocks = (size + pdb->block_size - 1) / pdb->block_size;
|
||||
buffer = malloc(nBlocks * pdb->block_size);
|
||||
buffer = xmalloc(nBlocks * pdb->block_size);
|
||||
|
||||
for (i = 0; i < nBlocks; i++)
|
||||
memcpy(buffer + i * pdb->block_size,
|
||||
|
@ -861,7 +862,7 @@ static void* pdb_ds_read(const struct PDB_DS_HEADER* header, const DWORD* block_
|
|||
if (!size) return NULL;
|
||||
|
||||
nBlocks = (size + header->block_size - 1) / header->block_size;
|
||||
buffer = malloc(nBlocks * header->block_size);
|
||||
buffer = xmalloc(nBlocks * header->block_size);
|
||||
|
||||
for (i = 0; i < nBlocks; i++)
|
||||
memcpy(buffer + i * header->block_size,
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
#include "../tools.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winedump.h"
|
||||
|
@ -2419,8 +2420,7 @@ static void do_grab_sym( void )
|
|||
|
||||
/* dll_close(); */
|
||||
|
||||
if (!(dll_symbols = malloc((exportDir->NumberOfFunctions + 1) * sizeof(dll_symbol))))
|
||||
fatal ("Out of memory");
|
||||
dll_symbols = xmalloc((exportDir->NumberOfFunctions + 1) * sizeof(dll_symbol));
|
||||
|
||||
/* bit map of used funcs */
|
||||
map = calloc(((exportDir->NumberOfFunctions + 31) & ~31) / 32, sizeof(DWORD));
|
||||
|
@ -2431,7 +2431,7 @@ static void do_grab_sym( void )
|
|||
map[*pOrdl / 32] |= 1 << (*pOrdl % 32);
|
||||
ptr = RVA(*pName++, sizeof(DWORD));
|
||||
if (!ptr) ptr = "cant_get_function";
|
||||
dll_symbols[j].symbol = strdup(ptr);
|
||||
dll_symbols[j].symbol = xstrdup(ptr);
|
||||
dll_symbols[j].ordinal = exportDir->Base + *pOrdl;
|
||||
assert(dll_symbols[j].symbol);
|
||||
}
|
||||
|
@ -2446,7 +2446,7 @@ static void do_grab_sym( void )
|
|||
globals.forward_dll ? globals.forward_dll : OUTPUT_UC_DLL_NAME,
|
||||
exportDir->Base + i);
|
||||
str_toupper(ordinal_text);
|
||||
dll_symbols[j].symbol = strdup(ordinal_text);
|
||||
dll_symbols[j].symbol = xstrdup(ordinal_text);
|
||||
assert(dll_symbols[j].symbol);
|
||||
dll_symbols[j].ordinal = exportDir->Base + i;
|
||||
j++;
|
||||
|
@ -2486,7 +2486,7 @@ BOOL dll_next_symbol (parsed_symbol * sym)
|
|||
if (!dll_current_symbol || !dll_current_symbol->symbol)
|
||||
return FALSE;
|
||||
assert (dll_symbols);
|
||||
sym->symbol = strdup (dll_current_symbol->symbol);
|
||||
sym->symbol = xstrdup (dll_current_symbol->symbol);
|
||||
sym->ordinal = dll_current_symbol->ordinal;
|
||||
dll_current_symbol++;
|
||||
return TRUE;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include "../tools.h"
|
||||
#include "winedump.h"
|
||||
|
||||
static char *grep_buff = NULL;
|
||||
|
@ -50,13 +51,10 @@ BOOL symbol_search (parsed_symbol *sym)
|
|||
return FALSE;
|
||||
|
||||
if (!grep_buff)
|
||||
grep_buff = malloc (MAX_RESULT_LEN);
|
||||
grep_buff = xmalloc (MAX_RESULT_LEN);
|
||||
|
||||
if (!fgrep_buff)
|
||||
fgrep_buff = malloc (MAX_RESULT_LEN);
|
||||
|
||||
if (!grep_buff || !fgrep_buff)
|
||||
fatal ("Out of Memory");
|
||||
fgrep_buff = xmalloc (MAX_RESULT_LEN);
|
||||
|
||||
/* Use 'grep' to tell us which possible files the function is in,
|
||||
* then use 'function_grep.pl' to get the prototype. If this fails the
|
||||
|
@ -66,8 +64,8 @@ BOOL symbol_search (parsed_symbol *sym)
|
|||
while (attempt < 2)
|
||||
{
|
||||
FILE *f_grep;
|
||||
char *cmd = str_create (4, "grep -d recurse -l \"", sym->symbol,
|
||||
!attempt ? "[:blank:]*(\" " : "\" ", globals.directory);
|
||||
char *cmd = strmake( "grep -d recurse -l \"%s%s\" %s", sym->symbol,
|
||||
!attempt ? "[:blank:]*(" : "", globals.directory);
|
||||
|
||||
if (VERBOSE)
|
||||
puts (cmd);
|
||||
|
@ -98,8 +96,7 @@ BOOL symbol_search (parsed_symbol *sym)
|
|||
if (VERBOSE)
|
||||
puts (grep_buff);
|
||||
|
||||
cmd = str_create (5, "function_grep.pl ", sym->symbol,
|
||||
" \"", grep_buff, "\"");
|
||||
cmd = strmake( "function_grep.pl %s \"%s\"", sym->symbol, grep_buff );
|
||||
|
||||
if (VERBOSE)
|
||||
puts (cmd);
|
||||
|
@ -199,7 +196,7 @@ static BOOL symbol_from_prototype (parsed_symbol *sym, const char *proto)
|
|||
else
|
||||
sym->flags = CALLING_CONVENTION;
|
||||
|
||||
sym->function_name = strdup (sym->symbol);
|
||||
sym->function_name = xstrdup (sym->symbol);
|
||||
proto = iter;
|
||||
|
||||
/* Now should be the arguments */
|
||||
|
@ -301,9 +298,7 @@ static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
|
|||
if (iter == base_type || catch_unsigned)
|
||||
{
|
||||
/* 'unsigned' with no type */
|
||||
char *tmp = str_create (2, type_str, " int");
|
||||
free (type_str);
|
||||
type_str = tmp;
|
||||
type_str = strmake( "%s int", type_str );
|
||||
}
|
||||
symbol_clean_string (type_str);
|
||||
|
||||
|
@ -320,7 +315,7 @@ static const char *get_type (parsed_symbol *sym, const char *proto, int arg)
|
|||
sym->arg_flag [arg] = is_const ? CT_CONST : is_volatile ? CT_VOLATILE : 0;
|
||||
|
||||
if (*proto_str == ',' || *proto_str == ')')
|
||||
sym->arg_name [arg] = str_create_num (1, arg, "arg");
|
||||
sym->arg_name [arg] = strmake( "arg%u", arg );
|
||||
else
|
||||
{
|
||||
iter = str_find_set (proto_str, " ,)");
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include "../tools.h"
|
||||
#include "winedump.h"
|
||||
|
||||
|
||||
|
@ -92,7 +93,7 @@ static const char * const known_longs[] =
|
|||
void symbol_init(parsed_symbol* sym, const char* name)
|
||||
{
|
||||
memset(sym, 0, sizeof(parsed_symbol));
|
||||
sym->symbol = strdup(name);
|
||||
sym->symbol = xstrdup(name);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "windef.h"
|
||||
|
||||
#include "../tools.h"
|
||||
#include "winedump.h"
|
||||
|
||||
#define MSFT_MAGIC 0x5446534d
|
||||
|
@ -1190,7 +1189,7 @@ static const char *decode_string(const BYTE *table, const char *stream, DWORD st
|
|||
table_size = *(const DWORD *)table;
|
||||
table += sizeof(DWORD);
|
||||
|
||||
buf = malloc(buf_size);
|
||||
buf = xmalloc(buf_size);
|
||||
buf[0] = 0;
|
||||
|
||||
while ((p = lookup_code(table, table_size, &bits)))
|
||||
|
|
|
@ -198,10 +198,6 @@ void output_prototype (FILE *file, const parsed_symbol *sym);
|
|||
void output_makefile (void);
|
||||
|
||||
/* Misc functions */
|
||||
char *str_create (size_t num_str, ...);
|
||||
|
||||
char *str_create_num (size_t num_str, int num, ...);
|
||||
|
||||
char *str_substring(const char *start, const char *end);
|
||||
|
||||
char *str_replace (char *str, const char *oldstr, const char *newstr);
|
||||
|
|
Loading…
Reference in a new issue