From 93faa9a36f83fdff0b5f8b24390bdff1885e3828 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 23 Apr 2012 14:44:28 +0200 Subject: [PATCH] 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: ... Fixes #190. --- ports/run/debug_nitpicker.run | 5 ++++- ports/run/gdb_monitor.run | 5 ++++- ports/run/gdb_monitor_interactive.run | 5 ++++- ports/run/gdb_monitor_target_config.run | 1 + ports/src/app/gdb_monitor/main.cc | 19 +++++++++++++++++-- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ports/run/debug_nitpicker.run b/ports/run/debug_nitpicker.run index ba8f495629..b1113c4468 100644 --- a/ports/run/debug_nitpicker.run +++ b/ports/run/debug_nitpicker.run @@ -63,7 +63,10 @@ set config { - + + + + diff --git a/ports/run/gdb_monitor.run b/ports/run/gdb_monitor.run index 05104298d8..c5e73328a0 100644 --- a/ports/run/gdb_monitor.run +++ b/ports/run/gdb_monitor.run @@ -59,7 +59,10 @@ set config { - + + + + } diff --git a/ports/run/gdb_monitor_interactive.run b/ports/run/gdb_monitor_interactive.run index 096cd25d7d..e367b746ab 100644 --- a/ports/run/gdb_monitor_interactive.run +++ b/ports/run/gdb_monitor_interactive.run @@ -53,7 +53,10 @@ set config { - + + + + } diff --git a/ports/run/gdb_monitor_target_config.run b/ports/run/gdb_monitor_target_config.run index 9dee06d983..75ac1e2a68 100644 --- a/ports/run/gdb_monitor_target_config.run +++ b/ports/run/gdb_monitor_target_config.run @@ -58,6 +58,7 @@ set config { + diff --git a/ports/src/app/gdb_monitor/main.cc b/ports/src/app/gdb_monitor/main.cc index 13891388b5..eebd7a82b0 100644 --- a/ports/src/app/gdb_monitor/main.cc +++ b/ports/src/app/gdb_monitor/main.cc @@ -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 config node"); + return -1; + } + + Number_of_bytes ram_quota = env()->ram_session()->avail() - preserved_ram_quota; /* start the application */ char *unique_name = filename;