debugd: log_tool: add DCHECKs for mismatched func calls
Developer builds should hard fail on these rather than return a
string that's easy to miss in giant log files.
BUG=None
TEST=CQ passes
Change-Id: I8d8c96db006bc94628faed452a92bf11c74f0657
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2593892
Reviewed-by: Miriam Zimmerman <mutexlox@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/debugd/src/log_tool.cc b/debugd/src/log_tool.cc
index b62a5fd..ff7c7cb 100644
--- a/debugd/src/log_tool.cc
+++ b/debugd/src/log_tool.cc
@@ -568,6 +568,7 @@
output = GetFileLogData();
break;
default:
+ DCHECK(false) << "unknown log type";
return "<unknown log type>";
}
@@ -579,6 +580,7 @@
// TODO(ellyjones): sandbox. crosbug.com/35122
std::string Log::GetCommandLogData() const {
+ DCHECK_EQ(type_, kCommand);
if (type_ != kCommand)
return "<log type mismatch>";
std::string tailed_cmdline =
@@ -602,6 +604,7 @@
}
std::string Log::GetFileLogData() const {
+ DCHECK_EQ(type_, kFile);
if (type_ != kFile)
return "<log type mismatch>";