aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2020-04-13 23:56:43 -0700
committerDan Willemsen <dwillemsen@google.com>2020-04-20 23:12:45 -0700
commit0cf3d2d5c0204fed5023575698da9c8b9d8681fe (patch)
tree862c9dc0c00580e162b491079554316ebb5544a2
parent14325fd35d6056415e35d4f3c00b0a94474e0426 (diff)
downloadplatform_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.cc4
-rw-r--r--func.h2
-rw-r--r--ninja.cc2
-rw-r--r--regen.cc5
-rw-r--r--regen_dump.cc9
5 files changed, 21 insertions, 1 deletions
diff --git a/func.cc b/func.cc
index e38e0e7..b0837da 100644
--- a/func.cc
+++ b/func.cc
@@ -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);
}
}
diff --git a/func.h b/func.h
index 4ba03b6..72f90fd 100644
--- a/func.h
+++ b/func.h
@@ -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();
diff --git a/ninja.cc b/ninja.cc
index 1a8332e..f53b15b 100644
--- a/ninja.cc
+++ b/ninja.cc
@@ -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;
diff --git a/regen.cc b/regen.cc
index 4374f81..1cb94e0 100644
--- a/regen.cc
+++ b/regen.cc
@@ -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) {