Skip to content

Commit

Permalink
Add a new SBTarget::LoadCore() overload which surfaces errors if the …
Browse files Browse the repository at this point in the history
…load fails

There was no way to find out what's wrong if SBProcess SBTarget::LoadCore(const char *core_file) failed. 
Additionally, the implementation was unconditionally setting sb_process, so it wasn't even possible to check if the return SBProcess is valid.

This change adds a new overload which surfaces the errors and also returns a valid SBProcess only if the core load succeeds:

SBProcess SBTarget::LoadCore(const char *core_file, SBError &error);

Differential Revision: https://reviews.llvm.org/D48049

llvm-svn: 334439
  • Loading branch information
Leonard Mosescu committed Jun 11, 2018
1 parent ed32baa commit e1bb517
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 67 deletions.
5 changes: 3 additions & 2 deletions lldb/include/lldb/API/SBTarget.h
Expand Up @@ -165,6 +165,7 @@ class LLDB_API SBTarget {
bool stop_at_entry, lldb::SBError &error);

SBProcess LoadCore(const char *core_file);
SBProcess LoadCore(const char *core_file, lldb::SBError &error);

//------------------------------------------------------------------
/// Launch a new process with sensible defaults.
Expand Down Expand Up @@ -718,9 +719,9 @@ class LLDB_API SBTarget {
// Finds all breakpoints by name, returning the list in bkpt_list. Returns
// false if the name is not a valid breakpoint name, true otherwise.
bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);

void GetBreakpointNames(SBStringList &names);

void DeleteBreakpointName(const char *name);

bool EnableAllBreakpoints();
Expand Down
Expand Up @@ -59,6 +59,24 @@ def check_state(self):
self.dbg.SetOutputFileHandle(None, False)
self.dbg.SetErrorFileHandle(None, False)

def test_loadcore_error_status(self):
"""Test the SBTarget.LoadCore(core, error) overload."""
self.dbg.CreateTarget(None)
self.target = self.dbg.GetSelectedTarget()
error = lldb.SBError()
self.process = self.target.LoadCore("linux-x86_64.dmp", error)
self.assertTrue(self.process, PROCESS_IS_VALID)
self.assertTrue(error.Success())

def test_loadcore_error_status_failure(self):
"""Test the SBTarget.LoadCore(core, error) overload."""
self.dbg.CreateTarget(None)
self.target = self.dbg.GetSelectedTarget()
error = lldb.SBError()
self.process = self.target.LoadCore("non-existent.dmp", error)
self.assertFalse(self.process, PROCESS_IS_VALID)
self.assertTrue(error.Fail())

def test_process_info_in_minidump(self):
"""Test that lldb can read the process information from the Minidump."""
# target create -c linux-x86_64.dmp
Expand Down

0 comments on commit e1bb517

Please sign in to comment.