sal/cppunittester/cppunittester.cxx |   41 +++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

New commits:
commit 4f900a536940fce989cd9e3d688a8391e6edf62f
Author:     Noel Grandin <n...@peralex.com>
AuthorDate: Wed Mar 23 11:45:34 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Mar 23 13:18:48 2022 +0100

    try to improve stack dumping on windows
    
    noting that this commit is completely blind. But we're not getting
    good stacks on jenkins, and it doesn't look right to me that we're
    using 64-bit functions on 32-bit stacks, so make the 32-bit paths
    consistently use 32-bit functions and structures.
    
    Change-Id: I413ab97001246c442df151700cc618df4391e03b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131964
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sal/cppunittester/cppunittester.cxx 
b/sal/cppunittester/cppunittester.cxx
index f75caccbc143..7d5ce39edf12 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -495,7 +495,11 @@ static void printStack( CONTEXT* ctx )
     HANDLE  process;
     HANDLE  thread;
     HMODULE hModule;
+#ifdef _M_AMD64
     STACKFRAME64        stack;
+#else
+    STACKFRAME          stack;
+#endif
     ULONG               frame;
     DWORD64             displacement;
     DWORD disp;
@@ -503,7 +507,11 @@ static void printStack( CONTEXT* ctx )
     char module[MaxNameLen];
     PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(buffer);
 
+#ifdef _M_AMD64
     memset( &stack, 0, sizeof( STACKFRAME64 ) );
+#else
+    memset( &stack, 0, sizeof( STACKFRAME ) );
+#endif
 
     process                = GetCurrentProcess();
     thread                 = GetCurrentThread();
@@ -519,19 +527,21 @@ static void printStack( CONTEXT* ctx )
 
     SymInitialize( process, nullptr, TRUE ); //load symbols
 
+#ifdef _M_AMD64
     std::unique_ptr<IMAGEHLP_LINE64> line(new IMAGEHLP_LINE64);
     line->SizeOfStruct = sizeof(IMAGEHLP_LINE64);
+#else
+    std::unique_ptr<IMAGEHLP_LINE> line(new IMAGEHLP_LINE);
+    line->SizeOfStruct = sizeof(IMAGEHLP_LINE);
+#endif
 
     for( frame = 0; ; frame++ )
     {
         //get next call from stack
+#ifdef _M_AMD64
         result = StackWalk64
         (
-#if defined(_M_AMD64)
             IMAGE_FILE_MACHINE_AMD64,
-#else
-            IMAGE_FILE_MACHINE_I386,
-#endif
             process,
             thread,
             &stack,
@@ -541,6 +551,20 @@ static void printStack( CONTEXT* ctx )
             SymGetModuleBase64,
             nullptr
         );
+#else
+        result = StackWalk
+        (
+            IMAGE_FILE_MACHINE_I386,
+            process,
+            thread,
+            &stack,
+            ctx,
+            nullptr,
+            SymFunctionTableAccess,
+            SymGetModuleBase,
+            nullptr
+        );
+#endif
 
         if( !result )
             break;
@@ -548,10 +572,17 @@ static void printStack( CONTEXT* ctx )
         //get symbol name for address
         pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
         pSymbol->MaxNameLen = MAX_SYM_NAME;
+#ifdef _M_AMD64
         SymFromAddr(process, static_cast< ULONG64 >(stack.AddrPC.Offset), 
&displacement, pSymbol);
-
+#else
+        SymFromAddr(process, static_cast< ULONG >(stack.AddrPC.Offset), 
&displacement, pSymbol);
+#endif
         //try to get line
+#ifdef _M_AMD64
         if (SymGetLineFromAddr64(process, stack.AddrPC.Offset, &disp, 
line.get()))
+#else
+        if (SymGetLineFromAddr(process, stack.AddrPC.Offset, &disp, 
line.get()))
+#endif
         {
             printf("\tat %s in %s: line: %lu: address: 0x%0I64X\n", 
pSymbol->Name, line->FileName, line->LineNumber, pSymbol->Address);
         }

Reply via email to