Config option for GDB monitor RAM preservation

This patch allows to configure the amount of RAM that GDB monitor should
preserve for itself. The configuration syntax looks as follows:

<start name="gdb_monitor">
    <resource name="RAM" quantum="1G"/>
    <config>
        <target name="noux">
        <preserve name="RAM" quantum="2M"/>
        ...
    </config>
</start>

Fixes #190.
This commit is contained in:
Christian Prochaska 2012-04-23 14:44:28 +02:00 committed by Norman Feske
parent 3236395e6a
commit 93faa9a36f
5 changed files with 30 additions and 5 deletions

View File

@ -63,7 +63,10 @@ set config {
<start name="gdb_monitor">
<resource name="RAM" quantum="4M"/>
<provides><service name="Nitpicker"/></provides>
<config><target name="nitpicker"/></config>
<config>
<target name="nitpicker"/>
<preserve name="RAM" quantum="2M"/>
</config>
</start>
<start name="scout">
<resource name="RAM" quantum="32M"/>

View File

@ -59,7 +59,10 @@ set config {
</start>
<start name="gdb_monitor">
<resource name="RAM" quantum="4M"/>
<config> <target name="test-gdb_monitor" /> </config>
<config>
<target name="test-gdb_monitor"/>
<preserve name="RAM" quantum="2M"/>
</config>
</start>
</config>
}

View File

@ -53,7 +53,10 @@ set config {
</start>
<start name="gdb_monitor">
<resource name="RAM" quantum="4M"/>
<config> <target name="test-gdb_monitor" /> </config>
<config>
<target name="test-gdb_monitor"/>
<preserve name="RAM" quantum="2M"/>
</config>
</start>
</config>
}

View File

@ -58,6 +58,7 @@ set config {
<test_config_subnode/>
</config>
</target>
<preserve name="RAM" quantum="2M"/>
</config>
</start>
</config>

View File

@ -65,8 +65,23 @@ int main()
/* extract target node from config file */
Xml_node target_node = config()->xml_node().sub_node("target");
/* reserve some memory for gdb_monitor and give the rest to the child */
Number_of_bytes ram_quota = env()->ram_session()->avail() - 2*1024*1024;
/*
* preserve the configured amount of memory for gdb_monitor and give the
* remainder to the child
*/
Number_of_bytes preserved_ram_quota = 0;
try {
Xml_node preserve_node = config()->xml_node().sub_node("preserve");
if (preserve_node.attribute("name").has_value("RAM"))
preserve_node.attribute("quantum").value(&preserved_ram_quota);
else
throw Xml_node::Exception();
} catch (...) {
PERR("Error: could not find a valid <preserve> config node");
return -1;
}
Number_of_bytes ram_quota = env()->ram_session()->avail() - preserved_ram_quota;
/* start the application */
char *unique_name = filename;