[Lldb-commits] [lldb] r106613 - in /lldb/trunk/source/Expression: ClangExpressionDeclMap.cpp DWARFExpression.cpp

Sean Callanan scallanan at apple.com
Tue Jun 22 17:47:48 PDT 2010


Author: spyffe
Date: Tue Jun 22 19:47:48 2010
New Revision: 106613

URL: http://llvm.org/viewvc/llvm-project?rev=106613&view=rev
Log:
Updated the expression parser to use proper logging when 
looking for external variables.  Also cleaned up the log
messages coming from the DWARF interpreter.

Modified:
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/DWARFExpression.cpp

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=106613&r1=106612&r2=106613&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Jun 22 19:47:48 2010
@@ -15,6 +15,7 @@
 // Project includes
 #include "lldb/lldb-private.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Expression/ClangASTSource.h"
 #include "lldb/Symbol/ClangASTContext.h"
@@ -29,12 +30,9 @@
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/ExecutionContext.h"
 
-//#define DEBUG_CEDM
-#ifdef DEBUG_CEDM
-#define DEBUG_PRINTF(...) fprintf(stderr, __VA_ARGS__)
-#else
-#define DEBUG_PRINTF(...)
-#endif
+#define DEBUG_PRINTF(...)           \
+    if (log)                        \
+        log->Printf(__VA_ARGS__)
 
 using namespace lldb_private;
 using namespace clang;
@@ -94,7 +92,9 @@
 ClangExpressionDeclMap::GetDecls(NameSearchContext &context,
                                  const char *name)
 {
-    DEBUG_PRINTF("Hunting for a definition for %s\n", name);
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
+    
+    DEBUG_PRINTF("Hunting for a definition for %s", name);
     
     // Back out in all cases where we're not fully initialized
     if (!m_exe_ctx || !m_exe_ctx->frame || !m_sym_ctx)
@@ -105,7 +105,7 @@
     
     if (!function || !block)
     {
-        DEBUG_PRINTF("function = %p, block = %p\n", function, block);
+        DEBUG_PRINTF("function = %p, block = %p", function, block);
         return;
     }
     
@@ -147,7 +147,7 @@
         
         if (!compile_unit)
         {
-            DEBUG_PRINTF("compile_unit = %p\n", compile_unit);
+            DEBUG_PRINTF("compile_unit = %p", compile_unit);
             return;
         }
         
@@ -170,11 +170,13 @@
 ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
                                        Variable* var)
 {
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
+    
     Type *var_type = var->GetType();
     
     if (!var_type) 
     {
-        DEBUG_PRINTF("Skipped a definition because it has no type\n");
+        DEBUG_PRINTF("Skipped a definition because it has no type");
         return;
     }
     
@@ -182,7 +184,7 @@
     
     if (!var_opaque_type)
     {
-        DEBUG_PRINTF("Skipped a definition because it has no Clang type\n");
+        DEBUG_PRINTF("Skipped a definition because it has no Clang type");
         return;
     }
     
@@ -192,7 +194,7 @@
     
     if (!type_list)
     {
-        DEBUG_PRINTF("Skipped a definition because the type has no associated type list\n");
+        DEBUG_PRINTF("Skipped a definition because the type has no associated type list");
         return;
     }
     
@@ -200,7 +202,7 @@
     
     if (!exe_ast_ctx)
     {
-        DEBUG_PRINTF("There is no AST context for the current execution context\n");
+        DEBUG_PRINTF("There is no AST context for the current execution context");
         return;
     }
     
@@ -210,7 +212,7 @@
     
     if (!var_location_expr.Evaluate(m_exe_ctx, exe_ast_ctx, NULL, *var_location.get(), &err))
     {
-        DEBUG_PRINTF("Error evaluating location: %s\n", err.AsCString());
+        DEBUG_PRINTF("Error evaluating location: %s", err.AsCString());
         return;
     }
     
@@ -249,18 +251,20 @@
     
     m_tuples.push_back(tuple);
     
-    DEBUG_PRINTF("Found variable\n");    
+    DEBUG_PRINTF("Found variable");    
 }
 
 void
 ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
                                        Function* fun)
 {
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
+
     Type *fun_type = fun->GetType();
     
     if (!fun_type) 
     {
-        DEBUG_PRINTF("Skipped a function because it has no type\n");
+        DEBUG_PRINTF("Skipped a function because it has no type");
         return;
     }
     
@@ -268,7 +272,7 @@
     
     if (!fun_opaque_type)
     {
-        DEBUG_PRINTF("Skipped a function because it has no Clang type\n");
+        DEBUG_PRINTF("Skipped a function because it has no Clang type");
         return;
     }
     
@@ -291,5 +295,5 @@
     
     m_tuples.push_back(tuple);
     
-    DEBUG_PRINTF("Found function\n");    
+    DEBUG_PRINTF("Found function");    
 }

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=106613&r1=106612&r2=106613&view=diff
==============================================================================
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Tue Jun 22 19:47:48 2010
@@ -840,14 +840,14 @@
 
         if (log)
         {
-            log->Printf("\n");
             size_t count = stack.size();
+            log->Printf("Stack before operation has %d values:", count);
             for (size_t i=0; i<count; ++i)
             {
                 StreamString new_value;
                 new_value.Printf("[%zu]", i);
                 stack[i].Dump(&new_value);
-                log->Printf("%s", new_value.GetData());
+                log->Printf("  %s", new_value.GetData());
             }
             log->Printf("0x%8.8x: %s", op_offset, DW_OP_value_to_name(op));
         }
@@ -2572,14 +2572,14 @@
     }
     else if (log)
     {
-        log->Printf("\n");
         size_t count = stack.size();
+        log->Printf("Stack after operation has %d values:", count);
         for (size_t i=0; i<count; ++i)
         {
             StreamString new_value;
             new_value.Printf("[%zu]", i);
             stack[i].Dump(&new_value);
-            log->Printf("%s", new_value.GetData());
+            log->Printf("  %s", new_value.GetData());
         }
     }
 





More information about the lldb-commits mailing list