Fix crash in lldb-mi when stack variable name is nullptr. This always happens when execution stops in try scope with unnamed catch clause

llvm-svn: 259189
This commit is contained in:
Eugene Leviant
2016-01-29 12:17:09 +00:00
parent 941ca06688
commit ec4d04e507
3 changed files with 34 additions and 1 deletions

View File

@@ -199,7 +199,20 @@ class MiStackTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
self.runCmd("-stack-list-locals --simple-values")
self.expect("\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
# Test -stack-list-locals in a function with catch clause,
# having unnamed parameter
# Run to BP_catch_unnamed
line = line_number('main.cpp', '// BP_catch_unnamed')
self.runCmd("-break-insert --file main.cpp:%d" % line)
self.expect("\^done,bkpt={number=\"6\"")
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect("\*stopped,reason=\"breakpoint-hit\"")
# Test -stack-list-locals: use --no-values
self.runCmd("-stack-list-locals --no-values")
self.expect("\^done,locals=\[name=\"i\",name=\"j\"\]")
@skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
def test_lldbmi_stack_list_variables(self):

View File

@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
#include <exception>
struct inner
{
int var_d;
@@ -114,6 +116,18 @@ int do_tests_with_args()
return 0;
}
void catch_unnamed_test()
{
try
{
int i = 1, j = 2;
throw std::exception(); // BP_catch_unnamed
}
catch(std::exception&)
{
}
}
int
main(int argc, char const *argv[])
{
@@ -121,6 +135,7 @@ main(int argc, char const *argv[])
local_struct_test();
local_array_test();
local_pointer_test();
catch_unnamed_test();
do_tests_with_args();
return 0;

View File

@@ -452,7 +452,12 @@ CMICmnLLDBDebugSessionInfo::MIResponseForVariableInfoInternal(const VariableInfo
{
CMICmnMIValueTuple miValueTuple;
lldb::SBValue value = vwrSBValueList.GetValueAtIndex(i);
const CMICmnMIValueConst miValueConst(value.GetName());
// If one stops inside try block with, which catch clause type is unnamed
// (e.g std::exception&) then value name will be nullptr as well as value pointer
const char* name = value.GetName();
if (name == nullptr)
continue;
const CMICmnMIValueConst miValueConst(name);
const CMICmnMIValueResult miValueResultName("name", miValueConst);
if (vbMarkArgs && vbIsArgs)
{