@@ -3,6 +3,8 @@ import IconChevronDown from "~icons/lucide/chevron-down";
33import IconChevronRight from "~icons/lucide/chevron-right" ;
44import Button from "~/components/ui/Button" ;
55
6+ type JsonValue = string | number | boolean | null | JsonValue [ ] | { [ key : string ] : JsonValue } ;
7+
68export interface StackFrame {
79 filename ?: string ;
810 function ?: string ;
@@ -28,6 +30,7 @@ export interface StackFrame {
2830 } ;
2931 addr_mode ?: string ;
3032 trust ?: string ;
33+ vars ?: Record < string , JsonValue > ;
3134}
3235
3336export interface DebugImage {
@@ -66,6 +69,13 @@ function findImage(
6669 return null ;
6770}
6871
72+ function formatVarValue ( value : JsonValue ) : string {
73+ if ( typeof value === "string" )
74+ return value ;
75+
76+ return JSON . stringify ( value , null , 2 ) ;
77+ }
78+
6979export function getFrameName ( frame : StackFrame ) : string {
7080 return frame . function ?? frame . instruction_addr ?? "<anonymous>" ;
7181}
@@ -148,7 +158,8 @@ export default function StacktraceViewer(props: StacktraceViewerProps) {
148158 img ?. arch
149159 ) ;
150160 } ;
151- const isExpandable = ( ) => hasContext ( ) || hasDebugInfo ( ) ;
161+ const hasVars = ( ) => ! ! frame . vars && Object . keys ( frame . vars ) . length > 0 ;
162+ const isExpandable = ( ) => hasContext ( ) || hasDebugInfo ( ) || hasVars ( ) ;
152163 const frameName = ( ) => getFrameName ( frame ) ;
153164 const frameLocation = ( ) => getFrameLocation ( frame ) ;
154165
@@ -274,6 +285,20 @@ export default function StacktraceViewer(props: StacktraceViewerProps) {
274285 </ Show >
275286 </ dl >
276287 </ Show >
288+ < Show when = { isExpanded ( ) && hasVars ( ) } >
289+ < dl class = "stacktrace__vars" >
290+ < For each = { Object . entries ( frame . vars ! ) } >
291+ { ( [ name , value ] ) => (
292+ < >
293+ < dt > { name } </ dt >
294+ < dd >
295+ < pre > { formatVarValue ( value ) } </ pre >
296+ </ dd >
297+ </ >
298+ ) }
299+ </ For >
300+ </ dl >
301+ </ Show >
277302 </ div >
278303 ) ;
279304 } }
0 commit comments