[PATCH] [rom-o-matic] Add options to enable debug

Colin Hogben colin at pythontech.co.uk
Thu Mar 18 09:33:50 EDT 2010


Add options to enable debug output in a subset of modules.
Also fix typo which caused stderr to be lost if compilation failed.

Signed-off-by: Colin Hogben <colin at pythontech.co.uk>
---
 contrib/rom-o-matic/build.php              |    9 +++++-
 contrib/rom-o-matic/doc/debug_aoe.html     |    1 +
 contrib/rom-o-matic/doc/debug_arp.html     |    1 +
 contrib/rom-o-matic/doc/debug_ata.html     |    1 +
 contrib/rom-o-matic/doc/debug_chap.html    |    1 +
 contrib/rom-o-matic/doc/debug_dhcp.html    |    1 +
 contrib/rom-o-matic/doc/debug_dns.html     |    1 +
 contrib/rom-o-matic/doc/debug_ibdev.html   |    1 +
 contrib/rom-o-matic/doc/debug_icmp.html    |    1 +
 contrib/rom-o-matic/doc/debug_image.html   |    1 +
 contrib/rom-o-matic/doc/debug_iscsi.html   |    1 +
 contrib/rom-o-matic/doc/debug_malloc.html  |    1 +
 contrib/rom-o-matic/doc/debug_ndp.html     |    1 +
 contrib/rom-o-matic/doc/debug_nvo.html     |    1 +
 contrib/rom-o-matic/doc/debug_options.html |    1 +
 contrib/rom-o-matic/doc/debug_script.html  |    1 +
 contrib/rom-o-matic/doc/debug_scsi.html    |    1 +
 contrib/rom-o-matic/doc/debug_serial.html  |    1 +
 contrib/rom-o-matic/doc/debug_srp.html     |    1 +
 contrib/rom-o-matic/doc/debug_tftp.html    |    1 +
 contrib/rom-o-matic/doc/debug_tls.html     |    1 +
 contrib/rom-o-matic/doc/debug_x509.html    |    1 +
 contrib/rom-o-matic/doc/debug_xfer.html    |    1 +
 contrib/rom-o-matic/flag-table.php         |   42 ++++++++++++++++++++++++++++
 contrib/rom-o-matic/utils.php              |   25 ++++++++++++++++
 25 files changed, 97 insertions(+), 1 deletions(-)
 create mode 100644 contrib/rom-o-matic/doc/debug_aoe.html
 create mode 100644 contrib/rom-o-matic/doc/debug_arp.html
 create mode 100644 contrib/rom-o-matic/doc/debug_ata.html
 create mode 100644 contrib/rom-o-matic/doc/debug_chap.html
 create mode 100644 contrib/rom-o-matic/doc/debug_dhcp.html
 create mode 100644 contrib/rom-o-matic/doc/debug_dns.html
 create mode 100644 contrib/rom-o-matic/doc/debug_ibdev.html
 create mode 100644 contrib/rom-o-matic/doc/debug_icmp.html
 create mode 100644 contrib/rom-o-matic/doc/debug_image.html
 create mode 100644 contrib/rom-o-matic/doc/debug_iscsi.html
 create mode 100644 contrib/rom-o-matic/doc/debug_malloc.html
 create mode 100644 contrib/rom-o-matic/doc/debug_ndp.html
 create mode 100644 contrib/rom-o-matic/doc/debug_nvo.html
 create mode 100644 contrib/rom-o-matic/doc/debug_options.html
 create mode 100644 contrib/rom-o-matic/doc/debug_script.html
 create mode 100644 contrib/rom-o-matic/doc/debug_scsi.html
 create mode 100644 contrib/rom-o-matic/doc/debug_serial.html
 create mode 100644 contrib/rom-o-matic/doc/debug_srp.html
 create mode 100644 contrib/rom-o-matic/doc/debug_tftp.html
 create mode 100644 contrib/rom-o-matic/doc/debug_tls.html
 create mode 100644 contrib/rom-o-matic/doc/debug_x509.html
 create mode 100644 contrib/rom-o-matic/doc/debug_xfer.html

diff --git a/contrib/rom-o-matic/build.php b/contrib/rom-o-matic/build.php
index 1d9ee30..8900a82 100644
--- a/contrib/rom-o-matic/build.php
+++ b/contrib/rom-o-matic/build.php
@@ -177,9 +177,16 @@ if ( $embedded_script != "" ) {
     $emb_script_cmd = "EMBEDDED_IMAGE=${emb_script_path}";
 }
 
+// Add debugs if requested
+$debug_var = "";
+$debugs = debug_flags ();
+if ( count ( $debugs ) > 0 ) {
+    $debug_var = "DEBUG=" . join ( ",", $debugs );
+}
+
 // Make the requested image.  $status is set to 0 on success
 $make_target = "bin/${nic}.${fmt_extension}";
-$make_cmd = "make -C '$build_dir' '$make_target' $emb_script_cmd $2>&1";
+$make_cmd = "make -C '$build_dir' '$make_target' $emb_script_cmd $debug_var 2>&1";
 
 exec ( $make_cmd, $maketxt, $status );
 
diff --git a/contrib/rom-o-matic/doc/debug_aoe.html b/contrib/rom-o-matic/doc/debug_aoe.html
new file mode 100644
index 0000000..0afa7e2
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_aoe.html
@@ -0,0 +1 @@
+Debug ATA over Ethernet
diff --git a/contrib/rom-o-matic/doc/debug_arp.html b/contrib/rom-o-matic/doc/debug_arp.html
new file mode 100644
index 0000000..6c4ed7b
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_arp.html
@@ -0,0 +1 @@
+Debug ARP address mapping
diff --git a/contrib/rom-o-matic/doc/debug_ata.html b/contrib/rom-o-matic/doc/debug_ata.html
new file mode 100644
index 0000000..945f29e
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_ata.html
@@ -0,0 +1 @@
+Debug ATA commands
diff --git a/contrib/rom-o-matic/doc/debug_chap.html b/contrib/rom-o-matic/doc/debug_chap.html
new file mode 100644
index 0000000..60ddf3e
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_chap.html
@@ -0,0 +1 @@
+Debug CHAP authentication
diff --git a/contrib/rom-o-matic/doc/debug_dhcp.html b/contrib/rom-o-matic/doc/debug_dhcp.html
new file mode 100644
index 0000000..48c0dbe
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_dhcp.html
@@ -0,0 +1 @@
+Debug DHCP lease negotiation
diff --git a/contrib/rom-o-matic/doc/debug_dns.html b/contrib/rom-o-matic/doc/debug_dns.html
new file mode 100644
index 0000000..3505d7e
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_dns.html
@@ -0,0 +1 @@
+Debug DNS resolver
diff --git a/contrib/rom-o-matic/doc/debug_ibdev.html b/contrib/rom-o-matic/doc/debug_ibdev.html
new file mode 100644
index 0000000..f9c9ac3
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_ibdev.html
@@ -0,0 +1 @@
+Debug infiniband
diff --git a/contrib/rom-o-matic/doc/debug_icmp.html b/contrib/rom-o-matic/doc/debug_icmp.html
new file mode 100644
index 0000000..c039069
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_icmp.html
@@ -0,0 +1 @@
+Debug ICMP packets
diff --git a/contrib/rom-o-matic/doc/debug_image.html b/contrib/rom-o-matic/doc/debug_image.html
new file mode 100644
index 0000000..0e90d4e
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_image.html
@@ -0,0 +1 @@
+Debug handling of downloaded image
diff --git a/contrib/rom-o-matic/doc/debug_iscsi.html b/contrib/rom-o-matic/doc/debug_iscsi.html
new file mode 100644
index 0000000..c40beb9
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_iscsi.html
@@ -0,0 +1 @@
+Debug iSCSI
diff --git a/contrib/rom-o-matic/doc/debug_malloc.html b/contrib/rom-o-matic/doc/debug_malloc.html
new file mode 100644
index 0000000..0992172
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_malloc.html
@@ -0,0 +1 @@
+Debug memory allocation
diff --git a/contrib/rom-o-matic/doc/debug_ndp.html b/contrib/rom-o-matic/doc/debug_ndp.html
new file mode 100644
index 0000000..b8f1a0c
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_ndp.html
@@ -0,0 +1 @@
+Debug NDP
diff --git a/contrib/rom-o-matic/doc/debug_nvo.html b/contrib/rom-o-matic/doc/debug_nvo.html
new file mode 100644
index 0000000..266517a
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_nvo.html
@@ -0,0 +1 @@
+Debug Non-Volatile Options
diff --git a/contrib/rom-o-matic/doc/debug_options.html b/contrib/rom-o-matic/doc/debug_options.html
new file mode 100644
index 0000000..14bd336
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_options.html
@@ -0,0 +1 @@
+Debug DHCP options
diff --git a/contrib/rom-o-matic/doc/debug_script.html b/contrib/rom-o-matic/doc/debug_script.html
new file mode 100644
index 0000000..ded38c0
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_script.html
@@ -0,0 +1 @@
+Debug script execution
diff --git a/contrib/rom-o-matic/doc/debug_scsi.html b/contrib/rom-o-matic/doc/debug_scsi.html
new file mode 100644
index 0000000..4bcd61b
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_scsi.html
@@ -0,0 +1 @@
+Debug SCSI commands
diff --git a/contrib/rom-o-matic/doc/debug_serial.html b/contrib/rom-o-matic/doc/debug_serial.html
new file mode 100644
index 0000000..d6d2d56
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_serial.html
@@ -0,0 +1 @@
+Debug serial port
diff --git a/contrib/rom-o-matic/doc/debug_srp.html b/contrib/rom-o-matic/doc/debug_srp.html
new file mode 100644
index 0000000..168bd22
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_srp.html
@@ -0,0 +1 @@
+Debug SRP
diff --git a/contrib/rom-o-matic/doc/debug_tftp.html b/contrib/rom-o-matic/doc/debug_tftp.html
new file mode 100644
index 0000000..5ccbbfd
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_tftp.html
@@ -0,0 +1 @@
+Debug TFTP transfer
diff --git a/contrib/rom-o-matic/doc/debug_tls.html b/contrib/rom-o-matic/doc/debug_tls.html
new file mode 100644
index 0000000..062527b
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_tls.html
@@ -0,0 +1 @@
+Debug TLS
diff --git a/contrib/rom-o-matic/doc/debug_x509.html b/contrib/rom-o-matic/doc/debug_x509.html
new file mode 100644
index 0000000..8c146a5
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_x509.html
@@ -0,0 +1 @@
+Debug X509 certificate handling
diff --git a/contrib/rom-o-matic/doc/debug_xfer.html b/contrib/rom-o-matic/doc/debug_xfer.html
new file mode 100644
index 0000000..4f4a542
--- /dev/null
+++ b/contrib/rom-o-matic/doc/debug_xfer.html
@@ -0,0 +1 @@
+Debug transfer of image
diff --git a/contrib/rom-o-matic/flag-table.php b/contrib/rom-o-matic/flag-table.php
index 82551e4..af6195e 100644
--- a/contrib/rom-o-matic/flag-table.php
+++ b/contrib/rom-o-matic/flag-table.php
@@ -487,8 +487,50 @@ $flag_table = array (
 
 	// End Wireless options
 
+	// Begin Debug options
+
+	"HDR_DEBUG_OPTIONS"
+	=> array (
+	   "flag" => "HDR_DEBUG_OPTIONS",
+	   "type" => "header",
+	   "label" => "Debug Logging Options",
+	   ),
 );
 
+// Add lots of debug options
+foreach (array(
+	       // Alphabetically for now; should probably group more sensibly
+	       'aoe',
+	       'arp',
+	       'ata',
+	       'chap',
+	       'dhcp',
+	       'dns',
+	       'ibdev',
+	       'icmp',
+	       'image',
+	       'iscsi',
+	       'malloc',
+	       'ndp',
+	       'nvo',
+	       'options',
+	       'script',
+	       'scsi',
+	       'serial',
+	       'srp',
+	       'tftp',
+	       'tls',
+	       'x509',
+	       'xfer',
+	       ) as $obj) {
+    $flag = 'debug_' . $obj;
+    $flag_table[$flag] = array (
+			 "flag" => $flag,
+			 "type" => "on/off",
+			 "value" => "off",
+			 );
+}
+
 // For emacs:
 // Local variables:
 //	c-basic-offset: 4
diff --git a/contrib/rom-o-matic/utils.php b/contrib/rom-o-matic/utils.php
index c5fdc20..1de3cfe 100644
--- a/contrib/rom-o-matic/utils.php
+++ b/contrib/rom-o-matic/utils.php
@@ -363,6 +363,31 @@ function get_flags ()
 }
 
 /**
+ * Return array of objects to be compiled with debug.
+ *
+ * Initial compile options are in a global called $flag_table.
+ * Compile options may have been changed via form input. We return
+ * an array listing the basenames of the requested objects.
+ *
+ * @return array of object basenames
+ */
+function debug_flags ()
+{
+	global $flag_table;
+
+	$debugs = array ();
+	foreach ( $flag_table as $key => $props ) {
+		$flag = $props["flag"];
+		if ( substr ( $flag, 0, 6 ) == "debug_" ) {
+			if ( $_POST["$flag"] == "on" ) {
+				$debugs[] = substr ( $flag, 6 );
+			}
+		}
+	}
+	return $debugs;
+}
+
+/**
  * Output given value in appropriate format for gPXE config file
  *
  * gPXE config/*.h files use C pre-processor syntax.  Output the given
-- 
1.6.5.6


--------------040601010109080907010307--


More information about the gPXE mailing list