@@ -35,6 +35,9 @@ $threadDisplay = if ($ThreadId -eq ".") { "current thread" } else { "thread $Thr
3535Write-NexusProgress " Starting stack analysis with source download for $threadDisplay "
3636
3737try {
38+ Write-NexusProgress " Enable source verbosity for $threadDisplay ..."
39+ $stackOutput = Invoke-NexusCommand " .srcnoisy 3"
40+
3841 # Step 1: Get stack with line numbers
3942 Write-NexusProgress " Retrieving stack trace for $threadDisplay ..."
4043 $stackCommand = if ($ThreadId -eq " ." ) { " kL" } else { " ~${ThreadId} kL" }
6467 addresses = @ ()
6568 error = " Thread '$ThreadId ' not found. The thread ID may be invalid or the thread may not exist in this dump file."
6669 suggestion = " Use the '!threads' or '~' command to list available threads, then try again with a valid thread ID."
67- } | ConvertTo-Json
70+ stackTrace = $stackOutput
71+ } | ConvertTo-Json - Depth 10
6872 Write-Output $result
6973 exit 0
7074 }
@@ -99,51 +103,78 @@ try {
99103 sourcesDownloaded = 0
100104 addresses = @ ()
101105 error = " No valid return addresses found in stack trace"
102- } | ConvertTo-Json
106+ stackTrace = $stackOutput
107+ } | ConvertTo-Json - Depth 10
103108 Write-Output $result
104109 exit 0
105110 }
106111
107112 Write-NexusLog " Found $ ( $addresses.Count ) return addresses to process" - Level Information
108113 Write-NexusProgress " Found $ ( $addresses.Count ) return addresses to process"
109114
110- # Step 3: Download sources for each address
115+ # Step 3: Download sources for each address (first pass)
116+ Write-NexusProgress " [$threadDisplay ] Downloading sources for $ ( $addresses.Count ) addresses..."
117+ $processedCount = 0
118+
119+ foreach ($addr in $addresses ) {
120+ $processedCount ++
121+ $percent = [int ](($processedCount / $addresses.Count ) * 100 )
122+ Write-NexusProgress " [$threadDisplay ] Downloading source for address $addr ($processedCount of $ ( $addresses.Count ) , $percent %)"
123+
124+ try {
125+ # First pass: Just download, don't verify yet
126+ $null = Invoke-NexusCommand " lsa $addr "
127+ }
128+ catch {
129+ Write-NexusLog " Failed to execute lsa for address $addr `: $_ " - Level Warning
130+ }
131+ }
132+
133+ # Step 4: Verify downloaded sources (second pass)
134+ Write-NexusProgress " [$threadDisplay ] Verifying downloaded sources..."
111135 $downloadedCount = 0
112136 $failedAddresses = @ ()
113137 $processedCount = 0
114-
138+ $sourceOutputs = @ {} # Collect all lsa outputs
139+
115140 foreach ($addr in $addresses ) {
116141 $processedCount ++
117142 $percent = [int ](($processedCount / $addresses.Count ) * 100 )
118- Write-NexusProgress " [$threadDisplay ] Downloading source for address $addr ($processedCount of $ ( $addresses.Count ) , $percent %)"
119-
143+ Write-NexusProgress " [$threadDisplay ] Verifying source for address $addr ($processedCount of $ ( $addresses.Count ) , $percent %)"
144+
120145 try {
121- $lsaOutput = Invoke-NexusCommand " lsa $addr "
146+ $verifyOutput = Invoke-NexusCommand " lsa $addr "
147+ $sourceOutputs [$addr ] = $verifyOutput
122148
123- # Check if source was actually downloaded
124- if ($lsaOutput -match ' source' -or $lsaOutput -match ' \.c' -or $lsaOutput -match ' \.cpp' -or $lsaOutput -match ' \.h' ) {
149+ # Check if source was found in cache (with .srcnoisy 3, should show "already loaded")
150+ # Also accept if output shows line numbers (source is displayed)
151+ if ($verifyOutput -match ' Found already loaded file:|already loaded' -or
152+ $verifyOutput -match ' ^\s*\d+:' ) {
125153 $downloadedCount ++
154+ Write-NexusLog " [$threadDisplay ] Verified source for address $addr (cached)" - Level Debug
126155 }
127156 else {
128157 $failedAddresses += $addr
158+ Write-NexusLog " [$threadDisplay ] No source found for address $addr " - Level Debug
129159 }
130160 }
131161 catch {
132- Write-Warning " Failed to download source for address $addr `: $_ "
133162 $failedAddresses += $addr
163+ $sourceOutputs [$addr ] = " ERROR: $_ "
164+ Write-NexusLog " Failed to verify source for address $addr `: $_ " - Level Warning
134165 }
135166 }
136167
137- Write-NexusProgress " [$threadDisplay ] Source download complete: $downloadedCount of $ ( $addresses.Count ) sources downloaded "
168+ Write-NexusProgress " [$threadDisplay ] Source download complete: $downloadedCount of $ ( $addresses.Count ) sources verified "
138169
139170 $successRate = [math ]::Round(($downloadedCount / $addresses.Count ) * 100 , 2 )
140- Write-NexusLog " [$threadDisplay ] Source download completed: $downloadedCount /$ ( $addresses.Count ) sources ($successRate % success rate)" - Level Information
171+ Write-NexusLog " [$threadDisplay ] Source download completed: $downloadedCount /$ ( $addresses.Count ) sources verified ($successRate % success rate)" - Level Information
141172
142173 if ($failedAddresses.Count -gt 0 ) {
143174 Write-NexusLog " Failed to download sources for $ ( $failedAddresses.Count ) addresses" - Level Warning
144175 }
145176
146- # Return structured result
177+ # Return structured result with all command outputs
147178 $result = @ {
148179 success = $true
149180 threadId = $ThreadId
@@ -153,8 +184,10 @@ try {
153184 successRate = $successRate
154185 addresses = $addresses
155186 failedAddresses = $failedAddresses
156- message = " Successfully downloaded $downloadedCount of $ ( $addresses.Count ) source files"
157- } | ConvertTo-Json
187+ message = " Successfully downloaded and verified $downloadedCount of $ ( $addresses.Count ) source files"
188+ stackTrace = $stackOutput
189+ sourceOutputs = $sourceOutputs
190+ } | ConvertTo-Json - Depth 10
158191
159192 Write-Output $result
160193 exit 0
0 commit comments