Collapse irrelevant subroutines
This commit is contained in:
parent
b87020a5cd
commit
d738314490
2 changed files with 57 additions and 1 deletions
|
@ -3,6 +3,22 @@
|
||||||
Renders the output of computations on a given program as an HTML webpage.
|
Renders the output of computations on a given program as an HTML webpage.
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
(** Generates a fresh unique identifier *)
|
||||||
|
let fresh_uuid =
|
||||||
|
let next = ref 0 in
|
||||||
|
fun () ->
|
||||||
|
let out = !next in
|
||||||
|
incr next ; out
|
||||||
|
|
||||||
|
(** Checks whether a submethod is relevant to show, or whether it should be
|
||||||
|
hidden by default. *)
|
||||||
|
let is_sub_relevant sub = Renderer.AnnotAsm.(
|
||||||
|
List.exists
|
||||||
|
(fun instr -> instr.instr_annot.Renderer.events <> [])
|
||||||
|
sub.sub_asm
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
(** Box `AnnotAsm.asm_info_t` as a Jingoo tvalue *)
|
(** Box `AnnotAsm.asm_info_t` as a Jingoo tvalue *)
|
||||||
let render_prog_box annotated_prog = Jingoo.Jg_types.(Renderer.AnnotAsm.(
|
let render_prog_box annotated_prog = Jingoo.Jg_types.(Renderer.AnnotAsm.(
|
||||||
let render_addr addr = (Format.sprintf "%04x" addr) in
|
let render_addr addr = (Format.sprintf "%04x" addr) in
|
||||||
|
@ -11,6 +27,10 @@ let render_prog_box annotated_prog = Jingoo.Jg_types.(Renderer.AnnotAsm.(
|
||||||
("sub_section", box_string render_sub.sub_section);
|
("sub_section", box_string render_sub.sub_section);
|
||||||
("sub_name", box_string render_sub.sub_name);
|
("sub_name", box_string render_sub.sub_name);
|
||||||
("sub_addr", box_string (Format.sprintf "%016x" render_sub.sub_addr));
|
("sub_addr", box_string (Format.sprintf "%016x" render_sub.sub_addr));
|
||||||
|
("sub_uuid", box_int @@ fresh_uuid ());
|
||||||
|
("sub_relevant", box_int @@ (match is_sub_relevant render_sub with
|
||||||
|
| true -> 1
|
||||||
|
| false -> 0));
|
||||||
("sub_asm", List.map (fun row -> [
|
("sub_asm", List.map (fun row -> [
|
||||||
("instr_addr", box_string (render_addr row.instr_addr));
|
("instr_addr", box_string (render_addr row.instr_addr));
|
||||||
("instr_bytes", box_string (
|
("instr_bytes", box_string (
|
||||||
|
|
|
@ -28,6 +28,17 @@
|
||||||
.subroutine {
|
.subroutine {
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sub_collapser {
|
||||||
|
background-color: #8c8c8c;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
border-radius: 50%;
|
||||||
|
text-align: center;
|
||||||
|
display: inline-block;
|
||||||
|
width: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.sub_body {
|
.sub_body {
|
||||||
margin-left: 4ex;
|
margin-left: 4ex;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +81,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggle_visibility(id) {
|
||||||
|
var e = document.getElementById(id);
|
||||||
|
var label = document.getElementById(id + "_collapser");
|
||||||
|
|
||||||
|
if(e.style.display == 'none') {
|
||||||
|
label.innerHTML = label.innerHTML.replace("+","-");
|
||||||
|
e.style.display = 'block';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
label.innerHTML = label.innerHTML.replace("-","+");
|
||||||
|
e.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="prog_container">
|
<div class="prog_container">
|
||||||
|
@ -79,11 +106,17 @@
|
||||||
{% for subroutine in prog.prog %}
|
{% for subroutine in prog.prog %}
|
||||||
<div class="subroutine">
|
<div class="subroutine">
|
||||||
<div class="sub_headline">
|
<div class="sub_headline">
|
||||||
|
<span class="sub_collapser"
|
||||||
|
id="sub_body_{{subroutine.sub_uuid}}_collapser"
|
||||||
|
onclick="toggle_visibility('sub_body_{{ subroutine.sub_uuid }}')"
|
||||||
|
>
|
||||||
|
-
|
||||||
|
</span>
|
||||||
<span class="addr">{{ subroutine.sub_addr }}</span>
|
<span class="addr">{{ subroutine.sub_addr }}</span>
|
||||||
<span class="sub_section">[{{ subroutine.sub_section }}]</span>
|
<span class="sub_section">[{{ subroutine.sub_section }}]</span>
|
||||||
<span class="sub_name"><{{ subroutine.sub_name }}></span>:
|
<span class="sub_name"><{{ subroutine.sub_name }}></span>:
|
||||||
</div>
|
</div>
|
||||||
<div class="sub_body">
|
<div class="sub_body" id="sub_body_{{ subroutine.sub_uuid }}">
|
||||||
{% for row in subroutine.sub_asm %}
|
{% for row in subroutine.sub_asm %}
|
||||||
{% for event in row.instr_events %}
|
{% for event in row.instr_events %}
|
||||||
{% if event.typ == "start" %}
|
{% if event.typ == "start" %}
|
||||||
|
@ -106,6 +139,9 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if not subroutine.sub_relevant %}
|
||||||
|
<script>toggle_visibility('sub_body_{{ subroutine.sub_uuid }}');</script>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue