Skip to content
Snippets Groups Projects
Commit cb17bb52 authored by David Bühler's avatar David Bühler
Browse files

Merge branch 'feature/ivette/pointed_value' into 'master'

[ivette] Display lvalues through pointers and pretty offsetmaps

See merge request frama-c/frama-c!3436
parents ea345863 c25ae7bb
No related branches found
No related tags found
No related merge requests found
...@@ -176,4 +176,27 @@ export const getValues: Server.GetRequest< ...@@ -176,4 +176,27 @@ export const getValues: Server.GetRequest<
alarms: [ "True" | "False" | "Unknown", string ][] } alarms: [ "True" | "False" | "Unknown", string ][] }
>= getValues_internal; >= getValues_internal;
const getPointedLvalues_internal: Server.GetRequest<
{ callstack?: callstack, pointer: marker },
{ lvalues?: [ string, marker ][] }
> = {
kind: Server.RqKind.GET,
name: 'plugins.eva.values.getPointedLvalues',
input: Json.jObject({ callstack: jCallstack, pointer: jMarkerSafe,}),
output: Json.jObject({
lvalues: Json.jList(
Json.jTry(
Json.jPair(
Json.jFail(Json.jString,'String expected'),
jMarkerSafe,
))),
}),
signals: [],
};
/** Pointed lvalues for the given marker */
export const getPointedLvalues: Server.GetRequest<
{ callstack?: callstack, pointer: marker },
{ lvalues?: [ string, marker ][] }
>= getPointedLvalues_internal;
/* ------------------------------------- */ /* ------------------------------------- */
...@@ -92,6 +92,17 @@ export class Model implements ModelCallbacks { ...@@ -92,6 +92,17 @@ export class Model implements ModelCallbacks {
return undefined; return undefined;
} }
addProbe(location: States.Location) {
const { fct, marker } = location;
if (fct && marker) {
const probe = new Probe(this, fct, marker);
probe.setPersistent();
probe.requestProbeInfo();
this.probes.set(marker, probe);
this.forceLayout();
}
}
getStacks(p: Probe | undefined): Values.callstack[] { getStacks(p: Probe | undefined): Values.callstack[] {
return p ? this.stacks.getStacks(p.marker) : []; return p ? this.stacks.getStacks(p.marker) : [];
} }
......
...@@ -109,7 +109,7 @@ export class FontSizer { ...@@ -109,7 +109,7 @@ export class FontSizer {
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
export const WSIZER = new FontSizer(7, 6); export const WSIZER = new FontSizer(7, 6);
export const HSIZER = new FontSizer(14, 6); export const HSIZER = new FontSizer(15, 6);
export interface SizedAreaProps { export interface SizedAreaProps {
cols: number; cols: number;
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
// React & Dome // React & Dome
import React from 'react'; import React from 'react';
import * as Dome from 'dome'; import * as Dome from 'dome';
import * as Server from 'frama-c/server';
import * as Values from 'frama-c/api/plugins/eva/values';
import { classes } from 'dome/misc/utils'; import { classes } from 'dome/misc/utils';
import { VariableSizeList } from 'react-window'; import { VariableSizeList } from 'react-window';
import { Hpack, Filler } from 'dome/layout/boxes'; import { Hpack, Filler } from 'dome/layout/boxes';
...@@ -49,6 +51,8 @@ import { Callsite } from './stacks'; ...@@ -49,6 +51,8 @@ import { Callsite } from './stacks';
import { Stmt } from './valueinfos'; import { Stmt } from './valueinfos';
import './style.css'; import './style.css';
const D = new Dome.Debug('Source Code');
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- Cell Diffs // --- Cell Diffs
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -177,12 +181,31 @@ function TableCell(props: TableCellProps) { ...@@ -177,12 +181,31 @@ function TableCell(props: TableCellProps) {
probe.setPersistent(); probe.setPersistent();
if (probe.zoomable) probe.setZoomed(!probe.zoomed); if (probe.zoomable) probe.setZoomed(!probe.zoomed);
}; };
async function onContextMenu() {
Server
.send(Values.getPointedLvalues, { pointer: marker, callstack })
.then((r) => {
const lvalues = r.lvalues ?? [];
const items: Dome.PopupMenuItem[] = lvalues.map((lval) => {
const [text, lvalMarker] = lval;
const label = `Display values for ${text}`;
const location = { fct: probe.fct, marker: lvalMarker };
const onItemClick = () => model.addProbe(location);
return { label, onClick: onItemClick };
});
if (items.length > 0) Dome.popupMenu(items);
})
.catch((err) => D.error(`Fail to recover pointed lvalues: ${err}`));
}
return ( return (
<div <div
className={className} className={className}
style={style} style={style}
onClick={onClick} onClick={onClick}
onDoubleClick={onDoubleClick} onDoubleClick={onDoubleClick}
onContextMenu={onContextMenu}
> >
{contents} {contents}
</div> </div>
......
...@@ -140,6 +140,10 @@ module Bound_Lattice ...@@ -140,6 +140,10 @@ module Bound_Lattice
let is_included = is_included Lattice.is_included let is_included = is_included Lattice.is_included
end end
let to_option = function
| `Bottom -> None
| `Value v -> Some v
let to_list = function let to_list = function
| `Bottom -> [] | `Bottom -> []
| `Value v -> [v] | `Value v -> [v]
......
...@@ -70,6 +70,7 @@ module Bound_Lattice ...@@ -70,6 +70,7 @@ module Bound_Lattice
the empty list is the bottom case. *) the empty list is the bottom case. *)
(** Conversion functions. *) (** Conversion functions. *)
val to_option : 'a or_bottom -> 'a option
val to_list: 'a or_bottom -> 'a list val to_list: 'a or_bottom -> 'a list
val bot_of_list: 'a list -> 'a list or_bottom val bot_of_list: 'a list -> 'a list or_bottom
val list_of_bot: 'a list or_bottom -> 'a list val list_of_bot: 'a list or_bottom -> 'a list
......
...@@ -188,6 +188,10 @@ let iter f = function ...@@ -188,6 +188,10 @@ let iter f = function
| Just m -> M.iter f m | Just m -> M.iter f m
| AllBut _ -> assert false | AllBut _ -> assert false
let fold f acc = function
| Just m -> M.fold f m acc
| AllBut _ -> assert false
let exists test ~default = function let exists test ~default = function
| Just m -> M.exists test m || default True | Just m -> M.exists test m || default True
| AllBut m -> M.exists test m || default Unknown | AllBut m -> M.exists test m || default Unknown
......
...@@ -98,6 +98,7 @@ val exists: (alarm -> status -> bool) -> default:(status -> bool) -> t -> bool ...@@ -98,6 +98,7 @@ val exists: (alarm -> status -> bool) -> default:(status -> bool) -> t -> bool
val for_all: (alarm -> status -> bool) -> default:(status -> bool) -> t -> bool val for_all: (alarm -> status -> bool) -> default:(status -> bool) -> t -> bool
val iter: (alarm -> status -> unit) -> t -> unit val iter: (alarm -> status -> unit) -> t -> unit
val fold : (alarm -> status -> 'a -> 'a) -> 'a -> t -> 'a
(** Emits the alarms according to the given warn mode, at the given (** Emits the alarms according to the given warn mode, at the given
instruction. *) instruction. *)
......
This diff is collapsed.
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