Skip to content

Commit 07a8f4b

Browse files
authored
Merge pull request #1 from crtdll/patch-1
Added stracktrace->vars support
2 parents 645056a + 7eaa9fe commit 07a8f4b

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

frontend/src/components/events/StacktraceViewer.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import IconChevronDown from "~icons/lucide/chevron-down";
33
import IconChevronRight from "~icons/lucide/chevron-right";
44
import Button from "~/components/ui/Button";
55

6+
type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
7+
68
export 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

3336
export 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+
6979
export 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
}}

frontend/src/styles/globals.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,36 @@ label.field-label--sm {
11591159
font-size: 12px;
11601160
}
11611161

1162+
.stacktrace__vars {
1163+
margin: 0 16px 8px;
1164+
padding: 8px 12px;
1165+
border-radius: var(--radius);
1166+
border: 1px solid var(--color-border);
1167+
background: var(--color-surface-1);
1168+
display: grid;
1169+
grid-template-columns: auto 1fr;
1170+
column-gap: 16px;
1171+
row-gap: 4px;
1172+
font-size: 12px;
1173+
line-height: 18px;
1174+
}
1175+
1176+
.stacktrace__vars dt {
1177+
color: var(--color-text-secondary);
1178+
font-weight: 500;
1179+
}
1180+
1181+
.stacktrace__vars dd {
1182+
margin: 0;
1183+
color: var(--color-text-primary);
1184+
overflow-wrap: anywhere;
1185+
}
1186+
1187+
.stacktrace__vars code {
1188+
font-family: var(--font-mono);
1189+
font-size: 12px;
1190+
}
1191+
11621192
/* ===================================================================
11631193
BREADCRUMBS TIMELINE
11641194
=================================================================== */

0 commit comments

Comments
 (0)