Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce76ae1

Browse files
Fix debug tracing error with magic extents (#25726)
Co-authored-by: Patrick Meinecke <SeeminglyScience@users.noreply.github.com>
1 parentc6329dd commitce76ae1

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

‎src/System.Management.Automation/engine/debugger/debugger.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,16 @@ private List<Breakpoint> TriggerBreakpoints(List<Breakpoint> breakpoints)
15361536

15371537
internalvoidOnSequencePointHit(FunctionContextfunctionContext)
15381538
{
1539-
if(_context.ShouldTraceStatement&&!_callStack.Last().IsFrameHidden&&!functionContext._debuggerStepThrough)
1539+
// TraceLine uses ColumnNumber and expects it to be 1 based. For
1540+
// extents added by the engine and not user code the value can be
1541+
// set to 0 causing an exception. This skips those types of extents
1542+
// as tracing them wouldn't be useful for the end user anyway.
1543+
if(_context.ShouldTraceStatement&&
1544+
!_callStack.Last().IsFrameHidden&&
1545+
!functionContext._debuggerStepThrough&&
1546+
functionContext.CurrentPositionis notEmptyScriptExtent&&
1547+
(functionContext.CurrentPositionisInternalScriptExtent||
1548+
functionContext.CurrentPosition.StartColumnNumber>0))
15401549
{
15411550
TraceLine(functionContext.CurrentPosition);
15421551
}

‎test/powershell/Modules/Microsoft.PowerShell.Core/Set-PSDebug.Tests.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,16 @@ Describe "Set-PSDebug" -Tags "CI" {
1515
It"Should be able to set strict" {
1616
{Set-PSDebug-Strict }| Should-Not-Throw
1717
}
18+
19+
It"Should skip magic extents created by pwsh" {
20+
classClassWithDefaultCtor {
21+
MyMethod() { }
22+
}
23+
24+
{
25+
Set-PSDebug-Trace1
26+
[ClassWithDefaultCtor]::new()
27+
}| Should-Not-Throw
28+
}
1829
}
1930
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp