Skip to content
Snippets Groups Projects
Commit 95ddbd6f authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette/eva] show alarms

parent bb3f1dbc
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ import React from 'react'; ...@@ -7,7 +7,7 @@ import React from 'react';
import * as Dome from 'dome'; import * as Dome from 'dome';
import { classes } from 'dome/misc/utils'; import { classes } from 'dome/misc/utils';
import { VariableSizeList } from 'react-window'; import { VariableSizeList } from 'react-window';
import { Vfill, Hpack, Filler } from 'dome/layout/boxes'; import { Vfill, Hpack, Vpack, Filler } from 'dome/layout/boxes';
import { Icon } from 'dome/controls/icons'; import { Icon } from 'dome/controls/icons';
import { Label, Code } from 'dome/controls/labels'; import { Label, Code } from 'dome/controls/labels';
import { IconButton } from 'dome/controls/buttons'; import { IconButton } from 'dome/controls/buttons';
...@@ -26,7 +26,7 @@ import * as Ast from 'frama-c/api/kernel/ast'; ...@@ -26,7 +26,7 @@ import * as Ast from 'frama-c/api/kernel/ast';
// Locals // Locals
import { SizedArea, HSIZER, WSIZER } from './sized'; import { SizedArea, HSIZER, WSIZER } from './sized';
import { Diff } from './diffed'; import { Diff } from './diffed';
import { sizeof, valueAt, diffAfter, diffThen, diffElse } from './cells'; import { sizeof, valueAt, diffAfter, diffThen, diffElse, EvaAlarm } from './cells';
import { Row } from './layout'; import { Row } from './layout';
import { Probe } from './probes'; import { Probe } from './probes';
import { Callsite } from './stacks'; import { Callsite } from './stacks';
...@@ -149,14 +149,44 @@ function ProbeInfos() { ...@@ -149,14 +149,44 @@ function ProbeInfos() {
); );
} }
// --------------------------------------------------------------------------
// --- Alarms Panel
// --------------------------------------------------------------------------
function AlarmsInfo() {
const model = useModel();
const probe = model.getFocused();
if (probe) {
const callstack = model.getCallstack();
const domain =
model.values.getValues(probe.marker, probe.stmt, callstack);
const alarms = domain?.alarms ?? [];
if (alarms.length > 0) {
console.log('ALARMS', alarms);
const renderAlarm = ([status, alarm]: EvaAlarm) => {
const className = `eva-alarm-info eva-alarm-${status}`;
return (
<Code className={className} icon='WARNING'>{alarm}</Code>
);
};
return (
<Vpack className="eva-info">
{alarms.map(renderAlarm)}
</Vpack>
);
}
}
return null;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- Stack Panel // --- Stack Panel
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
function StackInfos() { function StackInfo() {
const model = useModel(); const model = useModel();
const [, setSelection] = States.useSelection(); const [, setSelection] = States.useSelection();
const callstack = model.getCallstack(); const callstack = model.getCalls();
if (callstack.length <= 1) return null; if (callstack.length <= 1) return null;
const makeCallsite = ({ caller, stmt, rank }: Callsite) => { const makeCallsite = ({ caller, stmt, rank }: Callsite) => {
if (!caller || !stmt) return null; if (!caller || !stmt) return null;
...@@ -425,7 +455,8 @@ function ValuesComponent() { ...@@ -425,7 +455,8 @@ function ValuesComponent() {
)} )}
</AutoSizer> </AutoSizer>
</Vfill> </Vfill>
<StackInfos /> <AlarmsInfo />
<StackInfo />
</Vfill> </Vfill>
</> </>
); );
......
...@@ -30,6 +30,7 @@ export interface Row { ...@@ -30,6 +30,7 @@ export interface Row {
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
const PADDING = 2; const PADDING = 2;
const INSET = 1;
const HCROP = 18; const HCROP = 18;
const VCROP = 1; const VCROP = 1;
...@@ -64,7 +65,8 @@ export class LayoutEngine { ...@@ -64,7 +65,8 @@ export class LayoutEngine {
private rows: Row[] = []; private rows: Row[] = [];
crop(zoomed: boolean, s: Size): Size { crop(zoomed: boolean, s: Size): Size {
const cols = zoomed ? s.cols : Math.min(s.cols, this.hcrop); const s_cols = s.cols + INSET;
const cols = zoomed ? s_cols : Math.min(s_cols, this.hcrop);
const rows = zoomed ? s.rows : Math.min(s.rows, this.vcrop); const rows = zoomed ? s.rows : Math.min(s.rows, this.vcrop);
return { return {
cols: Math.max(HCROP, cols), cols: Math.max(HCROP, cols),
......
...@@ -109,7 +109,11 @@ export class Model implements ModelCallbacks { ...@@ -109,7 +109,11 @@ export class Model implements ModelCallbacks {
return cs !== undefined ? cs === row.callstack : false; return cs !== undefined ? cs === row.callstack : false;
} }
getCallstack(): Callsite[] { getCallstack(): Values.callstack | undefined {
return this.callstack;
}
getCalls(): Callsite[] {
const c = this.callstack; const c = this.callstack;
return c === undefined ? [] : this.stacks.getCalls(c); return c === undefined ? [] : this.stacks.getCalls(c);
} }
......
...@@ -144,14 +144,28 @@ ...@@ -144,14 +144,28 @@
.eva-state-Then .eva-diff { background: green; } .eva-state-Then .eva-diff { background: green; }
.eva-state-Else .eva-diff { background: orange; } .eva-state-Else .eva-diff { background: orange; }
/* -------------------------------------------------------------------------- */
/* --- Alarms --- */
/* -------------------------------------------------------------------------- */
.eva-cell-alarms { .eva-cell-alarms {
fill: red; fill: orange;
position: absolute; position: absolute;
top: -1px; top: -1px;
right: 3px; right: 3px;
z-index: 1; z-index: 1;
} }
.eva-alarm-info {
font-size: x-small;
padding: 0px;
margin: 1px;
}
.eva-alarm-True { fill: green; }
.eva-alarm-False { fill: red; }
.eva-alarm-Unknown { fill: darkorange; }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* --- Table Rows Background --- */ /* --- Table Rows Background --- */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
......
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