Danny Backx wrote:
> 
> I believe Pedro's remark would be adressed by this new implementation,
> but maybe I've not understood his remark completely.
> 

My remark was that cegcc may be used on devices without a screen, or with a
screen turned off.  That's how the GNUWINCE toolchain was(/is?) used by
the Voxware folks.  Better let the app crash and something else restart it,
than having a message box wait for input that will never happen.

Yes, this implementation addresses my concerns.

> If you want to play with this, use regeditce or a similar tool to add
>       HKEY_CURRENT_USER -> cegcc -> debug
> 
> If you create this as a string, with value "dialog", then that's what
> will happen. In all other cases, the original functionality (simple
> printf) is currently preserved.
> 
> As I said I welcome comments.
> 

Comments to the patch below.


>> ------------------------------------------------------------------------
>>
>> Index: startup.c
>> ===================================================================
>> --- startup.c        (revision 915)
>> +++ startup.c        (working copy)
>> @@ -13,6 +13,10 @@
>>  #include "sys/io.h"
>>  #include "sys/fixpath.h"
>>  
>> +/* Forward declaration */
>> +static wchar_t *_get_registry_debugflag(void);
>> +static int _get_registry_debug(void);
>> +

If possible, move the definitions here, and avoid the
forward declarations.

>>  void
>>  _start_process(wchar_t *exe, wchar_t *cmd)
>>  {
>> @@ -36,24 +40,25 @@
>>    DWORD exception;
>>    int signal;
>>    const char* str;
>> +  const wchar_t *wstr;
>>  };
>>  
>>  /* from pocket console */
>>  struct exception_map_t __exception_map[] = 
>>  {
>> -  { STATUS_ACCESS_VIOLATION,         SIGSEGV,  "Access Violation" },
>> -  { STATUS_ILLEGAL_INSTRUCTION,      SIGILL, "Illegal Instruction"},
>> -  { STATUS_PRIVILEGED_INSTRUCTION,   SIGILL, "Privileged Instruction" },
>> +  { STATUS_ACCESS_VIOLATION,         SIGSEGV,  "Access Violation", L"Access 
>> Violation"},
>> +  { STATUS_ILLEGAL_INSTRUCTION,      SIGILL, "Illegal Instruction", 
>> L"Illegal Instruction"},
>> +  { STATUS_PRIVILEGED_INSTRUCTION,   SIGILL, "Privileged Instruction", 
>> L"Privileged Instruction"},
>>    /*      { (unsigned long)STATUS_NONCONTINUABLE_EXCEPTION, NOSIG,   
>> SIG_DIE }, */
>>    /*      { (unsigned long)STATUS_INVALID_DISPOSITION,      NOSIG,   
>> SIG_DIE }, */
>> -  { STATUS_INTEGER_DIVIDE_BY_ZERO,   SIGFPE, "Integer divide by zero" },
>> -  { STATUS_FLOAT_DENORMAL_OPERAND,   SIGFPE, "Float denormal operand" },
>> -  { STATUS_FLOAT_DIVIDE_BY_ZERO,     SIGFPE, "Float divide by zero" },
>> -  { STATUS_FLOAT_INEXACT_RESULT,     SIGFPE, "Float inexact result" },
>> -  { STATUS_FLOAT_INVALID_OPERATION,  SIGFPE, "Float invalid operation" },
>> -  { STATUS_FLOAT_OVERFLOW,           SIGFPE, "Float overflow" },
>> -  { STATUS_FLOAT_STACK_CHECK,        SIGFPE, "Float stack check" },
>> -  { STATUS_FLOAT_UNDERFLOW,          SIGFPE, "Float underflow" },
>> +  { STATUS_INTEGER_DIVIDE_BY_ZERO,   SIGFPE, "Integer divide by zero", 
>> L"Integer divide by zero"},
>> +  { STATUS_FLOAT_DENORMAL_OPERAND,   SIGFPE, "Float denormal operand", 
>> L"Float denormal operand"},
>> +  { STATUS_FLOAT_DIVIDE_BY_ZERO,     SIGFPE, "Float divide by zero", 
>> L"Float divide by zero"},
>> +  { STATUS_FLOAT_INEXACT_RESULT,     SIGFPE, "Float inexact result", 
>> L"Float inexact result"},
>> +  { STATUS_FLOAT_INVALID_OPERATION,  SIGFPE, "Float invalid operation", 
>> L"Float invalid operation"},
>> +  { STATUS_FLOAT_OVERFLOW,           SIGFPE, "Float overflow", L"Float 
>> overflow"},
>> +  { STATUS_FLOAT_STACK_CHECK,        SIGFPE, "Float stack check", L"Float 
>> stack check"},
>> +  { STATUS_FLOAT_UNDERFLOW,          SIGFPE, "Float underflow", L"Float 
>> underflow"},
>>    /*      { (unsigned long)STATUS_INTEGER_DIVIDE_BY_ZERO,   NOSIG }, */
>>    /*      { (unsigned long)STATUS_STACK_OVERFLOW,           NOSIG } */
>>  };


I would ratter one didn't have to type the same string twice.
Either use a macro like:

#define EXCEPTION_MAP_ENTRY(W, U, T) \
{ W, U, T, L ## T }

struct exception_map_t __exception_map[] =
{
- { STATUS_ACCESS_VIOLATION,         SIGSEGV,  "Access Violation" },
+ EXCEPTION_MAP_ENTRY(STATUS_ACCESS_VIOLATION, SIGSEGV, "Access Violation"),

... or, perhaps better, simply use use mbstowcs, or similar...

>> @@ -103,6 +108,9 @@
>>  {
>>    // ### What is this needed for?
>>    static int NestedException=0;
>> +  wchar_t   msg[256];
>> +  int               unhandled = 0;
>> +
>>    if(NestedException)
>>    {
>>      printf("nested exception\n");
>> @@ -117,22 +125,40 @@
>>      DWORD DataAddr;
>>  
>>  #if 0
>> -    printf("Trying to handle EXCEPTION_DATATYPE_MISALIGNMENT Flags:%x 
>> Addr:%x "
>> -      "SP:%x LR:%x R0:%x R1:%x R2:%x R3:%x R4:%x R5:%x R12:%x FP:%x\n", 
>> -      ExceptionRecord->ExceptionFlags,
>> -      ExceptionRecord->ExceptionAddress,
>> -      ContextRecord->Sp,
>> -      ContextRecord->Lr,
>> -      ContextRecord->R0,
>> -      ContextRecord->R1,
>> -      ContextRecord->R2,
>> -      ContextRecord->R3,
>> -      ContextRecord->R4,
>> -      ContextRecord->R5,
>> -      ContextRecord->R12,
>> -      EstablisherFrame
>> -    );
>> +    if (_get_registry_debug()) {
>> +        wsprintf(msg, L"Flags:%x Addr:%x\r\nSP:%x LR:%x R0:%x R1:%x R2:%x 
>> R3:%x\r\n"
>> +                        "R4:%x R5:%x R12:%x FP:%x\n",
>> +                        ExceptionRecord->ExceptionFlags,
>> +                        ExceptionRecord->ExceptionAddress,
>> +                        ContextRecord->Sp,
>> +                        ContextRecord->Lr,
>> +                        ContextRecord->R0,
>> +                        ContextRecord->R1,
>> +                        ContextRecord->R2,
>> +                        ContextRecord->R3,
>> +                        ContextRecord->R4,
>> +                        ContextRecord->R5,
>> +                        ContextRecord->R12,
>> +                        EstablisherFrame);
>> +        MessageBoxW(0, msg, L"Datatype Misalignment Exception", 0);
>> +    } else
>>  #endif
>> +    {
>> +        printf("Trying to handle EXCEPTION_DATATYPE_MISALIGNMENT Flags:%x 
>> Addr:%x "
>> +                        "SP:%x LR:%x R0:%x R1:%x R2:%x R3:%x R4:%x R5:%x 
>> R12:%x FP:%x\n",
>> +                        ExceptionRecord->ExceptionFlags,
>> +                        ExceptionRecord->ExceptionAddress,
>> +                        ContextRecord->Sp,
>> +                        ContextRecord->Lr,
>> +                        ContextRecord->R0,
>> +                        ContextRecord->R1,
>> +                        ContextRecord->R2,
>> +                        ContextRecord->R3,
>> +                        ContextRecord->R4,
>> +                        ContextRecord->R5,
>> +                        ContextRecord->R12,
>> +                        EstablisherFrame);
>> +    }
>>  

... like using 'msg', on the printf version too.  Perhaps you could have
a function that takes care of that?  Like:

static void
excp_printf (const char* buf, ...)
{
    if (use dialog box)
        {
           wchar_t wbuf[];
           mbstowcs (wbuf, buf, ...);
           MessageBoxW (0, wbuf, ...);
        }
     else
        {
           printf (...);
        }
        
}

>> +  MessageBoxW(0, msg, L"WinCE Exception a", 0);

Was this a left over?


You can commit with those changes.

Thanks,

Cheers,
Pedro Alves



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to