[Lldb-commits] [lldb] r151116 - /lldb/trunk/examples/lookup/main.cpp

Johnny Chen johnny.chen at apple.com
Tue Feb 21 18:03:14 PST 2012


Author: johnny
Date: Tue Feb 21 20:03:13 2012
New Revision: 151116

URL: http://llvm.org/viewvc/llvm-project?rev=151116&view=rev
Log:
Use a sentry object to properly initialize/terminate LLDB.

Modified:
    lldb/trunk/examples/lookup/main.cpp

Modified: lldb/trunk/examples/lookup/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/lookup/main.cpp?rev=151116&r1=151115&r2=151116&view=diff
==============================================================================
--- lldb/trunk/examples/lookup/main.cpp (original)
+++ lldb/trunk/examples/lookup/main.cpp Tue Feb 21 20:03:13 2012
@@ -38,11 +38,23 @@
 //
 //    $ DYLD_FRAMEWORK_PATH=/Volumes/data/lldb/svn/ToT/build/Debug ./a.out executable_path file_address
 //----------------------------------------------------------------------
+class LLDBSentry
+{
+public:
+    LLDBSentry() {
+        // Initialize LLDB
+        SBDebugger::Initialize();
+    }
+    ~LLDBSentry() {
+        // Terminate LLDB
+        SBDebugger::Terminate();
+    }
+};
 int
 main (int argc, char const *argv[])
 {
-    // Initialize LLDB
-    SBDebugger::Initialize();
+    // Use a sentry object to properly initialize/terminate LLDB.
+    LLDBSentry sentry;
 
     if (argc < 3)
         exit (1);
@@ -105,8 +117,6 @@
         }
     }
 
-    // Terminate LLDB
-    SBDebugger::Terminate();
     return 0;
 }
 





More information about the lldb-commits mailing list