[Lldb-commits] [lldb] r146917 - in /lldb/trunk: source/Core/UserSettingsController.cpp test/python_api/debugger/ test/python_api/debugger/TestDebuggerAPI.py

Johnny Chen johnny.chen at apple.com
Mon Dec 19 14:51:28 PST 2011


Author: johnny
Date: Mon Dec 19 16:51:27 2011
New Revision: 146917

URL: http://llvm.org/viewvc/llvm-project?rev=146917&view=rev
Log:
Work in progress for:

rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBDebugger APIs.

Added:
    lldb/trunk/test/python_api/debugger/
    lldb/trunk/test/python_api/debugger/TestDebuggerAPI.py
Modified:
    lldb/trunk/source/Core/UserSettingsController.cpp

Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=146917&r1=146916&r2=146917&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Mon Dec 19 16:51:27 2011
@@ -280,7 +280,9 @@
     ConstString const_var_name;
     const ConstString &default_name = InstanceSettings::GetDefaultName();
 
-    Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name);
+    Args names;
+    if (full_dot_name )
+        names = UserSettingsController::BreakNameIntoPieces (full_dot_name);
     int num_pieces = names.GetArgumentCount();
 
     if (num_pieces < 1)
@@ -538,12 +540,18 @@
     Error &err
 )
 {
-    Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name);
-    ConstString const_var_name;
     StringList value;
+    if (!full_dot_name)
+    {
+        err.SetErrorString ("invalid variable name");
+        return value;
+    }
 
+    Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name);
     int num_pieces = names.GetArgumentCount();
 
+    ConstString const_var_name;
+
     ConstString prefix (names.GetArgumentAtIndex (0));
     const_var_name.SetCString (names.GetArgumentAtIndex (num_pieces - 1));
 

Added: lldb/trunk/test/python_api/debugger/TestDebuggerAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/debugger/TestDebuggerAPI.py?rev=146917&view=auto
==============================================================================
--- lldb/trunk/test/python_api/debugger/TestDebuggerAPI.py (added)
+++ lldb/trunk/test/python_api/debugger/TestDebuggerAPI.py Mon Dec 19 16:51:27 2011
@@ -0,0 +1,30 @@
+"""
+Test Debugger APIs.
+"""
+
+import os, time
+import re
+import unittest2
+import lldb, lldbutil
+from lldbtest import *
+
+class DebuggerAPITestCase(TestBase):
+
+    mydir = os.path.join("python_api", "debugger")
+
+    @python_api_test
+    def test_debugger_api_boundary_condition(self):
+        """Exercise SBDebugger APIs with boundary conditions."""
+        self.dbg.HandleCommand(None)
+        self.dbg.SetDefaultArchitecture(None)
+        self.dbg.GetScriptingLanguage(None)
+        self.dbg.CreateTarget(None)
+        self.dbg.CreateTarget(None, None, None, True, lldb.SBError())
+        self.dbg.CreateTargetWithFileAndTargetTriple(None, None)
+        self.dbg.CreateTargetWithFileAndArch(None, None)
+        self.dbg.FindTargetWithFileAndArch(None, None)
+        self.dbg.SetInternalVariable(None, None, None)
+        self.dbg.GetInternalVariableValue(None, None)
+        self.dbg.SetPrompt(None)
+        self.dbg.SetCurrentPlatform(None)
+        self.dbg.SetCurrentPlatformSDKRoot(None)





More information about the lldb-commits mailing list