Skip to content
Snippets Groups Projects
Commit 4761976f authored by Maxime Jacquemin's avatar Maxime Jacquemin Committed by David Bühler
Browse files

[ivette] Better statement identification in the Eva component

parent 30d392f8
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ function ProbeEditor() { ...@@ -50,7 +50,7 @@ function ProbeEditor() {
if (!probe || !probe.code) return null; if (!probe || !probe.code) return null;
const { label } = probe; const { label } = probe;
const { code } = probe; const { code } = probe;
const { stmt } = probe; const { stmt, fct, marker } = probe;
const { rank } = probe; const { rank } = probe;
const byCS = probe.byCallstacks; const byCS = probe.byCallstacks;
const stacks = model.getStacks(probe); const stacks = model.getStacks(probe);
...@@ -65,7 +65,7 @@ function ProbeEditor() { ...@@ -65,7 +65,7 @@ function ProbeEditor() {
<div className="eva-probeinfo-code"> <div className="eva-probeinfo-code">
<SizedArea cols={cols} rows={rows}>{code}</SizedArea> <SizedArea cols={cols} rows={rows}>{code}</SizedArea>
</div> </div>
<Code><Stmt stmt={stmt} rank={rank} /></Code> <Code><Stmt stmt={stmt} rank={rank} fct={fct} marker={marker} /></Code>
<IconButton <IconButton
icon="ITEMS.LIST" icon="ITEMS.LIST"
className="eva-probeinfo-button" className="eva-probeinfo-button"
......
...@@ -30,6 +30,9 @@ import { classes } from 'dome/misc/utils'; ...@@ -30,6 +30,9 @@ import { classes } from 'dome/misc/utils';
import { Hpack, Vpack } from 'dome/layout/boxes'; import { Hpack, Vpack } from 'dome/layout/boxes';
import { Code, Cell } from 'dome/controls/labels'; import { Code, Cell } from 'dome/controls/labels';
import * as States from 'frama-c/states'; import * as States from 'frama-c/states';
import * as Ast from 'frama-c/api/kernel/ast';
import { readFile } from 'dome/system';
import * as Dome from 'dome';
// Locals // Locals
import { EvaAlarm } from './cells'; import { EvaAlarm } from './cells';
...@@ -43,15 +46,25 @@ import { useModel } from './model'; ...@@ -43,15 +46,25 @@ import { useModel } from './model';
interface StmtProps { interface StmtProps {
stmt?: string; stmt?: string;
rank?: number; rank?: number;
fct: string;
marker: Ast.marker;
} }
export function Stmt(props: StmtProps) { export function Stmt(props: StmtProps) {
const { rank, stmt } = props; const { rank, stmt, fct, marker } = props;
const markersInfo = States.useSyncArray(Ast.markerInfo);
const line = markersInfo.getData(marker)?.sloc?.line;
const file = markersInfo.getData(marker)?.sloc?.file;
const read = () => file ? readFile(file) : Promise.reject();
const text = React.useMemo(read, [file]);
const { result } = Dome.usePromise(text);
const allLines = result?.split(/\r\n|\n/);
const title = allLines ? (line ? `Stmt: ${allLines[line - 1]}` : '') : '' ;
if (rank === undefined || !stmt) return null; if (rank === undefined || !stmt) return null;
const title = `Stmt at global rank ${rank} (internal id: ${stmt})`; // const title = `Stmt at global rank ${rank} (internal id: ${stmt})`;
return ( return (
<span className="dome-text-cell eva-stmt" title={title}> <span className="dome-text-cell eva-stmt" title={title}>
@S{rank} @{fct}:{line}
</span> </span>
); );
} }
...@@ -125,7 +138,7 @@ export function StackInfos() { ...@@ -125,7 +138,7 @@ export function StackInfos() {
onDoubleClick={onDoubleClick} onDoubleClick={onDoubleClick}
> >
{caller} {caller}
<Stmt stmt={stmt} rank={rank} /> <Stmt stmt={stmt} rank={rank} fct={caller} marker={stmt} />
</Cell> </Cell>
); );
}; };
......
...@@ -107,7 +107,7 @@ function TableCell(props: TableCellProps) { ...@@ -107,7 +107,7 @@ function TableCell(props: TableCellProps) {
const maxWidth = CELLPADDING + WSIZER.dimension(probe.maxCols); const maxWidth = CELLPADDING + WSIZER.dimension(probe.maxCols);
const style = { width: minWidth, maxWidth }; const style = { width: minWidth, maxWidth };
let contents: React.ReactNode = props.probe.marker; let contents: React.ReactNode = props.probe.marker;
const { transient } = probe; const { transient, marker } = probe;
const focused = model.getFocused(); const focused = model.getFocused();
const isFocused = focused === probe; const isFocused = focused === probe;
...@@ -118,12 +118,12 @@ function TableCell(props: TableCellProps) { ...@@ -118,12 +118,12 @@ function TableCell(props: TableCellProps) {
if (transient) { if (transient) {
contents = <span className="dome-text-label">« Probe »</span>; contents = <span className="dome-text-label">« Probe »</span>;
} else { } else {
const { stmt, rank, code, label } = probe; const { stmt, rank, code, label, fct } = probe;
const textClass = label ? 'dome-text-label' : 'dome-text-cell'; const textClass = label ? 'dome-text-label' : 'dome-text-cell';
contents = ( contents = (
<> <>
<span className={textClass}>{label ?? code}</span> <span className={textClass}>{label ?? code}</span>
<Stmt stmt={stmt} rank={rank} /> <Stmt stmt={stmt} rank={rank} fct={fct} marker={marker} />
</> </>
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment