Skip to content

Commit

Permalink
Fix LLDB core dumps loading in separate debug targets (#1396)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Wang <[email protected]>
  • Loading branch information
iridinite and WardenGnaw authored Jul 22, 2023
1 parent 8e80e0c commit 202416e
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -690,17 +690,11 @@ private async Task<List<LaunchCommand>> GetInitializeCommands()
LocalLaunchOptions localLaunchOptions = _launchOptions as LocalLaunchOptions;
if (this.IsCoreDump)
{
// Add executable information
this.AddExecutablePathCommand(commands);
// Load executable and core dump
this.AddExecutableAndCorePathCommand(commands);

// Important: this must occur after file-exec-and-symbols but before anything else.
// Important: this must occur after executable load but before anything else.
this.AddGetTargetArchitectureCommand(commands);

// Add core dump information (linux/mac does not support quotes around this path but spaces in the path do work)
string coreDump = this.UseUnixPathSeparators ? _launchOptions.CoreDumpPath : this.EnsureProperPathSeparators(_launchOptions.CoreDumpPath, true);
string coreDumpCommand = _launchOptions.DebuggerMIMode == MIMode.Lldb ? String.Concat("target create --core ", coreDump) : String.Concat("-target-select core ", coreDump);
string coreDumpDescription = String.Format(CultureInfo.CurrentCulture, ResourceStrings.LoadingCoreDumpMessage, _launchOptions.CoreDumpPath);
commands.Add(new LaunchCommand(coreDumpCommand, coreDumpDescription, ignoreFailures: false));
}
else if (_launchOptions.ProcessId.HasValue)
{
Expand Down Expand Up @@ -918,6 +912,30 @@ private void AddExecutablePathCommand(IList<LaunchCommand> commands)
commands.Add(new LaunchCommand("-file-exec-and-symbols " + exe, description, ignoreFailures: false, failureHandler: failureHandler));
}

private void AddExecutableAndCorePathCommand(IList<LaunchCommand> commands)
{
string command;
if (_launchOptions.DebuggerMIMode == MIMode.Lldb)
{
// LLDB requires loading the executable and the core into the same target, using one command. Quotes in the path are supported.
string exePath = this.EnsureProperPathSeparators(_launchOptions.ExePath, true);
string corePath = this.EnsureProperPathSeparators(_launchOptions.CoreDumpPath, true);
command = String.Concat("file ", exePath, " -c ", corePath);
}
else
{
// GDB requires loading the executable and core separately.
// Note: Linux/mac do not support quotes around this path, but spaces in the path do work.
this.AddExecutablePathCommand(commands);
string corePathNoQuotes = this.EnsureProperPathSeparators(_launchOptions.CoreDumpPath, true, true);
command = String.Concat("-target-select core ", corePathNoQuotes);
}

// Load core dump information
string description = String.Format(CultureInfo.CurrentCulture, ResourceStrings.LoadingCoreDumpMessage, _launchOptions.CoreDumpPath);
commands.Add(new LaunchCommand(command, description, ignoreFailures: false));
}

private void DetermineAndAddExecutablePathCommand(IList<LaunchCommand> commands, UnixShellPortLaunchOptions launchOptions)
{
// TODO: connecting to OSX via SSH doesn't work yet. Show error after connection manager dialog gets dismissed.
Expand Down

0 comments on commit 202416e

Please sign in to comment.