Skip to content
Merged
Show file tree
Hide file tree
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
54 changes: 54 additions & 0 deletions loc/lci/OpenFolderSchema.json.lci
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,60 @@
<Cmt Name="LcxAdmin"><![CDATA[{Locked}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.description" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Controls GDB's debuginfod behavior for automatic downloading of debug symbols.]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked="GDB"} {Locked="debuginfod"}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.type" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[object]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.properties.enabled.description" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[If true (default), GDB's debuginfod support is enabled. Set to false to disable debuginfod, which can prevent GDB from hanging when debuginfod servers are unavailable.]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked="GDB"} {Locked="debuginfod"}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.properties.enabled.type" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[boolean]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.properties.timeout.description" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The timeout in seconds for debuginfod server requests. Default is 30. Set to 0 for no timeout override (GDB defaults apply). Applies to local, runInTerminal, and SSH attach transports. This setting is not applied for pipeTransport; set DEBUGINFOD_TIMEOUT and DEBUGINFOD_MAXTIME in the debugger's environment manually.]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked="debuginfod"} {Locked="GDB"} {Locked="DEBUGINFOD_TIMEOUT"} {Locked="DEBUGINFOD_MAXTIME"} {Locked="pipeTransport"} {Locked="runInTerminal"} {Locked="SSH"}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.properties.timeout.type" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[integer]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.environment.description" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Environment variables to add to the environment for the program. ]A;Example: [ { "name": "squid", "value": "clam" } ]5D;.]]></Val>
Expand Down
21 changes: 21 additions & 0 deletions src/MICore/JsonLaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ public abstract partial class BaseOptions
/// </summary>
[JsonProperty("unknownBreakpointHandling", DefaultValueHandling = DefaultValueHandling.Ignore)]
public UnknownBreakpointHandling? UnknownBreakpointHandling { get; set; }

/// <summary>
/// Controls GDB's debuginfod behavior.
/// </summary>
[JsonProperty("debuginfod", DefaultValueHandling = DefaultValueHandling.Ignore)]
public DebuginfodSettings Debuginfod { get; set; }
}

internal class VisualizerFileConverter : JsonConverter
Expand Down Expand Up @@ -315,6 +321,21 @@ public enum UnknownBreakpointHandling
Stop
}

public partial class DebuginfodSettings
{
/// <summary>
/// If true (default), GDB's debuginfod support is enabled.
/// </summary>
[JsonProperty("enabled")]
public bool? Enabled { get; set; }

/// <summary>
/// The timeout in seconds for debuginfod server requests. Default is 30. Set to 0 for no override.
/// </summary>
[JsonProperty("timeout", DefaultValueHandling = DefaultValueHandling.Ignore)]
public int? Timeout { get; set; }
}

public partial class LaunchOptions : BaseOptions
{
#region Public Properties for Serialization
Expand Down
95 changes: 94 additions & 1 deletion src/MICore/LaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ static internal PipeLaunchOptions CreateFromJson(JObject parsedOptions)
quoteArgs = platformSpecificTransportOptions.QuoteArgs ?? quoteArgs;
}

Json.LaunchOptions.BaseOptions baseOptions = Json.LaunchOptions.LaunchOptionHelpers.GetLaunchOrAttachOptions(parsedOptions);

PipeLaunchOptions pipeOptions = new PipeLaunchOptions(
pipePath: pipeProgram,
pipeArguments: EnsurePipeArguments(pipeArgs, debuggerPath, gdbPathDefault, quoteArgs),
Expand All @@ -145,7 +147,6 @@ static internal PipeLaunchOptions CreateFromJson(JObject parsedOptions)
pipeEnvironment: GetEnvironmentEntries(pipeEnv)
);

Json.LaunchOptions.BaseOptions baseOptions = Json.LaunchOptions.LaunchOptionHelpers.GetLaunchOrAttachOptions(parsedOptions);
pipeOptions.InitializeCommonOptions(baseOptions);
if (baseOptions is Json.LaunchOptions.LaunchOptions)
{
Expand Down Expand Up @@ -300,6 +301,12 @@ public EnvironmentEntry(Json.LaunchOptions.Environment jsonEntry)
this.Value = jsonEntry.Value;
}

public EnvironmentEntry(string name, string value)
{
this.Name = name;
this.Value = value;
}

/// <summary>
/// [Required] Name of the environment variable
/// </summary>
Expand Down Expand Up @@ -805,6 +812,12 @@ public UnixShellPortLaunchOptions(string startRemoteDebuggerCommand,
this.InitializeCommonOptions(baseLaunchOptions);
this.BaseOptions = baseLaunchOptions;
}

string prefix = GetDebuginfodEnvironmentPrefix();
if (!string.IsNullOrEmpty(prefix))
{
this.StartRemoteDebuggerCommand = prefix + this.StartRemoteDebuggerCommand;
}
}
}

Expand Down Expand Up @@ -1211,6 +1224,81 @@ public UnknownBreakpointHandling UnknownBreakpointHandling
}
}

private bool _enableDebuginfod = true;

/// <summary>
/// If true (default), GDB's debuginfod support is enabled.
/// </summary>
public bool EnableDebuginfod
{
get { return _enableDebuginfod; }
set
{
VerifyCanModifyProperty(nameof(EnableDebuginfod));
_enableDebuginfod = value;
}
}

private int _debuginfodTimeout = 30;

/// <summary>
/// The timeout in seconds for debuginfod requests. Default is 30. Set to 0 for no override.
/// </summary>
public int DebuginfodTimeout
{
get { return _debuginfodTimeout; }
set
{
VerifyCanModifyProperty(nameof(DebuginfodTimeout));
_debuginfodTimeout = value;
}
}

/// <summary>
/// Returns environment entries to configure debuginfod on the GDB process.
/// </summary>
public List<EnvironmentEntry> GetDebuginfodEnvironmentEntries()
{
var entries = new List<EnvironmentEntry>();
if (DebuggerMIMode != MIMode.Gdb)
return entries;

if (EnableDebuginfod)
{
if (DebuginfodTimeout > 0)
{
string timeoutStr = DebuginfodTimeout.ToString(System.Globalization.CultureInfo.InvariantCulture);
entries.Add(new EnvironmentEntry("DEBUGINFOD_TIMEOUT", timeoutStr));
entries.Add(new EnvironmentEntry("DEBUGINFOD_MAXTIME", timeoutStr));
}
}
else
{
entries.Add(new EnvironmentEntry("DEBUGINFOD_URLS", ""));
}

return entries;
}

/// <summary>
/// Returns an 'env' command prefix for debuginfod settings, for use in shell-based remote commands.
/// Returns empty string if no env vars are needed.
/// </summary>
public string GetDebuginfodEnvironmentPrefix()
{
var entries = GetDebuginfodEnvironmentEntries();
if (entries.Count == 0)
return string.Empty;

var sb = new StringBuilder();
sb.Append("env ");
foreach (var entry in entries)
{
sb.AppendFormat(CultureInfo.InvariantCulture, "{0}={1} ", entry.Name, entry.Value);
}
return sb.ToString();
}

public string GetOptionsString()
{
try
Expand Down Expand Up @@ -1824,6 +1912,9 @@ protected void InitializeCommonOptions(Json.LaunchOptions.BaseOptions options)
}

this.UnknownBreakpointHandling = options.UnknownBreakpointHandling ?? UnknownBreakpointHandling.Throw;
this.EnableDebuginfod = options.Debuginfod?.Enabled ?? true;
int debuginfodTimeout = options.Debuginfod?.Timeout ?? 30;
this.DebuginfodTimeout = debuginfodTimeout >= 0 ? debuginfodTimeout : 30;
}

protected void InitializeCommonOptions(Xml.LaunchOptions.BaseLaunchOptions source)
Expand Down Expand Up @@ -1855,6 +1946,8 @@ protected void InitializeCommonOptions(Xml.LaunchOptions.BaseLaunchOptions sourc

this.ShowDisplayString = source.ShowDisplayString;
this.WaitDynamicLibLoad = source.WaitDynamicLibLoad;
this.EnableDebuginfod = source.EnableDebuginfod;
this.DebuginfodTimeout = source.DebuginfodTimeout >= 0 ? source.DebuginfodTimeout : 30;

this.SetupCommands = LaunchCommand.CreateCollection(source.SetupCommands);
this.PostRemoteConnectCommands = LaunchCommand.CreateCollection(source.PostRemoteConnectCommands);
Expand Down
23 changes: 23 additions & 0 deletions src/MICore/LaunchOptions.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,29 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableDebuginfod" type="xs:boolean" use="optional" default="true">
<xs:annotation>
<xs:documentation>
If true (default), GDB's debuginfod support is enabled, allowing automatic downloading of debug symbols.
Set to false to disable debuginfod, which can prevent GDB from hanging when debuginfod servers are unavailable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DebuginfodTimeout" use="optional" default="30">
<xs:annotation>
<xs:documentation>
The timeout in seconds for debuginfod server requests. Default is 30. Only applies when EnableDebuginfod is true.
A value of 0 means no timeout override is applied (GDB/libdebuginfod defaults are used).
This sets the DEBUGINFOD_TIMEOUT and DEBUGINFOD_MAXTIME environment variables on the GDB process.
Applies to local, runInTerminal, and SSH attach transports. This setting is not applied for pipeTransport; set DEBUGINFOD_TIMEOUT and DEBUGINFOD_MAXTIME in the debugger's environment manually.
</xs:documentation>
Comment thread
WardenGnaw marked this conversation as resolved.
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:element name="LocalLaunchOptions">
<xs:annotation>
Expand Down
36 changes: 36 additions & 0 deletions src/MICore/LaunchOptions.xsd.types.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MICore/Transports/LocalTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public override void InitStreams(LaunchOptions options, out StreamReader reader,
proc.StartInfo.SetEnvironmentVariable("PATH", path);
}

foreach (var entry in options.GetDebuginfodEnvironmentEntries())
{
proc.StartInfo.SetEnvironmentVariable(entry.Name, entry.Value);
}

// Allow to execute custom commands before launching debugger.
// For ex., instructing GDB not to break for certain signals
if (options.DebuggerMIMode == MIMode.Gdb && !string.IsNullOrWhiteSpace(options.WorkingDirectory))
Expand Down
3 changes: 2 additions & 1 deletion src/MICore/Transports/RunInTerminalTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ public override async void Init(ITransportCallback transportCallback, LaunchOpti
}

// Do not pass the launchOptions Environment entries as those are used for the debuggee only.
RunInTerminalLauncher launcher = new RunInTerminalLauncher(windowtitle, new List<EnvironmentEntry>(0).AsReadOnly());
var debuggerEnv = options.GetDebuginfodEnvironmentEntries().AsReadOnly();
RunInTerminalLauncher launcher = new RunInTerminalLauncher(windowtitle, debuggerEnv);

launcher.Launch(
cmdArgs,
Expand Down
5 changes: 4 additions & 1 deletion src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,10 @@ private async Task<List<LaunchCommand>> GetInitializeCommands()
if (_launchOptions.DebuggerMIMode == MIMode.Gdb)
{
commands.Add(new LaunchCommand("-interpreter-exec console \"set pagination off\""));
commands.Add(new LaunchCommand("set debuginfod enabled on", ignoreFailures:true));
if (_launchOptions.EnableDebuginfod)
{
commands.Add(new LaunchCommand("set debuginfod enabled on", ignoreFailures: true));
}
Comment thread
WardenGnaw marked this conversation as resolved.
}

// When user specifies loading directives then the debugger cannot auto load symbols, the MIEngine must intervene at each solib-load event and make a determination
Expand Down
18 changes: 18 additions & 0 deletions src/MIDebugPackage/OpenFolderSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@
"stop"
],
"description": "Controls how breakpoints set externally (usually via raw GDB commands) are handled when hit.\nAllowed values are \"throw\", which acts as if an exception was thrown by the application, and \"stop\", which only pauses the debug session. The default value is \"throw\"."
},
"debuginfod": {
"type": "object",
"description": "Controls GDB's debuginfod behavior for automatic downloading of debug symbols.",
Comment thread
gregg-miskelly marked this conversation as resolved.
"default": { "enabled": true, "timeout": 30 },
"properties": {
"enabled": {
"type": "boolean",
"description": "If true (default), GDB's debuginfod support is enabled. Set to false to disable debuginfod, which can prevent GDB from hanging when debuginfod servers are unavailable.",
"default": true
},
"timeout": {
"type": "integer",
"description": "The timeout in seconds for debuginfod server requests. Default is 30. Set to 0 for no timeout override (GDB defaults apply). Applies to local, runInTerminal, and SSH attach transports. This setting is not applied for pipeTransport; set DEBUGINFOD_TIMEOUT and DEBUGINFOD_MAXTIME in the debugger's environment manually.",
"default": 30,
"minimum": 0
}
}
}
},
"definitions": {
Expand Down
Loading
Loading