summaryrefslogtreecommitdiff
path: root/gold/debug.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2008-03-04 23:10:38 +0000
committerIan Lance Taylor <iant@google.com>2008-03-04 23:10:38 +0000
commitce2b5aab6a3abd9016e888750b5a5fa1973808f3 (patch)
tree63afc344334c4b5774bf2f87d40a021c17bd8656 /gold/debug.h
parent67e66a190ce77b35c8fab85fa1d615c375204dfe (diff)
downloadbinutils-redhat-ce2b5aab6a3abd9016e888750b5a5fa1973808f3.tar.gz
From Craig Silverstein: rework option handling to make it easier to
add a new option.
Diffstat (limited to 'gold/debug.h')
-rw-r--r--gold/debug.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/gold/debug.h b/gold/debug.h
index e37e2f157a..143c7dfbf1 100644
--- a/gold/debug.h
+++ b/gold/debug.h
@@ -36,6 +36,25 @@ const int DEBUG_SCRIPT = 2;
const int DEBUG_ALL = DEBUG_TASK | DEBUG_SCRIPT;
+// Convert a debug string to the appropriate enum.
+inline int
+debug_string_to_enum(const char* arg)
+{
+ static const struct { const char* name; int value; }
+ debug_options[] =
+ {
+ { "task", DEBUG_TASK },
+ { "script", DEBUG_SCRIPT },
+ { "all", DEBUG_ALL }
+ };
+
+ int retval = 0;
+ for (size_t i = 0; i < sizeof(debug_options) / sizeof(*debug_options); ++i)
+ if (strstr(arg, debug_options[i].name))
+ retval |= debug_options[i].value;
+ return retval;
+}
+
// Print a debug message if TYPE is enabled. This is a macro so that
// we only evaluate the arguments if necessary.