Mesa (debug-refcnt-2): u_debug_symbol: support getting a string without output

Luca Barbieri lb at kemper.freedesktop.org
Fri Aug 20 12:20:46 UTC 2010


Module: Mesa
Branch: debug-refcnt-2
Commit: 9b907e118acf20bf7bfbab9692f8de5bf7de98fa
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b907e118acf20bf7bfbab9692f8de5bf7de98fa

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Wed Aug 18 00:38:19 2010 +0200

u_debug_symbol: support getting a string without output

---

 src/gallium/auxiliary/util/u_debug_symbol.c |   36 +++++++++++++++++---------
 src/gallium/auxiliary/util/u_debug_symbol.h |    3 ++
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c b/src/gallium/auxiliary/util/u_debug_symbol.c
index 6e25057..1f71c1d 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -33,6 +33,7 @@
  */
 
 #include "pipe/p_compiler.h"
+#include "u_string.h"
 
 #include "u_debug.h"
 #include "u_debug_symbol.h"
@@ -113,8 +114,8 @@ BOOL WINAPI j_SymGetSymFromAddr(HANDLE hProcess, DWORD Address, PDWORD Displacem
 }
 
 
-static INLINE boolean
-debug_symbol_print_imagehlp(const void *addr)
+static INLINE void
+debug_symbol_name_imagehlp(const void *addr, char* buf, unsigned size)
 {
    HANDLE hProcess;
    BYTE symbolBuffer[1024];
@@ -133,23 +134,32 @@ debug_symbol_print_imagehlp(const void *addr)
    }
       
    if(!j_SymGetSymFromAddr(hProcess, (DWORD)addr, &dwDisplacement, pSymbol))
-      return FALSE;
-
-   debug_printf("\t%s\n", pSymbol->Name);
-
-   return TRUE;
-   
+      buf[0] = 0;
+   else
+   {
+      strncpy(buf, pSymbol->Name, size);
+      buf[size - 1] = 0;
+   }
 }
 #endif
 
-
 void
-debug_symbol_print(const void *addr)
+debug_symbol_name(const void *addr, char* buf, unsigned size)
 {
 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER) && defined(PIPE_ARCH_X86)
-   if(debug_symbol_print_imagehlp(addr))
+   debug_symbol_name_imagehlp(addr, buf, size);
+   if(buf[0])
       return;
 #endif
-   
-   debug_printf("\t%p\n", addr);
+
+   util_snprintf(buf, size, "%p", addr);
+   buf[size - 1] = 0;
+}
+
+void
+debug_symbol_print(const void *addr)
+{
+   char buf[1024];
+   debug_symbol_name(addr, buf, sizeof(buf));
+   debug_printf("\t%s\n", buf);
 }
diff --git a/src/gallium/auxiliary/util/u_debug_symbol.h b/src/gallium/auxiliary/util/u_debug_symbol.h
index 0215869..5e283e5 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.h
+++ b/src/gallium/auxiliary/util/u_debug_symbol.h
@@ -43,6 +43,9 @@ extern "C" {
 
 
 void
+debug_symbol_name(const void *addr, char* buf, unsigned size);
+
+void
 debug_symbol_print(const void *addr);
 
 




More information about the mesa-commit mailing list