Skip to content

Commit

Permalink
Merge branch 'main' into feat-better-runtime-error-handling-99
Browse files Browse the repository at this point in the history
  • Loading branch information
saimeunt authored Mar 22, 2024
2 parents f030157 + cd88fd8 commit 494148d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions components/Tracer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@ export interface TraceEntry {
fp: number
}

export interface CallstackEntry {
fp: number
call_pc: number | null
ret_pc: number | null
fn_name: string | null
}

export type SierraVariables = { [key: string]: Array<string> }

export interface TracerData {
pcInstMap: { [key: string]: Instruction }
trace: TraceEntry[]
callstack: CallstackEntry[][]
memory: { [key: string]: string }
pcToInstIndexesMap: { [key: string]: number }
entryToSierraVarsMap: { [key: string]: SierraVariables }
Expand Down Expand Up @@ -67,6 +75,7 @@ export const Tracer = ({ mainHeight }: TracerProps) => {
const trace = tracerData?.trace
const currentTraceEntry = tracerData?.trace[executionTraceStepNumber]
const errorTraceEntry = tracerData?.trace.at(-1)
const currentCallstackEntry = tracerData?.callstack[executionTraceStepNumber]

const [selectedConsoleTab, setSelectedConsoleTab] = useState<IConsoleTab>(
IConsoleTab.Console,
Expand Down Expand Up @@ -245,6 +254,7 @@ export const Tracer = ({ mainHeight }: TracerProps) => {
trace={trace}
currentTraceEntry={currentTraceEntry}
executionTraceStepNumber={executionTraceStepNumber}
currentCallstackEntry={currentCallstackEntry}
handleRegisterPointerClick={handleRegisterPointerClick}
/>
)}
Expand All @@ -257,11 +267,13 @@ export const Tracer = ({ mainHeight }: TracerProps) => {
function DebugInfoTab({
trace,
currentTraceEntry,
currentCallstackEntry,
executionTraceStepNumber,
handleRegisterPointerClick,
}: {
trace: TraceEntry[] | undefined
currentTraceEntry: TraceEntry | undefined
currentCallstackEntry?: CallstackEntry[]
executionTraceStepNumber: number
handleRegisterPointerClick: (num: number) => void
}) {
Expand Down Expand Up @@ -317,6 +329,36 @@ function DebugInfoTab({
</dd>
</div>
</div>
<div>
<dt className="mb-1 text-gray-500 dark:text-gray-400 font-medium uppercase">
Callstack
</dt>
<dd className="font-mono mb-2">
<table className="w-full font-mono text-tiny border border-gray-300 dark:border-black-500">
<thead>
<tr className="text-left sticky top-0 bg-gray-50 dark:bg-black-600 text-gray-400 dark:text-gray-600 border-b border-gray-300 dark:border-black-500">
<th className="py-1 px-2 font-thin">FP</th>
<th className="py-1 px-2 font-thin">CALL PC</th>
<th className="py-1 px-2 font-thin">RET PC</th>
<th className="py-1 px-2 font-thin">FN NAME</th>
</tr>
</thead>
<tbody>
{currentCallstackEntry?.map((callstackEntry, index) => (
<tr
key={index}
className="relative border-b border-gray-300 dark:border-black-500 text-gray-400 dark:text-gray-600"
>
<td className="py-1 px-2">{callstackEntry.fp}</td>
<td className="py-1 px-2">{callstackEntry.call_pc}</td>
<td className="py-1 px-2">{callstackEntry.ret_pc}</td>
<td className="py-1 px-2">{callstackEntry.fn_name}</td>
</tr>
))}
</tbody>
</table>
</dd>
</div>
</dl>
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions context/cairoVMApiContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export const CairoVMApiProvider: React.FC<PropsWithChildren> = ({
memory: data.tracer_data.memory,
pcInstMap: data.tracer_data.pc_inst_map,
trace: data.tracer_data.trace,
callstack: data.tracer_data.callstack,
pcToInstIndexesMap: data.tracer_data.pc_to_inst_indexes_map,
entryToSierraVarsMap: data.tracer_data.trace_entries_to_sierra_vars,
})
Expand Down

0 comments on commit 494148d

Please sign in to comment.