[Lldb-commits] [lldb] r113599 - in /lldb/trunk: examples/ examples/lookup/ examples/lookup/main.cpp include/lldb/API/SBAddress.h include/lldb/API/SBModule.h include/lldb/API/SBSymbolContext.h include/lldb/API/SBSymbolContextList.h lldb.xcodeproj/project.pbxproj source/API/SBAddress.cpp source/API/SBModule.cpp source/API/SBSymbolContext.cpp source/API/SBSymbolContextList.cpp source/Core/Timer.cpp

Greg Clayton gclayton at apple.com
Fri Sep 10 11:31:35 PDT 2010


Author: gclayton
Date: Fri Sep 10 13:31:35 2010
New Revision: 113599

URL: http://llvm.org/viewvc/llvm-project?rev=113599&view=rev
Log:
Added some missing API for address resolving within a module, and looking
up a seciton offset address (SBAddress) within a module that returns a
symbol context (SBSymbolContext). Also added a SBSymbolContextList in 
preparation for adding find/lookup APIs that can return multiple results.

Added a lookup example code that shows how to do address lookups.


Added:
    lldb/trunk/examples/
    lldb/trunk/examples/lookup/
    lldb/trunk/examples/lookup/main.cpp
    lldb/trunk/include/lldb/API/SBSymbolContextList.h
    lldb/trunk/source/API/SBSymbolContextList.cpp
Modified:
    lldb/trunk/include/lldb/API/SBAddress.h
    lldb/trunk/include/lldb/API/SBModule.h
    lldb/trunk/include/lldb/API/SBSymbolContext.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/API/SBAddress.cpp
    lldb/trunk/source/API/SBModule.cpp
    lldb/trunk/source/API/SBSymbolContext.cpp
    lldb/trunk/source/Core/Timer.cpp

Added: lldb/trunk/examples/lookup/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/lookup/main.cpp?rev=113599&view=auto
==============================================================================
--- lldb/trunk/examples/lookup/main.cpp (added)
+++ lldb/trunk/examples/lookup/main.cpp Fri Sep 10 13:31:35 2010
@@ -0,0 +1,105 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "lldb/API/SBBlock.h"
+#include "lldb/API/SBCompileUnit.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBFunction.h"
+#include "lldb/API/SBModule.h"
+#include "lldb/API/SBSymbol.h"
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBThread.h"
+#include "lldb/API/SBProcess.h"
+
+using namespace lldb;
+
+//----------------------------------------------------------------------
+// This quick sample code shows how to create a debugger instance and
+// create an "i386" executable target. Then we can lookup the executable
+// module and resolve a file address into a section offset address,
+// and find all symbol context objects (if any) for that address: 
+// compile unit, function, deepest block, line table entry and the 
+// symbol.
+//----------------------------------------------------------------------
+int
+main (int argc, char const *argv[])
+{
+    // Initialize LLDB
+    SBDebugger::Initialize();
+
+    if (argc < 3)
+        exit (1);
+    
+    // The first argument is the file path we want to look something up in
+    const char *exe_file_path = argv[1];
+    // The second arguemnt in the address that we want to lookup
+    lldb::addr_t file_addr = strtoull (argv[2], NULL, 0);
+    
+    // Make a file spec out of our executable path
+    SBFileSpec exe_file_spec (exe_file_path);
+    
+    // Create a debugger instance so we can create a target
+    SBDebugger debugger (SBDebugger::Create());
+    
+    if (debugger.IsValid())
+    {
+        // Create a target using the executable.
+        SBTarget target (debugger.CreateTargetWithFileAndArch (exe_file_path, "i386"));
+        if (target.IsValid())
+        {
+            // Find the executable module so we can do a lookup inside it
+            SBModule module (target.FindModule (exe_file_spec));
+            SBAddress addr;
+            
+            // Take a file virtual address and resolve it to a section offset
+            // address that can be used to do a symbol lookup by address
+            if (module.ResolveFileAddress (file_addr, addr))
+            {
+                // We can resolve a section offset address in the module
+                // and only ask for what we need. You can logical or together
+                // bits from the SymbolContextItem enumeration found in 
+                // lldb-enumeration.h to request only what you want. Here we
+                // are asking for everything. 
+                //
+                // NOTE: the less you ask for, the less LLDB will parse as
+                // LLDB does partial parsing on just about everything.
+                SBSymbolContext symbol_context (module.ResolveSymbolContextForAddress (addr, eSymbolContextEverything));
+                
+                SBCompileUnit comp_unit (symbol_context.GetCompileUnit());
+                if (comp_unit.IsValid())
+                {
+                }
+                SBFunction function (symbol_context.GetFunction());
+                if (function.IsValid())
+                {
+                }
+                SBBlock block (symbol_context.GetBlock());
+                if (block.IsValid())
+                {
+                }
+                SBLineEntry line_entry (symbol_context.GetLineEntry());
+                if (line_entry.IsValid())
+                {
+                }
+                SBSymbol symbol (symbol_context.GetSymbol());
+                if (symbol.IsValid())
+                {
+                }
+            }
+        }
+    }
+
+    // Terminate LLDB
+    SBDebugger::Terminate();
+    return 0;
+}
+

Modified: lldb/trunk/include/lldb/API/SBAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=113599&r1=113598&r2=113599&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBAddress.h (original)
+++ lldb/trunk/include/lldb/API/SBAddress.h Fri Sep 10 13:31:35 2010
@@ -32,6 +32,9 @@
     bool
     IsValid () const;
 
+    void
+    Clear ();
+
     addr_t
     GetFileAddress () const;
 
@@ -45,17 +48,24 @@
 
     friend class SBFrame;
     friend class SBLineEntry;
+    friend class SBModule;
     friend class SBSymbolContext;
     friend class SBThread;
 
 #ifndef SWIG
 
+    lldb_private::Address *
+    operator->();
+
     const lldb_private::Address *
     operator->() const;
 
     const lldb_private::Address &
     operator*() const;
 
+    lldb_private::Address &
+    operator*();
+
 #endif
 
 

Modified: lldb/trunk/include/lldb/API/SBModule.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=113599&r1=113598&r2=113599&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBModule.h (original)
+++ lldb/trunk/include/lldb/API/SBModule.h Fri Sep 10 13:31:35 2010
@@ -11,6 +11,7 @@
 #define LLDB_SBModule_h_
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBSymbolContext.h"
 
 namespace lldb {
 
@@ -40,6 +41,13 @@
 
 #endif
 
+    bool
+    ResolveFileAddress (lldb::addr_t vm_addr, 
+                        lldb::SBAddress& addr);
+
+    lldb::SBSymbolContext
+    ResolveSymbolContextForAddress (const lldb::SBAddress& addr, 
+                                    uint32_t resolve_scope);
 
 private:
     friend class SBSymbolContext;

Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=113599&r1=113598&r2=113599&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSymbolContext.h (original)
+++ lldb/trunk/include/lldb/API/SBSymbolContext.h Fri Sep 10 13:31:35 2010
@@ -46,17 +46,25 @@
 
 protected:
     friend class SBFrame;
+    friend class SBModule;
     friend class SBThread;
+    friend class SBSymbolContextList;
 
 #ifndef SWIG
 
     lldb_private::SymbolContext*
     operator->() const;
 
+    lldb_private::SymbolContext&
+    operator*();
+
+    const lldb_private::SymbolContext&
+    operator*() const;
+
 #endif
 
     lldb_private::SymbolContext *
-    GetLLDBObjectPtr() const;
+    get() const;
 
     SBSymbolContext (const lldb_private::SymbolContext *sc_ptr);
 

Added: lldb/trunk/include/lldb/API/SBSymbolContextList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContextList.h?rev=113599&view=auto
==============================================================================
--- lldb/trunk/include/lldb/API/SBSymbolContextList.h (added)
+++ lldb/trunk/include/lldb/API/SBSymbolContextList.h Fri Sep 10 13:31:35 2010
@@ -0,0 +1,60 @@
+//===-- SBSymbolContextList.h -----------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SBSymbolContextList_h_
+#define LLDB_SBSymbolContextList_h_
+
+#include "lldb/API/SBDefines.h"
+#include "lldb/API/SBSymbolContext.h"
+
+namespace lldb {
+
+class SBSymbolContextList
+{
+public:
+    SBSymbolContextList ();
+
+    SBSymbolContextList (const lldb::SBSymbolContextList& rhs);
+
+    ~SBSymbolContextList ();
+
+#ifndef SWIG
+    const lldb::SBSymbolContextList &
+    operator = (const lldb::SBSymbolContextList &rhs);
+#endif
+
+    bool
+    IsValid () const;
+
+    uint32_t
+    GetSize() const;
+
+    SBSymbolContext
+    GetContextAtIndex (uint32_t idx);
+
+protected:
+
+#ifndef SWIG
+
+    lldb_private::SymbolContextList*
+    operator->() const;
+
+    lldb_private::SymbolContextList&
+    operator*() const;
+
+#endif
+
+private:
+    std::auto_ptr<lldb_private::SymbolContextList> m_opaque_ap;
+};
+
+
+} // namespace lldb
+
+#endif // LLDB_SBSymbolContextList_h_

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113599&r1=113598&r2=113599&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 10 13:31:35 2010
@@ -63,6 +63,8 @@
 		26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; };
 		26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; };
 		2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; };
+		268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; };
+		268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; };
 		26B42B1F1187A92B0079C8C8 /* lldb-include.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42B1E1187A92B0079C8C8 /* lldb-include.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		26D27C9F11ED3A4E0024D721 /* ELFHeader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D27C9D11ED3A4E0024D721 /* ELFHeader.cpp */; };
@@ -567,6 +569,8 @@
 		2689B0A4113EE3CD00A4AEDB /* Symbols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Symbols.h; path = include/lldb/Host/Symbols.h; sourceTree = "<group>"; };
 		2689B0B5113EE47E00A4AEDB /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Symbols.cpp; path = source/Host/macosx/Symbols.cpp; sourceTree = "<group>"; };
 		268A813F115B19D000F645B0 /* UniqueCStringMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UniqueCStringMap.h; path = include/lldb/Core/UniqueCStringMap.h; sourceTree = "<group>"; };
+		268F9D52123AA15200B91E9B /* SBSymbolContextList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSymbolContextList.h; path = include/lldb/API/SBSymbolContextList.h; sourceTree = "<group>"; };
+		268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; sourceTree = "<group>"; };
 		269416AD119A024800FF2715 /* CommandObjectTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTarget.cpp; path = source/Commands/CommandObjectTarget.cpp; sourceTree = "<group>"; };
 		269416AE119A024800FF2715 /* CommandObjectTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectTarget.h; path = source/Commands/CommandObjectTarget.h; sourceTree = "<group>"; };
 		26A0604711A5BC7A00F75969 /* Baton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Baton.h; path = include/lldb/Core/Baton.h; sourceTree = "<group>"; };
@@ -1479,6 +1483,8 @@
 				26DE20641161904E00A093E2 /* SBSymbol.cpp */,
 				26DE204011618AB900A093E2 /* SBSymbolContext.h */,
 				26DE204611618AED00A093E2 /* SBSymbolContext.cpp */,
+				268F9D52123AA15200B91E9B /* SBSymbolContextList.h */,
+				268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */,
 				9A9831081125FC5800A56CB0 /* SBTarget.h */,
 				9A9831071125FC5800A56CB0 /* SBTarget.cpp */,
 				9A98310A1125FC5800A56CB0 /* SBThread.h */,
@@ -2264,6 +2270,7 @@
 				49CF9834122C718B007A0B96 /* IRDynamicChecks.h in Headers */,
 				961FABEB1235F26800F93A47 /* UnwindAssemblyProfiler-x86.h in Headers */,
 				961FAC1F12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h in Headers */,
+				268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2726,6 +2733,7 @@
 				69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */,
 				69A01E251236C5D400C660B5 /* Symbols.cpp in Sources */,
 				69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */,
+				268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: lldb/trunk/source/API/SBAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=113599&r1=113598&r2=113599&view=diff
==============================================================================
--- lldb/trunk/source/API/SBAddress.cpp (original)
+++ lldb/trunk/source/API/SBAddress.cpp Fri Sep 10 13:31:35 2010
@@ -55,6 +55,12 @@
 }
 
 void
+SBAddress::Clear ()
+{
+    m_opaque_ap.reset();
+}
+
+void
 SBAddress::SetAddress (const lldb_private::Address *lldb_object_ptr)
 {
     if (lldb_object_ptr)
@@ -102,6 +108,11 @@
     return false;
 }
 
+lldb_private::Address *
+SBAddress::operator->()
+{
+    return m_opaque_ap.get();
+}
 
 const lldb_private::Address *
 SBAddress::operator->() const
@@ -109,9 +120,18 @@
     return m_opaque_ap.get();
 }
 
+lldb_private::Address &
+SBAddress::operator*()
+{
+    if (m_opaque_ap.get() == NULL)
+        m_opaque_ap.reset (new lldb_private::Address);
+    return *m_opaque_ap;
+}
+
 const lldb_private::Address &
 SBAddress::operator*() const
 {
+    assert (m_opaque_ap.get());
     return *m_opaque_ap;
 }
 

Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=113599&r1=113598&r2=113599&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Fri Sep 10 13:31:35 2010
@@ -8,6 +8,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/API/SBModule.h"
+#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/Core/Module.h"
 
@@ -105,3 +107,23 @@
     m_opaque_sp = module_sp;
 }
 
+
+bool
+SBModule::ResolveFileAddress (lldb::addr_t vm_addr, SBAddress& addr)
+{
+    if (m_opaque_sp)
+        return m_opaque_sp->ResolveFileAddress (vm_addr, *addr);
+    
+    addr->Clear();
+    return false;
+}
+
+SBSymbolContext
+SBModule::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope)
+{
+    SBSymbolContext sb_sc;
+    if (m_opaque_sp && addr.IsValid())
+        m_opaque_sp->ResolveSymbolContextForAddress (*addr, resolve_scope, *sb_sc);
+    return sb_sc;
+}
+

Modified: lldb/trunk/source/API/SBSymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=113599&r1=113598&r2=113599&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbolContext.cpp (original)
+++ lldb/trunk/source/API/SBSymbolContext.cpp Fri Sep 10 13:31:35 2010
@@ -123,8 +123,25 @@
     return m_opaque_ap.get();
 }
 
+
+const lldb_private::SymbolContext&
+SBSymbolContext::operator*() const
+{
+    assert (m_opaque_ap.get());
+    return *m_opaque_ap.get();
+}
+
+
+lldb_private::SymbolContext&
+SBSymbolContext::operator*()
+{
+    if (m_opaque_ap.get() == NULL)
+        m_opaque_ap.reset (new SymbolContext);
+    return *m_opaque_ap.get();
+}
+
 lldb_private::SymbolContext *
-SBSymbolContext::GetLLDBObjectPtr() const
+SBSymbolContext::get() const
 {
     return m_opaque_ap.get();
 }

Added: lldb/trunk/source/API/SBSymbolContextList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContextList.cpp?rev=113599&view=auto
==============================================================================
--- lldb/trunk/source/API/SBSymbolContextList.cpp (added)
+++ lldb/trunk/source/API/SBSymbolContextList.cpp Fri Sep 10 13:31:35 2010
@@ -0,0 +1,91 @@
+//===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/API/SBSymbolContextList.h"
+#include "lldb/Symbol/SymbolContext.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBSymbolContextList::SBSymbolContextList () :
+    m_opaque_ap ()
+{
+}
+
+SBSymbolContextList::SBSymbolContextList (const SBSymbolContextList& rhs) :
+    m_opaque_ap ()
+{
+    if (rhs.IsValid())
+        *m_opaque_ap = *rhs.m_opaque_ap;
+}
+
+SBSymbolContextList::~SBSymbolContextList ()
+{
+}
+
+const SBSymbolContextList &
+SBSymbolContextList::operator = (const SBSymbolContextList &rhs)
+{
+    if (this != &rhs)
+    {
+        if (rhs.IsValid())
+            m_opaque_ap.reset (new lldb_private::SymbolContextList(*rhs.m_opaque_ap.get()));
+    }
+    return *this;
+}
+
+uint32_t
+SBSymbolContextList::GetSize() const
+{
+    if (m_opaque_ap.get())
+        return m_opaque_ap->GetSize();
+    return 0;
+}
+
+SBSymbolContext
+SBSymbolContextList::GetContextAtIndex (uint32_t idx)
+{
+    SBSymbolContext sb_sc;
+    if (m_opaque_ap.get())
+    {
+        SymbolContext sc;
+        if (m_opaque_ap->GetContextAtIndex (idx, sc))
+        {
+            sb_sc.SetSymbolContext(&sc);
+        }
+    }
+    return sb_sc;
+}
+
+
+bool
+SBSymbolContextList::IsValid () const
+{
+    return m_opaque_ap.get() != NULL;
+}
+
+
+
+lldb_private::SymbolContextList*
+SBSymbolContextList::operator->() const
+{
+    return m_opaque_ap.get();
+}
+
+
+lldb_private::SymbolContextList&
+SBSymbolContextList::operator*() const
+{
+    assert (m_opaque_ap.get());
+    return *m_opaque_ap.get();
+}
+
+
+
+

Modified: lldb/trunk/source/Core/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Timer.cpp?rev=113599&r1=113598&r2=113599&view=diff
==============================================================================
--- lldb/trunk/source/Core/Timer.cpp (original)
+++ lldb/trunk/source/Core/Timer.cpp Fri Sep 10 13:31:35 2010
@@ -20,6 +20,7 @@
 using namespace lldb_private;
 
 #define TIMER_INDENT_AMOUNT 2
+static bool g_quiet = true;
 uint32_t Timer::g_depth = 0;
 uint32_t Timer::g_display_depth = 0;
 FILE * Timer::g_file = NULL;
@@ -78,16 +79,19 @@
 {
     if (g_depth++ < g_display_depth)
     {
-        // Indent
-        ::fprintf (g_file, "%*s", g_depth * TIMER_INDENT_AMOUNT, "");
-        // Print formatted string
-        va_list args;
-        va_start (args, format);
-        ::vfprintf (g_file, format, args);
-        va_end (args);
+        if (g_quiet == false)
+        {
+            // Indent
+            ::fprintf (g_file, "%*s", g_depth * TIMER_INDENT_AMOUNT, "");
+            // Print formatted string
+            va_list args;
+            va_start (args, format);
+            ::vfprintf (g_file, format, args);
+            va_end (args);
 
-        // Newline
-        ::fprintf (g_file, "\n");
+            // Newline
+            ::fprintf (g_file, "\n");
+        }
         TimeValue start_time(TimeValue::Now());
         m_total_start = start_time;
         m_timer_start = start_time;
@@ -133,11 +137,16 @@
         const uint64_t timer_nsec_uint = GetTimerElapsedNanoSeconds();
         const double total_nsec = total_nsec_uint;
         const double timer_nsec = timer_nsec_uint;
-        ::fprintf (g_file,
-                   "%*s%.9f sec (%.9f sec)\n",
-                   (g_depth - 1) *TIMER_INDENT_AMOUNT, "",
-                   total_nsec / 1000000000.0,
-                   timer_nsec / 1000000000.0);
+
+        if (g_quiet == false)
+        {
+
+            ::fprintf (g_file,
+                       "%*s%.9f sec (%.9f sec)\n",
+                       (g_depth - 1) *TIMER_INDENT_AMOUNT, "",
+                       total_nsec / 1000000000.0,
+                       timer_nsec / 1000000000.0);
+        }
 
         // Keep total results for each category so we can dump results.
         Mutex::Locker locker (GetCategoryMutex());





More information about the lldb-commits mailing list