[Wine-patches] [eterhack] Revert "kernel32, ntdll: backtrace (etyerbug #1990)"

Dmitry Timoshkov dtimoshkov на etersoft.ru
Пн Сен 17 07:21:28 MSK 2012


This reverts commit 4699f1864dcc9cf096aa137827d1d4018b81e46e.

This hack breaks things in various weird ways, and it's better to keep it
private if this proves to be really useful for somebody else.
---
 dlls/kernel32/except.c   |  40 +---
 dlls/ntdll/signal_i386.c | 511 -----------------------------------------------
 2 files changed, 1 insertion(+), 550 deletions(-)

diff --git a/dlls/kernel32/except.c b/dlls/kernel32/except.c
index 54feebc..7502235 100644
--- a/dlls/kernel32/except.c
+++ b/dlls/kernel32/except.c
@@ -462,44 +462,6 @@ LONG WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
     return EXCEPTION_CONTINUE_SEARCH;
 }
 
-static void EterUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter )
-{
-    /*MIB: check WINESEHBLOCK */
-    if (!getenv("WINESEHBLOCK"))
-    {
-        top_filter = filter; // normal behaviour
-    }
-    else
-    {
-        char c;
-        printf("Call SetUnhandledExceptionFilter."
-               " Current filter - %x, new filter - %x.\n"
-               "[A]llow, [i]gnore(default)?:",
-               (DWORD)top_filter, (DWORD)filter);
-
-        while (1)
-        {
-            switch(c = fgetc(stdin))
-            {
-                case 'A':
-                    c = 'a';
-                case 'a':
-                    top_filter = filter;
-                    printf("Allowed.\n");
-                    break;
-                case '\n': c = 'i';
-                case 'I': c = 'i';
-                case 'i':
-                    printf("Ignored.\n");
-                    break;
-                default:
-                    continue;
-                }
-                fgetc(stdin);
-                break;
-            }
-        }
-}
 
 /***********************************************************************
  *            SetUnhandledExceptionFilter   (KERNEL32.@)
@@ -518,7 +480,7 @@ LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter(
     switch(global_block)
     {
         case GLOBAL_BLOCK_NO:
-            EterUnhandledExceptionFilter(filter);
+            top_filter = filter;
             break;
         case GLOBAL_BLOCK_YES:
             MESSAGE("SetUnhandledExceptionFilter(filter=%p) blocked.\n", filter);
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index a7abad7..4a83a70 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -632,514 +632,6 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *context )
     return STATUS_UNHANDLED_EXCEPTION;
 }
 
-/*
-    table of filters, pointer to memory block:
-        item \n
-        item \n
-        ...  ...
-        item \n
-        item \0
-
-*/
-
-/* filters table */
-char *filters = NULL;
-        //example "code=345 addr=434534\nparameters[0]=223f4\ncode=456";
-const char /* command */
-        *sCode        = "code",
-        *sFlag        = "flags",
-        *sParameters  = "parameters",
-        *sAddr        = "addr";
-
-void show_filters(void)
-{
-    char *pos = filters;
-    if (!pos)
-        printf("NULL");
-    for (;*pos; pos++)
-        switch (*pos)
-        {
-            case '\n': printf("\\n"); break;
-            default: printf("%c", *pos);
-        }
-    printf("\\0\n");
-}
-
-#define MAXTOKEN 32
-
-char *check_arg(EXCEPTION_RECORD *rec, CONTEXT *context, char *pos)
-{
-    char *cur;
-    char key[MAXTOKEN], value[MAXTOKEN], ind[MAXTOKEN];
-    int i;
-    DWORD v;
-
-    /* key */
-    cur = pos;
-    for (i = 0; i < MAXTOKEN; i++, cur++)
-    {
-        if (!*cur)
-        {
-            printf("Invalid `sym-name'.\n");
-            return NULL;
-        }
-
-        if ((*cur == '=') || (*cur == '[')) break;
-
-        if (isalpha(*cur)) key[i] = *cur;
-        else
-        {
-            printf("Invalid `sym-name'.\n");
-            return NULL;
-        }
-    }
-
-    if (i == MAXTOKEN)
-    {
-        printf("Out of range in `sym-name'.\n");
-        return NULL;
-    }
-    key[i] = (char)0;
-
-    /* ind */
-    if (*cur == '[')
-    {
-        cur++;
-        for (i = 0; i < 32; cur++, i++)
-        {
-            if (!*cur)
-            {
-                printf("Invalid `index'.\n");
-                return NULL;
-            }
-            if (*cur == ']')
-            {
-                cur++;
-                break;
-            }
-            if (isdigit(*cur)) ind[i] = *cur;
-            else
-            {
-                printf("Invalid `index'.\n");
-                return NULL;
-            }
-        }
-
-        if (i == MAXTOKEN)
-        {
-            printf("Out of range in `index'.\n");
-            return NULL;
-        }
-        ind[i] = 0;
-    }
-
-    /* value */
-    if (*cur == '=')
-    {
-        cur++;
-        for (i = 0; i < MAXTOKEN; i++, cur++)
-        {
-            if ((!*cur) && (i == 0))
-            {
-                printf("Invalid `value'.\n");
-                return NULL;
-            }
-
-            if ((!*cur) || (*cur == '\n') || (*cur == ' ')) break;
-
-            if (isxdigit(*cur)) value[i] = *cur;
-            else
-            {
-               printf("Invalid `value'.\n");
-                return NULL;
-            }
-        }
-
-        if (i == MAXTOKEN)
-        {
-            printf("Out of range in `value'.\n");
-            return NULL;
-        }
-        value[i] = 0;
-    }
-
-    v = strtoul(value, (char**)NULL, 16);
-
-    if (!strcmp(key, sCode))
-    {
-        if (rec->ExceptionCode == v) return cur;
-        else return NULL;
-    }
-
-    if (!strcmp(key, sFlag))
-    {
-        if (rec->ExceptionFlags == v) return cur;
-        else return NULL;
-    }
-
-    if (!strcmp(key, sParameters))
-    {
-        int idx;
-        idx = atoi(ind);
-
-        if (idx < rec->NumberParameters)
-            if (v == (rec-> ExceptionInformation)[idx]) return cur;
-            else return NULL;
-        else return NULL;
-    }
-
-    if (!strcmp(key, sAddr))
-    {
-        if (((DWORD)(rec->ExceptionAddress)) == v) return cur;
-        else return NULL;
-    }
-
-    printf("Invalid `key' name.\n");
-    return NULL;
-}
-
-char *check_string(EXCEPTION_RECORD *rec, CONTEXT *context, char *pos)
-{
-    char *cur;
-
-    for (cur = pos; (*cur != '\n') && (*cur != '\0');)
-    {
-        char *arg;
-
-        if (*cur == ' ')
-        {
-            cur++;
-            continue;
-        }
-
-        arg = check_arg(rec, context, cur);
-
-        if (!arg)
-        {
-            while(!((*cur == 0) || (*cur == '\n'))) cur++;
-            return  cur;
-        }
-        else cur = arg;
-    }
-    return NULL;
-}
-
-BOOL auto_continue(EXCEPTION_RECORD *rec, CONTEXT *context)
-{
-    char *pos;
-
-    if (!filters) return FALSE;
-
-    for (pos = filters; *pos;)
-    {
-        if (*pos == '\n')
-        {
-            pos++;
-            continue;
-        }
-
-        pos = check_string(rec, context, pos);
-        if (!pos) return TRUE;
-    }
-    return FALSE;
-}
-
-static NTSTATUS eter_raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance )
-{
-    /* check $WINESEHBLOCK: */
-    char *sehBlock, command[2048];
-    int iteratorExceptionInformation;
-
-    sehBlock = getenv("WINESEHBLOCK");
-    if (sehBlock)
-        if (!strcmp(sehBlock, "all"))
-        {
-            int loop;
-            /* exception information output */
-            printf("Handled exception code=%x, flags=%x, addr=%p, parameters[%i]={",
-                   rec->ExceptionCode,
-                   rec->ExceptionFlags,
-                   rec->ExceptionAddress,
-                   rec->NumberParameters);
-
-            for (iteratorExceptionInformation = 0;
-                 iteratorExceptionInformation < rec->NumberParameters;
-                 iteratorExceptionInformation ++ )
-                 printf("%lx%s",
-                        (rec->ExceptionInformation)[iteratorExceptionInformation],
-                        (iteratorExceptionInformation != rec->NumberParameters - 1)?", ": "");
-            printf("}\n");
-
-            loop = !auto_continue(rec, context);
-
-            if (!loop) printf("Skip.\n");
-
-            while (loop)
-            {
-                int i;
-
-                printf("[d]ebugger, [c]ontinue, [e]xit, [h]elp:");
-                if (!fgets(command, 256, stdin))
-                    return STATUS_UNHANDLED_EXCEPTION;
-
-                for (i = 0; i < 256; i++)
-                    if (command[i] == '\n') command[i] = '\x00';
-
-                if (!strcmp("h", command))
-                {
-                    printf("d    Debugger\n"
-                           "c    Continue\n"
-                           "e    Exit\n"
-                           "s    List of skippers\n"
-                           "s+ SkipperString     Add new skipper\n"
-                           "s- Number            Delete skipper by number\n"
-                           "s.   Add new skipper for current handled exception\n"
-                           "s=   Add new skipper for current handled exception with arameters\n");
-                    continue;
-                }
-
-                if (!strcmp("c", command)) break;
-                if (!strcmp("e", command)) exit(1);
-                /* filters */
-
-                if (!strcmp("s", command))
-                {
-                    int i;
-                    char *current, *begin;
-                    if (!filters)
-                    {
-                        printf("Empty list.\n");
-                        continue;
-                    }
-
-                    printf("Actual skippers:\n");
-
-                    for (i = 0, current = begin = filters; *current; current++ )
-                    {
-                        if (current == begin) printf("  (%i)", i++);
-                        if ((*current) == '\n')
-                        {
-                            begin = current;
-                            begin++;
-                            printf("\n");
-                            continue;
-                        }
-                        printf("%c", *current);
-                    }
-                        MESSAGE("\n");
-                        continue;
-                }
-
-                /* add new filter */
-                if ((command[0] == 's') && (command[1] == '+'))
-                {
-                    char *pos, *begin;
-                    int l = 0;
-                    pos = &(command[2]);
-
-                    while (*pos == ' ')pos ++; /* skip spaces from begin */
-                    begin = pos;
-                    while (*pos) pos ++; /* to end */
-                    for (; *pos == ' '; pos --) *pos = (char)0; /* delete spaces from end */
-                    l = strlen(begin);
-
-                    if (filters)
-                    {
-                        int lf = strlen(filters);
-                        char *p;
-
-                        filters = (char *)realloc((void *)filters, lf + l + 2);
-                        p = filters + lf;
-                        *p = '\n';
-
-                        strcpy(++p, begin);
-                    }
-                    else
-                    {
-                        filters = (char *)malloc(l + 1);
-                        strcpy(filters, begin);
-                    }
-                    continue;
-                }
-
-                if ((command[0] == 's') && (command[1] == '='))
-                {
-                    char f[2048];
-
-                    sprintf(f, "code=%x flags=%x addr=%p",
-                            rec->ExceptionCode,
-                            rec->ExceptionFlags,
-                            rec->ExceptionAddress);
-
-                    if (rec->NumberParameters)
-                    {
-                        int i;
-
-                        for (i = 0; i < rec->NumberParameters; i++)
-                        {
-                            char arg[32];
-                            sprintf(arg, " parameters[%i]=%lx", i, (rec->ExceptionInformation)[i]);
-                            strcat(f, arg);
-                        }
-                    }
-
-                    if (filters)
-                    {
-                        int lf = strlen(filters);
-                        char *p;
-                        filters = (char*)realloc((void *)filters, lf + strlen(f) + 2);
-                        p = filters + lf;
-                        *p = '\n';
-                        strcpy(++p, f);
-                    }
-                    else
-                    {
-                        filters = (char *)malloc (strlen(f) + 1);
-                        strcpy(filters, f);
-                    }
-                    continue;
-                }
-
-                if ((command[0] == 's') && (command[1] == '.'))
-                {
-                    char f[128];
-
-                    sprintf(f, "code=%x flags=%x addr=%p",
-                            rec->ExceptionCode,
-                            rec->ExceptionFlags,
-                            rec->ExceptionAddress);
-
-                    if (filters)
-                    {
-                        int lf = strlen(filters);
-                        char *p;
-
-                        filters = (char*)realloc((void *)filters, lf + strlen(f) + 2);
-                        p = filters + lf;
-                        *p = '\n';
-                        strcpy(++p, f);
-                    }
-                    else
-                    {
-                        filters = (char *)malloc(strlen(f) + 1);
-                        strcpy(filters, f);
-                    }
-                    continue;
-                }
-
-                /* delete skipper from table */
-                if ((command[0] == 's') && (command[1]=='-'))
-                {
-                    int filtN = -1, count, i;
-                    char *pos, *begin, *second, *new_filters;
-                    /* if filter list is empty */
-                    if (!filters) continue;
-
-                    /* parse argument */
-                    pos = command + 2;
-                    while (*pos == ' ') pos ++; /* skip spaces from begin */
-                    begin = pos;
-                    while (*pos == ' ') pos ++; /* to end */
-
-                    for (; *pos == ' '; pos --)
-                        *pos = (char)0; /* delete spaces from end */
-                    filtN = atoi(begin); /* convert string to number */
-                    if (filtN < 0)
-                    {
-                        printf("Invalid argument.\n");
-                        continue;
-                    }
-
-                    /* delete skipper */
-                    pos = filters;
-                    count = 0;
-
-                    for(; *pos; pos ++)
-                        if(*pos == '\n') count ++;
-
-                    count ++;
-
-                    if (filtN >= count)
-                    {
-                        printf("Filter not found.\n");
-                        continue;
-                    }
-
-                    if ((filtN == 0) && (count == 1))
-                    {
-                        /* delete all memory block */
-                        free((void *)filters);
-                        filters = NULL;
-                        continue;
-                    }
-
-                    if ((filtN == 0) && (count != 1))
-                    {
-                        /* delete first skipper */
-                        char *new_filters, *begin;
-                        pos = filters;
-
-                        while (*pos != '\n') pos ++; /* to first /n`*/
-                        begin = pos ++;
-
-                        while (*pos) pos ++; /* to end */
-                        new_filters = (char *)malloc((size_t)pos - (size_t)begin + 1);
-                        memcpy((void *)new_filters, (void *)(begin + 1), (size_t)pos - (size_t)begin);
-                        free(filters);
-                        filters = new_filters;
-                        continue;
-                    }
-
-                    if (filtN == count - 1)
-                    {
-                        /* delete last skipper */
-                        int i;
-
-                        for (i = 0, pos = filters; i < filtN; pos ++)
-                            if(*pos == '\n') i++;
-
-                        /* *pos = '\n' */
-                        pos--;
-                        *pos = (char)0;
-                        filters = (char *)realloc((void *)filters, (size_t)(pos + 1) - (size_t) filters);
-                        continue;
-                    }
-
-                    /* delete skipper by number */
-
-                    for (i = 0, pos = filters; i < filtN; pos ++)
-                        if (*pos == '\n') i++;
-                    pos --;
-
-                    /* *pos == '\n' */
-                    second = pos + 1;
-
-                    while (*second != '\n') second ++;
-
-                    /* *second == '\n' */
-                    new_filters = (char *)malloc((size_t)pos - (size_t)filters + strlen(second) + 1);
-                    memcpy((void *)new_filters, (void *)filters, (size_t)pos - (size_t)filters + 1);
-                    strcpy(new_filters + ((size_t)pos - (size_t)filters)+1, second + 1);
-                    free(filters);
-                    filters = new_filters;
-                    continue;
-                }
-
-                if(!strcmp("d", command))
-                {
-                    /* call debugger */
-                    EXCEPTION_POINTERS pointers;
-                    pointers.ExceptionRecord = rec;
-                    pointers.ContextRecord = context;
-                    (*unhandled_exception_filter) (&pointers);
-                    return STATUS_UNHANDLED_EXCEPTION;
-                }
-                printf("Parse command error. Try again...\n");
-            }
-        }
-
-    return STATUS_SUCCESS;
-}
 
 /*******************************************************************
  *		raise_exception
@@ -1189,9 +681,6 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f
         if (call_vectored_handlers( rec, context ) == EXCEPTION_CONTINUE_EXECUTION)
             return STATUS_SUCCESS;
 
-        /* eterbug #1990 */
-        status = eter_raise_exception(rec, context, first_chance);
-
         if ((status = call_stack_handlers( rec, context )) != STATUS_UNHANDLED_EXCEPTION)
             return status;
     }
-- 
1.7.11.6



Подробная информация о списке рассылки Wine-patches