mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-01 15:10:56 +00:00
report_rom: add 'verbose' config attribute
This commit is contained in:
parent
5317cca031
commit
fcf35a0397
@ -22,3 +22,6 @@ client obtains the data from the report client with the label specified in the
|
|||||||
'report' attribute. In the example above, the nitpicker GUI server sends
|
'report' attribute. In the example above, the nitpicker GUI server sends
|
||||||
reports about the pointer position to the report-ROM service. Those reports
|
reports about the pointer position to the report-ROM service. Those reports
|
||||||
are handed out to a window decorator (labeled "decorator") as ROM module.
|
are handed out to a window decorator (labeled "decorator") as ROM module.
|
||||||
|
|
||||||
|
The component can be configured to write all incoming reports to the LOG
|
||||||
|
output by setting the 'verbose' attribute of the '<config>' node to "yes".
|
||||||
|
@ -50,7 +50,16 @@ struct Server::Main
|
|||||||
|
|
||||||
Xml_node rom_config = _rom_config_node();
|
Xml_node rom_config = _rom_config_node();
|
||||||
|
|
||||||
Report::Root report_root = { ep, sliced_heap, rom_registry };
|
bool _verbose_config()
|
||||||
|
{
|
||||||
|
char const *attr = "verbose";
|
||||||
|
return Genode::config()->xml_node().has_attribute(attr)
|
||||||
|
&& Genode::config()->xml_node().attribute(attr).has_value("yes");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool verbose = _verbose_config();
|
||||||
|
|
||||||
|
Report::Root report_root = { ep, sliced_heap, rom_registry, verbose };
|
||||||
Rom ::Root rom_root = { ep, sliced_heap, rom_registry, rom_config};
|
Rom ::Root rom_root = { ep, sliced_heap, rom_registry, rom_config};
|
||||||
|
|
||||||
Main(Entrypoint &ep) : ep(ep)
|
Main(Entrypoint &ep) : ep(ep)
|
||||||
|
@ -39,14 +39,29 @@ struct Report::Session_component : Genode::Rpc_object<Session>, Rom::Writer
|
|||||||
|
|
||||||
Rom::Module &_module;
|
Rom::Module &_module;
|
||||||
|
|
||||||
|
bool &_verbose;
|
||||||
|
|
||||||
|
size_t const _str_line_end(char const * const str, size_t const len)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
for (; str[i] && i < len && str[i] != '\n'; i++);
|
||||||
|
|
||||||
|
/* the newline character belongs to the line */
|
||||||
|
if (str[i] == '\n')
|
||||||
|
i++;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Session_component(Rom::Module::Name const &name, size_t buffer_size,
|
Session_component(Rom::Module::Name const &name, size_t buffer_size,
|
||||||
Rom::Registry_for_writer ®istry)
|
Rom::Registry_for_writer ®istry, bool &verbose)
|
||||||
:
|
:
|
||||||
_registry(registry),
|
_registry(registry),
|
||||||
_ds(Genode::env()->ram_session(), buffer_size),
|
_ds(Genode::env()->ram_session(), buffer_size),
|
||||||
_module(_registry.lookup(*this, name))
|
_module(_registry.lookup(*this, name)),
|
||||||
|
_verbose(verbose)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,10 +77,49 @@ struct Report::Session_component : Genode::Rpc_object<Session>, Rom::Writer
|
|||||||
|
|
||||||
Dataspace_capability dataspace() override { return _ds.cap(); }
|
Dataspace_capability dataspace() override { return _ds.cap(); }
|
||||||
|
|
||||||
void submit(size_t const length) override
|
void submit(size_t length) override
|
||||||
{
|
{
|
||||||
_module.write_content(_ds.local_addr<char>(),
|
length = Genode::min(length, _ds.size());
|
||||||
Genode::min(length, _ds.size()));
|
|
||||||
|
if (_verbose) {
|
||||||
|
|
||||||
|
PLOG("report '%s'", _module.name().string());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We cannot simply print the content of the report dataspace
|
||||||
|
* as one string because we cannot expect the client to null-
|
||||||
|
* terminate the content properly. Therefore, we output the
|
||||||
|
* report line by line while keeping track of the dataspace
|
||||||
|
* size.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* pointer and length of remaining string */
|
||||||
|
char const *str = _ds.local_addr<char>();
|
||||||
|
size_t len = length;
|
||||||
|
|
||||||
|
while (*str && len) {
|
||||||
|
|
||||||
|
size_t const line_len = _str_line_end(str, len);
|
||||||
|
|
||||||
|
if (!line_len)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy line from (untrusted) report dataspace to local
|
||||||
|
* line buffer,
|
||||||
|
*/
|
||||||
|
char line_buf[200];
|
||||||
|
Genode::strncpy(line_buf, str, Genode::min(line_len, sizeof(line_buf)));
|
||||||
|
PLOG(" %s", line_buf);
|
||||||
|
|
||||||
|
str += line_len;
|
||||||
|
len -= line_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
PLOG("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
_module.write_content(_ds.local_addr<char>(), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void response_sigh(Genode::Signal_context_capability) override { }
|
void response_sigh(Genode::Signal_context_capability) override { }
|
||||||
@ -79,6 +133,7 @@ struct Report::Root : Genode::Root_component<Session_component>
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
Rom::Registry_for_writer &_rom_registry;
|
Rom::Registry_for_writer &_rom_registry;
|
||||||
|
bool &_verbose;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -96,17 +151,18 @@ struct Report::Root : Genode::Root_component<Session_component>
|
|||||||
|
|
||||||
return new (md_alloc())
|
return new (md_alloc())
|
||||||
Session_component(Rom::Module::Name(label), buffer_size,
|
Session_component(Rom::Module::Name(label), buffer_size,
|
||||||
_rom_registry);
|
_rom_registry, _verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Root(Server::Entrypoint &ep,
|
Root(Server::Entrypoint &ep,
|
||||||
Genode::Allocator &md_alloc,
|
Genode::Allocator &md_alloc,
|
||||||
Rom::Registry_for_writer &rom_registry)
|
Rom::Registry_for_writer &rom_registry,
|
||||||
|
bool &verbose)
|
||||||
:
|
:
|
||||||
Genode::Root_component<Session_component>(&ep.rpc_ep(), &md_alloc),
|
Genode::Root_component<Session_component>(&ep.rpc_ep(), &md_alloc),
|
||||||
_rom_registry(rom_registry)
|
_rom_registry(rom_registry), _verbose(verbose)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -192,6 +192,8 @@ struct Rom::Module : Module_list::Element
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t size() const { return _size; }
|
size_t size() const { return _size; }
|
||||||
|
|
||||||
|
Name name() const { return _name; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _ROM_MODULE_ */
|
#endif /* _ROM_MODULE_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user