mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 11:43:31 +00:00
New -S: Search only prototype names found in 'symfile'.
This commit is contained in:
parent
2ca7000dc8
commit
a58134aede
2 changed files with 85 additions and 2 deletions
|
@ -124,6 +124,30 @@ static void do_end (const char *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void do_symfile (const char *arg)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
char symstring[256]; /* keep count with "%<width>s" below */
|
||||||
|
search_symbol *symbolp,**symbolptail = &globals.search_symbol;
|
||||||
|
|
||||||
|
if (!(f = fopen(arg, "rt")))
|
||||||
|
fatal ("Cannot open <symfile>");
|
||||||
|
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");
|
||||||
|
strcpy(symbolp->symbolname, symstring);
|
||||||
|
symbolp->found = 0;
|
||||||
|
symbolp->next = NULL;
|
||||||
|
*symbolptail = symbolp;
|
||||||
|
symbolptail = &symbolp->next;
|
||||||
|
}
|
||||||
|
if (fclose(f))
|
||||||
|
fatal ("Cannot close <symfile>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void do_verbose (void)
|
static void do_verbose (void)
|
||||||
{
|
{
|
||||||
globals.do_verbose = 1;
|
globals.do_verbose = 1;
|
||||||
|
@ -173,6 +197,7 @@ static const struct option option_table[] = {
|
||||||
{"-C", SPEC, 0, do_cdecl, "-C Assume __cdecl calls (default: __stdcall)"},
|
{"-C", SPEC, 0, do_cdecl, "-C Assume __cdecl calls (default: __stdcall)"},
|
||||||
{"-s", SPEC, 1, do_start, "-s num Start prototype search after symbol 'num'"},
|
{"-s", SPEC, 1, do_start, "-s num Start prototype search after symbol 'num'"},
|
||||||
{"-e", SPEC, 1, do_end, "-e num End prototype search after symbol 'num'"},
|
{"-e", SPEC, 1, do_end, "-e num End prototype search after symbol 'num'"},
|
||||||
|
{"-S", SPEC, 1, do_symfile, "-S symfile Search only prototype names found in 'symfile'"},
|
||||||
{"-q", SPEC, 0, do_quiet, "-q Don't show progress (quiet)."},
|
{"-q", SPEC, 0, do_quiet, "-q Don't show progress (quiet)."},
|
||||||
{"-v", SPEC, 0, do_verbose, "-v Show lots of detail while working (verbose)."},
|
{"-v", SPEC, 0, do_verbose, "-v Show lots of detail while working (verbose)."},
|
||||||
{"dump", DUMP, 0, do_dump, "dump <mod> Dumps the content of the module (dll, exe...) named <mod>"},
|
{"dump", DUMP, 0, do_dump, "dump <mod> Dumps the content of the module (dll, exe...) named <mod>"},
|
||||||
|
@ -290,6 +315,54 @@ static void set_module_name(unsigned setUC)
|
||||||
OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( strdup (OUTPUT_DLL_NAME)) : "";
|
OUTPUT_UC_DLL_NAME = (setUC) ? str_toupper( strdup (OUTPUT_DLL_NAME)) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Marks the symbol as 'found'! */
|
||||||
|
/* return: perform-search */
|
||||||
|
static int symbol_searched(int count, const char *symbolname)
|
||||||
|
{
|
||||||
|
search_symbol *search_symbol;
|
||||||
|
|
||||||
|
if (!(count >= globals.start_ordinal
|
||||||
|
&& (!globals.end_ordinal || count <= globals.end_ordinal)))
|
||||||
|
return 0;
|
||||||
|
if (!globals.search_symbol)
|
||||||
|
return 1;
|
||||||
|
for (search_symbol = globals.search_symbol;
|
||||||
|
search_symbol;
|
||||||
|
search_symbol = search_symbol->next)
|
||||||
|
{
|
||||||
|
if (!strcmp(symbolname, search_symbol->symbolname))
|
||||||
|
{
|
||||||
|
search_symbol->found = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return: some symbols weren't found */
|
||||||
|
static int symbol_finish(void)
|
||||||
|
{
|
||||||
|
const search_symbol *search_symbol;
|
||||||
|
int started = 0;
|
||||||
|
|
||||||
|
for (search_symbol = globals.search_symbol;
|
||||||
|
search_symbol;
|
||||||
|
search_symbol = search_symbol->next)
|
||||||
|
{
|
||||||
|
if (search_symbol->found)
|
||||||
|
continue;
|
||||||
|
if (!started)
|
||||||
|
{
|
||||||
|
/* stderr? not a practice here */
|
||||||
|
puts("These requested <symfile> symbols weren't found:");
|
||||||
|
started = 1;
|
||||||
|
}
|
||||||
|
printf("\t%s\n",search_symbol->symbolname);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return started;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* main
|
* main
|
||||||
*/
|
*/
|
||||||
|
@ -344,8 +417,7 @@ int main (int argc, char *argv[])
|
||||||
printf ("Export %3d - '%s' ...%c", count, symbol.symbol,
|
printf ("Export %3d - '%s' ...%c", count, symbol.symbol,
|
||||||
VERBOSE ? '\n' : ' ');
|
VERBOSE ? '\n' : ' ');
|
||||||
|
|
||||||
if (globals.do_code && count >= globals.start_ordinal
|
if (globals.do_code && symbol_searched(count, symbol.symbol))
|
||||||
&& (!globals.end_ordinal || count <= globals.end_ordinal))
|
|
||||||
{
|
{
|
||||||
/* Attempt to get information about the symbol */
|
/* Attempt to get information about the symbol */
|
||||||
int result = symbol_demangle (&symbol);
|
int result = symbol_demangle (&symbol);
|
||||||
|
@ -375,6 +447,8 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
if (VERBOSE)
|
if (VERBOSE)
|
||||||
puts ("Finished, Cleaning up...");
|
puts ("Finished, Cleaning up...");
|
||||||
|
if (symbol_finish())
|
||||||
|
return 1;
|
||||||
break;
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
do_usage();
|
do_usage();
|
||||||
|
|
|
@ -91,6 +91,14 @@ typedef struct __parsed_symbol
|
||||||
char *arg_name [MAX_FUNCTION_ARGS];
|
char *arg_name [MAX_FUNCTION_ARGS];
|
||||||
} parsed_symbol;
|
} parsed_symbol;
|
||||||
|
|
||||||
|
/* FIXME: Replace with some hash such as GHashTable */
|
||||||
|
typedef struct __search_symbol
|
||||||
|
{
|
||||||
|
struct __search_symbol *next;
|
||||||
|
int found;
|
||||||
|
char symbolname[1]; /* static string, be ANSI C compliant by [1] */
|
||||||
|
} search_symbol;
|
||||||
|
|
||||||
/* All globals */
|
/* All globals */
|
||||||
typedef struct __globals
|
typedef struct __globals
|
||||||
{
|
{
|
||||||
|
@ -117,6 +125,7 @@ typedef struct __globals
|
||||||
/* Option arguments: spec mode */
|
/* Option arguments: spec mode */
|
||||||
int start_ordinal; /* -s */
|
int start_ordinal; /* -s */
|
||||||
int end_ordinal; /* -e */
|
int end_ordinal; /* -e */
|
||||||
|
search_symbol *search_symbol; /* -S */
|
||||||
const char *directory; /* -I */
|
const char *directory; /* -I */
|
||||||
const char *forward_dll; /* -f */
|
const char *forward_dll; /* -f */
|
||||||
const char *dll_name; /* -o */
|
const char *dll_name; /* -o */
|
||||||
|
|
Loading…
Reference in a new issue