]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: allow OutputDebugString to be sent to debugger
authorAlex Brainman <alex.brainman@gmail.com>
Fri, 19 Sep 2014 01:38:48 +0000 (11:38 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Fri, 19 Sep 2014 01:38:48 +0000 (11:38 +1000)
We mark DBG_PRINTEXCEPTION_C messages in VEH handler
as handled, thus preventing debugger from seeing them.
I don't see reason for doing that. The comment warns
of crashes, but I added test and don't see any crashes.

This is also simplify VEH handler before making
changes to fix issue 8006.

Update #8006

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/146800043

src/runtime/os_windows_386.c
src/runtime/os_windows_amd64.c
src/runtime/syscall_windows_test.go

index 028b09bbc885821a21c3bd7d9db3501f8cb6769c..e2ae8db277c55b0a72e57e49c64ee4f21cc808cf 100644 (file)
@@ -24,8 +24,6 @@ runtime·dumpregs(Context *r)
        runtime·printf("gs      %x\n", r->SegGs);
 }
 
-#define DBG_PRINTEXCEPTION_C 0x40010006
-
 // Called by sigtramp from Windows VEH handler.
 // Return value signals whether the exception has been handled (-1)
 // or should be made available to other handlers in the chain (0).
@@ -36,19 +34,6 @@ runtime·sighandler(ExceptionRecord *info, Context *r, G *gp)
        uintptr *sp;
        extern byte runtime·text[], runtime·etext[];
 
-       if(info->ExceptionCode == DBG_PRINTEXCEPTION_C) {
-               // This exception is intended to be caught by debuggers.
-               // There is a not-very-informational message like
-               // "Invalid parameter passed to C runtime function"
-               // sitting at info->ExceptionInformation[0] (a wchar_t*),
-               // with length info->ExceptionInformation[1].
-               // The default behavior is to ignore this exception,
-               // but somehow returning 0 here (meaning keep going)
-               // makes the program crash instead. Maybe Windows has no
-               // other handler registered? In any event, ignore it.
-               return -1;
-       }
-
        // Only handle exception if executing instructions in Go binary
        // (not Windows library code). 
        if(r->Eip < (uint32)runtime·text || (uint32)runtime·etext < r->Eip)
index d7b45c5b1d11bb8d34c172c608d837f144e02b85..261880d450115adfde677aceafda87b21be72472 100644 (file)
@@ -32,8 +32,6 @@ runtime·dumpregs(Context *r)
        runtime·printf("gs      %X\n", (uint64)r->SegGs);
 }
 
-#define DBG_PRINTEXCEPTION_C 0x40010006
-
 // Called by sigtramp from Windows VEH handler.
 // Return value signals whether the exception has been handled (-1)
 // or should be made available to other handlers in the chain (0).
@@ -44,19 +42,6 @@ runtime·sighandler(ExceptionRecord *info, Context *r, G *gp)
        uintptr *sp;
        extern byte runtime·text[], runtime·etext[];
 
-       if(info->ExceptionCode == DBG_PRINTEXCEPTION_C) {
-               // This exception is intended to be caught by debuggers.
-               // There is a not-very-informational message like
-               // "Invalid parameter passed to C runtime function"
-               // sitting at info->ExceptionInformation[0] (a wchar_t*),
-               // with length info->ExceptionInformation[1].
-               // The default behavior is to ignore this exception,
-               // but somehow returning 0 here (meaning keep going)
-               // makes the program crash instead. Maybe Windows has no
-               // other handler registered? In any event, ignore it.
-               return -1;
-       }
-
        // Only handle exception if executing instructions in Go binary
        // (not Windows library code). 
        if(r->Rip < (uint64)runtime·text || (uint64)runtime·etext < r->Rip)
index a828512188a89e0c15e73152d0a983ed267261a6..9ed016ccc8f7f9755e0f18ef86f15641f23f5c1e 100644 (file)
@@ -488,3 +488,9 @@ func TestRegisterClass(t *testing.T) {
                t.Fatalf("UnregisterClass failed: %v", err)
        }
 }
+
+func TestOutputDebugString(t *testing.T) {
+       d := GetDLL(t, "kernel32.dll")
+       p := syscall.StringToUTF16Ptr("testing OutputDebugString")
+       d.Proc("OutputDebugStringW").Call(uintptr(unsafe.Pointer(p)))
+}