diff options
author | Ed Maste <emaste@freebsd.org> | 2013-07-22 12:39:17 +0000 |
---|---|---|
committer | Ed Maste <emaste@freebsd.org> | 2013-07-22 12:39:17 +0000 |
commit | 76ad5d7589a5173a8ca9f2edfd828ccb0bb723a9 (patch) | |
tree | f03375f551d9992181500337957ecb97717b2342 /lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp | |
parent | 9c012165ad184c472692074a3ade2c8515ea7e08 (diff) | |
download | llvm-76ad5d7589a5173a8ca9f2edfd828ccb0bb723a9.zip llvm-76ad5d7589a5173a8ca9f2edfd828ccb0bb723a9.tar.gz llvm-76ad5d7589a5173a8ca9f2edfd828ccb0bb723a9.tar.bz2 |
Factor out common string match code for POSIX log enable/disable
llvm-svn: 186822
Diffstat (limited to 'lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp index d673ab4..624ca87 100644 --- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp +++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp @@ -47,6 +47,28 @@ ProcessPOSIXLog::GetLogIfAllCategoriesSet (uint32_t mask) return log; } +static uint32_t +GetFlagBits (const char *arg) +{ + if (::strcasecmp (arg, "all") == 0 ) return POSIX_LOG_ALL; + else if (::strcasecmp (arg, "async") == 0 ) return POSIX_LOG_ASYNC; + else if (::strncasecmp (arg, "break", 5) == 0 ) return POSIX_LOG_BREAKPOINTS; + else if (::strncasecmp (arg, "comm", 4) == 0 ) return POSIX_LOG_COMM; + else if (::strcasecmp (arg, "default") == 0 ) return POSIX_LOG_DEFAULT; + else if (::strcasecmp (arg, "packets") == 0 ) return POSIX_LOG_PACKETS; + else if (::strcasecmp (arg, "memory") == 0 ) return POSIX_LOG_MEMORY; + else if (::strcasecmp (arg, "data-short") == 0 ) return POSIX_LOG_MEMORY_DATA_SHORT; + else if (::strcasecmp (arg, "data-long") == 0 ) return POSIX_LOG_MEMORY_DATA_LONG; + else if (::strcasecmp (arg, "process") == 0 ) return POSIX_LOG_PROCESS; + else if (::strcasecmp (arg, "ptrace") == 0 ) return POSIX_LOG_PTRACE; + else if (::strcasecmp (arg, "registers") == 0 ) return POSIX_LOG_REGISTERS; + else if (::strcasecmp (arg, "step") == 0 ) return POSIX_LOG_STEP; + else if (::strcasecmp (arg, "thread") == 0 ) return POSIX_LOG_THREAD; + else if (::strcasecmp (arg, "verbose") == 0 ) return POSIX_LOG_VERBOSE; + else if (::strncasecmp (arg, "watch", 5) == 0 ) return POSIX_LOG_WATCHPOINTS; + return 0; +} + void ProcessPOSIXLog::DisableLog (const char **args, Stream *feedback_strm) { @@ -59,23 +81,12 @@ ProcessPOSIXLog::DisableLog (const char **args, Stream *feedback_strm) for (; args[0]; args++) { const char *arg = args[0]; + uint32_t bits = GetFlagBits(arg); - if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~POSIX_LOG_ALL; - else if (::strcasecmp (arg, "async") == 0 ) flag_bits &= ~POSIX_LOG_ASYNC; - else if (::strncasecmp (arg, "break", 5) == 0 ) flag_bits &= ~POSIX_LOG_BREAKPOINTS; - else if (::strncasecmp (arg, "comm", 4) == 0 ) flag_bits &= ~POSIX_LOG_COMM; - else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~POSIX_LOG_DEFAULT; - else if (::strcasecmp (arg, "packets") == 0 ) flag_bits &= ~POSIX_LOG_PACKETS; - else if (::strcasecmp (arg, "memory") == 0 ) flag_bits &= ~POSIX_LOG_MEMORY; - else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~POSIX_LOG_MEMORY_DATA_SHORT; - else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~POSIX_LOG_MEMORY_DATA_LONG; - else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~POSIX_LOG_PROCESS; - else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits &= ~POSIX_LOG_PTRACE; - else if (::strcasecmp (arg, "registers") == 0 ) flag_bits &= ~POSIX_LOG_REGISTERS; - else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~POSIX_LOG_STEP; - else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~POSIX_LOG_THREAD; - else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~POSIX_LOG_VERBOSE; - else if (::strncasecmp (arg, "watch", 5) == 0 ) flag_bits &= ~POSIX_LOG_WATCHPOINTS; + if (bits) + { + flag_bits &= ~bits; + } else { feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); @@ -115,23 +126,12 @@ ProcessPOSIXLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const for (; args[0]; args++) { const char *arg = args[0]; + uint32_t bits = GetFlagBits(arg); - if (::strcasecmp (arg, "all") == 0 ) flag_bits |= POSIX_LOG_ALL; - else if (::strcasecmp (arg, "async") == 0 ) flag_bits |= POSIX_LOG_ASYNC; - else if (::strncasecmp (arg, "break", 5) == 0 ) flag_bits |= POSIX_LOG_BREAKPOINTS; - else if (::strncasecmp (arg, "comm", 4) == 0 ) flag_bits |= POSIX_LOG_COMM; - else if (::strcasecmp (arg, "default") == 0 ) flag_bits |= POSIX_LOG_DEFAULT; - else if (::strcasecmp (arg, "packets") == 0 ) flag_bits |= POSIX_LOG_PACKETS; - else if (::strcasecmp (arg, "memory") == 0 ) flag_bits |= POSIX_LOG_MEMORY; - else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits |= POSIX_LOG_MEMORY_DATA_SHORT; - else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits |= POSIX_LOG_MEMORY_DATA_LONG; - else if (::strcasecmp (arg, "process") == 0 ) flag_bits |= POSIX_LOG_PROCESS; - else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits |= POSIX_LOG_PTRACE; - else if (::strcasecmp (arg, "registers") == 0 ) flag_bits |= POSIX_LOG_REGISTERS; - else if (::strcasecmp (arg, "step") == 0 ) flag_bits |= POSIX_LOG_STEP; - else if (::strcasecmp (arg, "thread") == 0 ) flag_bits |= POSIX_LOG_THREAD; - else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits |= POSIX_LOG_VERBOSE; - else if (::strncasecmp (arg, "watch", 5) == 0 ) flag_bits |= POSIX_LOG_WATCHPOINTS; + if (bits) + { + flag_bits |= bits; + } else { feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); |