Encode ovnievents output for HTML
This commit is contained in:
parent
df0e7b2bd4
commit
68fc8b0eba
@ -8,7 +8,7 @@ Built on Jan 29 2024.
|
|||||||
List of events for the model *nanos6* with identifier **`6`** at version `1.0.0`:
|
List of events for the model *nanos6* with identifier **`6`** at version `1.0.0`:
|
||||||
<dl>
|
<dl>
|
||||||
<dt><a id="6Yc" href="#6Yc"><pre>6Yc+(u32 typeid, str label)</pre></a></dt>
|
<dt><a id="6Yc" href="#6Yc"><pre>6Yc+(u32 typeid, str label)</pre></a></dt>
|
||||||
<dd>creates task type %{typeid} with label "%{label}"</dd>
|
<dd>creates task type %{typeid} with label "%{label}"</dd>
|
||||||
<dt><a id="6Tc" href="#6Tc"><pre>6Tc(u32 taskid, u32 typeid)</pre></a></dt>
|
<dt><a id="6Tc" href="#6Tc"><pre>6Tc(u32 taskid, u32 typeid)</pre></a></dt>
|
||||||
<dd>creates task %{taskid} with type %{typeid}</dd>
|
<dd>creates task %{taskid} with type %{typeid}</dd>
|
||||||
<dt><a id="6Tx" href="#6Tx"><pre>6Tx(u32 taskid)</pre></a></dt>
|
<dt><a id="6Tx" href="#6Tx"><pre>6Tx(u32 taskid)</pre></a></dt>
|
||||||
@ -400,7 +400,7 @@ List of events for the model *ovni* with identifier **`O`** at version `1.0.0`:
|
|||||||
<dt><a id="OAr" href="#OAr"><pre>OAr(i32 cpu, i32 tid)</pre></a></dt>
|
<dt><a id="OAr" href="#OAr"><pre>OAr(i32 cpu, i32 tid)</pre></a></dt>
|
||||||
<dd>changes the affinity of thread %{tid} to CPU %{cpu}</dd>
|
<dd>changes the affinity of thread %{tid} to CPU %{cpu}</dd>
|
||||||
<dt><a id="OAs" href="#OAs"><pre>OAs(i32 cpu)</pre></a></dt>
|
<dt><a id="OAs" href="#OAs"><pre>OAs(i32 cpu)</pre></a></dt>
|
||||||
<dd>switches it's own affinity to the CPU %{cpu}</dd>
|
<dd>switches it's own affinity to the CPU %{cpu}</dd>
|
||||||
<dt><a id="OB." href="#OB."><pre>OB.</pre></a></dt>
|
<dt><a id="OB." href="#OB."><pre>OB.</pre></a></dt>
|
||||||
<dd>emits a burst event to measure latency</dd>
|
<dd>emits a burst event to measure latency</dd>
|
||||||
<dt><a id="OHC" href="#OHC"><pre>OHC(i32 cpu, u64 tag)</pre></a></dt>
|
<dt><a id="OHC" href="#OHC"><pre>OHC(i32 cpu, u64 tag)</pre></a></dt>
|
||||||
@ -498,7 +498,7 @@ List of events for the model *nosv* with identifier **`V`** at version `1.0.0`:
|
|||||||
<dt><a id="VTr" href="#VTr"><pre>VTr(u32 taskid)</pre></a></dt>
|
<dt><a id="VTr" href="#VTr"><pre>VTr(u32 taskid)</pre></a></dt>
|
||||||
<dd>resumes the task %{taskid}</dd>
|
<dd>resumes the task %{taskid}</dd>
|
||||||
<dt><a id="VYc" href="#VYc"><pre>VYc+(u32 typeid, str label)</pre></a></dt>
|
<dt><a id="VYc" href="#VYc"><pre>VYc+(u32 typeid, str label)</pre></a></dt>
|
||||||
<dd>creates task type %{typeid} with label "%{label}"</dd>
|
<dd>creates task type %{typeid} with label "%{label}"</dd>
|
||||||
<dt><a id="VSr" href="#VSr"><pre>VSr</pre></a></dt>
|
<dt><a id="VSr" href="#VSr"><pre>VSr</pre></a></dt>
|
||||||
<dd>receives a task from another thread</dd>
|
<dd>receives a task from another thread</dd>
|
||||||
<dt><a id="VSs" href="#VSs"><pre>VSs</pre></a></dt>
|
<dt><a id="VSs" href="#VSs"><pre>VSs</pre></a></dt>
|
||||||
|
@ -16,19 +16,66 @@
|
|||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
static void
|
static int
|
||||||
|
html_encode(char *dst, int ndst, const char *src)
|
||||||
|
{
|
||||||
|
int j = 0;
|
||||||
|
int nsrc = strlen(src);
|
||||||
|
|
||||||
|
for (int i = 0; i < nsrc; i++) {
|
||||||
|
/* Simple check */
|
||||||
|
if (j + 10 >= ndst) {
|
||||||
|
err("not enough room");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int c = src[i];
|
||||||
|
switch (c) {
|
||||||
|
case '&': strcpy(&dst[j], "&"); j += 5; break;
|
||||||
|
case '"': strcpy(&dst[j], """); j += 6; break;
|
||||||
|
case '\'': strcpy(&dst[j], "'"); j += 6; break;
|
||||||
|
case '<': strcpy(&dst[j], "<"); j += 4; break;
|
||||||
|
case '>': strcpy(&dst[j], ">"); j += 4; break;
|
||||||
|
default: dst[j++] = c; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dst[j] = '\0';
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
print_event(struct model_spec *spec, long i)
|
print_event(struct model_spec *spec, long i)
|
||||||
{
|
{
|
||||||
struct ev_decl *evdecl = &spec->evlist[i];
|
struct ev_decl *evdecl = &spec->evlist[i];
|
||||||
struct ev_spec *evspec = &spec->evspec->alloc[i];
|
struct ev_spec *evspec = &spec->evspec->alloc[i];
|
||||||
|
|
||||||
const char *name = evspec->mcv;
|
char name[16];
|
||||||
|
if (html_encode(name, 16, evspec->mcv) != 0) {
|
||||||
printf("<dt><a id=\"%s\" href=\"#%s\"><pre>%s</pre></a></dt>\n", name, name, evdecl->signature);
|
err("html_encode failed for %s", evspec->mcv);
|
||||||
printf("<dd>%s</dd>\n", evdecl->description);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
char signature[1024];
|
||||||
|
if (html_encode(signature, 1024, evdecl->signature) != 0) {
|
||||||
|
err("html_encode failed for %s", evdecl->signature);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char desc[1024];
|
||||||
|
if (html_encode(desc, 1024, evdecl->description) != 0) {
|
||||||
|
err("html_encode failed for %s", evdecl->description);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("<dt><a id=\"%s\" href=\"#%s\"><pre>%s</pre></a></dt>\n", name, name, signature);
|
||||||
|
printf("<dd>%s</dd>\n", desc);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
print_model(struct model_spec *spec)
|
print_model(struct model_spec *spec)
|
||||||
{
|
{
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -38,9 +85,16 @@ print_model(struct model_spec *spec)
|
|||||||
spec->name, spec->model, spec->version);
|
spec->name, spec->model, spec->version);
|
||||||
|
|
||||||
printf("<dl>\n");
|
printf("<dl>\n");
|
||||||
for (long j = 0; j < spec->evspec->nevents; j++)
|
for (long j = 0; j < spec->evspec->nevents; j++) {
|
||||||
print_event(spec, j);
|
if (print_event(spec, j) != 0) {
|
||||||
|
err("cannot print event %d", j);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("</dl>\n");
|
printf("</dl>\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -54,7 +108,7 @@ main(void)
|
|||||||
/* Register all the models */
|
/* Register all the models */
|
||||||
if (models_register(&model) != 0) {
|
if (models_register(&model) != 0) {
|
||||||
err("failed to register models");
|
err("failed to register models");
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("# Emulator events\n");
|
printf("# Emulator events\n");
|
||||||
@ -66,7 +120,10 @@ main(void)
|
|||||||
if (!model.registered[i])
|
if (!model.registered[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
print_model(model.spec[i]);
|
if (print_model(model.spec[i]) != 0) {
|
||||||
|
err("cannot print model %c events", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user