diff options
| author | Dan Willemsen <dwillemsen@google.com> | 2020-04-13 23:56:43 -0700 |
|---|---|---|
| committer | Dan Willemsen <dwillemsen@google.com> | 2020-04-20 23:12:45 -0700 |
| commit | 0cf3d2d5c0204fed5023575698da9c8b9d8681fe (patch) | |
| tree | 862c9dc0c00580e162b491079554316ebb5544a2 | |
| parent | 14325fd35d6056415e35d4f3c00b0a94474e0426 (diff) | |
| download | platform_build_kati-0cf3d2d5c0204fed5023575698da9c8b9d8681fe.tar.gz platform_build_kati-0cf3d2d5c0204fed5023575698da9c8b9d8681fe.tar.bz2 platform_build_kati-0cf3d2d5c0204fed5023575698da9c8b9d8681fe.zip | |
Add debug location info into the regen stamp file
This makes it easier to figure out where different shell commands are
coming from.
Change-Id: I0eef9cd28eb39e5ca2961ee650bd498e34e94ced
| -rw-r--r-- | func.cc | 4 | ||||
| -rw-r--r-- | func.h | 2 | ||||
| -rw-r--r-- | ninja.cc | 2 | ||||
| -rw-r--r-- | regen.cc | 5 | ||||
| -rw-r--r-- | regen_dump.cc | 9 |
5 files changed, 21 insertions, 1 deletions
@@ -590,6 +590,7 @@ void ShellFunc(const vector<Value*>& args, Evaluator* ev, string* s) { cr->cmd = cmd; cr->find.reset(fc); cr->result = out; + cr->loc = ev->loc(); g_command_results.push_back(cr); } *s += out; @@ -712,6 +713,7 @@ static void FileReadFunc(Evaluator* ev, const string& filename, string* s) { CommandResult* cr = new CommandResult(); cr->op = CommandOp::READ_MISSING; cr->cmd = filename; + cr->loc = ev->loc(); g_command_results.push_back(cr); } return; @@ -745,6 +747,7 @@ static void FileReadFunc(Evaluator* ev, const string& filename, string* s) { CommandResult* cr = new CommandResult(); cr->op = CommandOp::READ; cr->cmd = filename; + cr->loc = ev->loc(); g_command_results.push_back(cr); } *s += out; @@ -772,6 +775,7 @@ static void FileWriteFunc(Evaluator* ev, cr->op = CommandOp::WRITE; cr->cmd = filename; cr->result = text; + cr->loc = ev->loc(); g_command_results.push_back(cr); } } @@ -20,6 +20,7 @@ #include <vector> #include "expr.h" +#include "loc.h" using namespace std; @@ -57,6 +58,7 @@ struct CommandResult { string cmd; unique_ptr<FindCommand> find; string result; + Loc loc; }; const vector<CommandResult*>& GetShellCommandResults(); @@ -771,6 +771,8 @@ class NinjaGenerator { DumpString(fp, cr->shellflag); DumpString(fp, cr->cmd); DumpString(fp, cr->result); + DumpString(fp, cr->loc.filename); + DumpInt(fp, cr->loc.lineno); if (cr->op == CommandOp::FIND) { vector<string> missing_dirs; @@ -245,6 +245,11 @@ class StampChecker { LOAD_STRING(fp, &sr->cmd); LOAD_STRING(fp, &sr->result); + string file; + // Ignore debug info + LOAD_STRING(fp, &file); + LOAD_INT(fp); + if (sr->op == CommandOp::FIND) { int num_missing_dirs = LOAD_INT(fp); for (int j = 0; j < num_missing_dirs; j++) { diff --git a/regen_dump.cc b/regen_dump.cc index 92a1688..9916a3f 100644 --- a/regen_dump.cc +++ b/regen_dump.cc @@ -148,7 +148,7 @@ int main(int argc, char* argv[]) { ERROR("Incomplete stamp file"); for (int i = 0; i < num_cmds; i++) { CommandOp op = static_cast<CommandOp>(LoadInt(fp)); - string shell, shellflag, cmd, result; + string shell, shellflag, cmd, result, file; if (!LoadString(fp, &shell)) ERROR("Incomplete stamp file"); if (!LoadString(fp, &shellflag)) @@ -157,6 +157,11 @@ int main(int argc, char* argv[]) { ERROR("Incomplete stamp file"); if (!LoadString(fp, &result)) ERROR("Incomplete stamp file"); + if (!LoadString(fp, &file)) + ERROR("Incomplete stamp file"); + int line = LoadInt(fp); + if (line < 0) + ERROR("Incomplete stamp file"); if (op == CommandOp::FIND) { auto missing_dirs = LoadVecString(fp); @@ -167,6 +172,7 @@ int main(int argc, char* argv[]) { printf("cmd type: FIND\n"); printf(" shell: %s\n", shell.c_str()); printf(" shell flags: %s\n", shellflag.c_str()); + printf(" loc: %s:%d\n", file.c_str(), line); printf(" cmd: %s\n", cmd.c_str()); if (result.length() > 0 && result.length() < 500 && result.find('\n') == std::string::npos) { @@ -202,6 +208,7 @@ int main(int argc, char* argv[]) { } else if (op == CommandOp::APPEND) { printf("cmd type: APPEND\n"); } + printf(" loc: %s:%d\n", file.c_str(), line); printf(" cmd: %s\n", cmd.c_str()); if (result.length() > 0 && result.length() < 500 && result.find('\n') == std::string::npos) { |
