From fee6e493b0062930f091847e68f14d9fc2bbd4bb Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Mon, 19 Dec 2011 22:51:27 +0000 Subject: [PATCH] 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. llvm-svn: 146917 --- lldb/source/Core/UserSettingsController.cpp | 14 +++++++-- .../python_api/debugger/TestDebuggerAPI.py | 30 +++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 lldb/test/python_api/debugger/TestDebuggerAPI.py diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index 91e4f0beb305..65c263f396e0 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -280,7 +280,9 @@ UserSettingsController::SetVariable (const char *full_dot_name, 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 @@ UserSettingsController::GetVariable 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)); diff --git a/lldb/test/python_api/debugger/TestDebuggerAPI.py b/lldb/test/python_api/debugger/TestDebuggerAPI.py new file mode 100644 index 000000000000..b9d169e244ae --- /dev/null +++ b/lldb/test/python_api/debugger/TestDebuggerAPI.py @@ -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)