Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LLDB core dumps loading in separate debug targets #1396

Merged
merged 2 commits into from
Jul 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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