[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-server-cvs
Subject:    [Server-cvs] common/util/platform/windows hxbacktrace.cpp,1.1,1.2
From:       dcollins () helixcommunity ! org
Date:       2010-12-10 20:31:09
Message-ID: 201012102031.oBAKV553006536 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/server/common/util/platform/windows
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv18840/server/common/util/platform/windows

Modified Files:
	hxbacktrace.cpp 
Log Message:
Synopsis
========
Adds an internal command-line flag to enable/disable verbose Win64 backtraces

Branches: HEAD
Reviewer: Chytanya


Description
===========

Win64 backtrace APIs allow us access to a lot of detailed register
information at each frame of the stack.  Currently, we dump this for
each stack frame in CA/HBFs.  Having chased some CAs, this is too much
information in the normal case.

With this diff, dumping the stack pointers becomes be the default
behavior, with the verbose stack dumps available as a runtime option.
By specifying --vbt (--verbose-back-trace) a Win64 build can still
dump the detailed stack information, which looks like it could be
very useful for certain types of issues.  By default, this verbose
information is disabled.

This command-line flag will be for developer/internal-use only.


Files Affected
==============

server/engine/core/_main.cpp
server/common/util/platform/windows/hxbacktrace.cpp
server/common/util/pub/platform/win/hxbacktrace.h
server/common/util/trace.c


Testing Performed
=================

Unit Tests:
- N/A

Integration Tests:
- Ran a 64-bit release build of the proxy in the Win2k8 uptime rig,
  with and without the --vbt flag, verifying the behavior.

Leak Tests:
- N/A

Performance Tests:
- N/A

Platforms Tested: win-x86_64-vc10
Builds Verified: win-x86_64-vc10, linux-rhel5-x86_64


QA Hints
========
- N/A


Index: hxbacktrace.cpp
===================================================================
RCS file: /cvsroot/server/common/util/platform/windows/hxbacktrace.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hxbacktrace.cpp	11 Oct 2010 16:05:18 -0000	1.1
+++ hxbacktrace.cpp	10 Dec 2010 20:31:06 -0000	1.2
@@ -60,14 +60,14 @@
 
 __declspec(noinline)
 char*
-HXWinBackTrace(void)
+HXWinBackTrace(int bVerbose)
 {
-    return HXWinThreadBackTrace(GetCurrentThread(), 2, FRAME_LIMIT);
+    return HXWinThreadBackTrace(GetCurrentThread(), 2, FRAME_LIMIT, bVerbose);
 }
 
 __declspec(noinline)
 char*
-HXWinThreadBackTrace(HANDLE hThread, int nFramesToSkip, int nFramesToCapture)
+HXWinThreadBackTrace(HANDLE hThread, int nFramesToSkip, int nFramesToCapture, int bVerbose)
 {
     //XXX need to limit the output to the size of g_threadLocal_backtrace
 
@@ -117,46 +117,55 @@
 
         if (!bSkipFirst && nFrame >= nFramesToSkip)
         {
-            pBuf += sprintf(pBuf, "0x%08llx:\n", ctx.Rip);
-            pBuf += sprintf(pBuf,
-                    "  FRAME 0x%02x\n",
-                    nFrame - nFramesToSkip);
-            pBuf += sprintf(pBuf,
-                    "  Rip=0x%p Rsp=0x%p Rbp=0x%p\n",
-                    ctx.Rip, ctx.Rsp, ctx.Rbp);
-            pBuf += sprintf(pBuf,
-                    "  Rax=0x%p Rbx=0x%p Rcx=0x%p\n",
-                    ctx.Rax, ctx.Rbx, ctx.Rcx);
-            pBuf += sprintf(pBuf,
-                    "  Rdx=0x%p Rsi=0x%p Rdi=0x%p\n",
-                    ctx.Rdx, ctx.Rsi, ctx.Rdi);
-            pBuf += sprintf(pBuf,
-                    "  R8 =0x%p R9 =0x%p R10=0x%p\n"
-                    "  R11=0x%p R12=0x%p R13=0x%p\n"
-                    "  R14=0x%p R15=0x%p\n",
-                    ctx.R8,  ctx.R9,  ctx.R10,
-                    ctx.R11, ctx.R12, ctx.R13,
-                    ctx.R14, ctx.R15);
+            if (!bVerbose)
+            {
+                //simply dump the frame's instruction pointer
+                pBuf += sprintf(pBuf, "0x%08llx\n", ctx.Rip);
+            }
+            else
+            {
+                // verbose stack dump with detail register data
+                pBuf += sprintf(pBuf, "0x%08llx:\n", ctx.Rip);
+                pBuf += sprintf(pBuf,
+                        "  FRAME 0x%02x\n",
+                        nFrame - nFramesToSkip);
+                pBuf += sprintf(pBuf,
+                        "  Rip=0x%p Rsp=0x%p Rbp=0x%p\n",
+                        ctx.Rip, ctx.Rsp, ctx.Rbp);
+                pBuf += sprintf(pBuf,
+                        "  Rax=0x%p Rbx=0x%p Rcx=0x%p\n",
+                        ctx.Rax, ctx.Rbx, ctx.Rcx);
+                pBuf += sprintf(pBuf,
+                        "  Rdx=0x%p Rsi=0x%p Rdi=0x%p\n",
+                        ctx.Rdx, ctx.Rsi, ctx.Rdi);
+                pBuf += sprintf(pBuf,
+                        "  R8 =0x%p R9 =0x%p R10=0x%p\n"
+                        "  R11=0x%p R12=0x%p R13=0x%p\n"
+                        "  R14=0x%p R15=0x%p\n",
+                        ctx.R8,  ctx.R9,  ctx.R10,
+                        ctx.R11, ctx.R12, ctx.R13,
+                        ctx.R14, ctx.R15);
 
 
-            static const char* RegisterNames[16] =
-            {
-                // These need to be in the same order as in the CONTEXT structure
-                "Rax", "Rcx", "Rdx", "Rbx", "Rsp", "Rbp", "Rsi", "Rdi",
-                "R8",  "R9",  "R10", "R11", "R12", "R13", "R14", "R15"
-            };
+                static const char* RegisterNames[16] =
+                {
+                    // These need to be in the same order as in the CONTEXT structure
+                    "Rax", "Rcx", "Rdx", "Rbx", "Rsp", "Rbp", "Rsi", "Rdi",
+                    "R8",  "R9",  "R10", "R11", "R12", "R13", "R14", "R15"
+                };
 
-            // This dumps the registers saved on the stack, if any
-            for (int nIndex=0; nIndex < 16; nIndex++)
-            {
-                if (nonvolContext.IntegerContext[nIndex])
+                // This dumps the registers saved on the stack, if any
+                for (int nIndex=0; nIndex < 16; nIndex++)
                 {
-                    pBuf += sprintf(pBuf, "  %s @ 0x%p (0x%p)\n",
-                            RegisterNames[nIndex], nonvolContext.IntegerContext[nIndex],
-                            *nonvolContext.IntegerContext[nIndex]);
+                    if (nonvolContext.IntegerContext[nIndex])
+                    {
+                        pBuf += sprintf(pBuf, "  %s @ 0x%p (0x%p)\n",
+                                RegisterNames[nIndex], nonvolContext.IntegerContext[nIndex],
+                                *nonvolContext.IntegerContext[nIndex]);
+                    }
                 }
+                pBuf += sprintf(pBuf, "\n");
             }
-            pBuf += sprintf(pBuf, "\n");
         }
         else
         {


_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic