Commit a164e4c0 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add some more pyc debugging

ie for the "repeatedly failing to parse file" error.
parent 9abf0b58
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
namespace pyston { namespace pyston {
bool DEBUG_PARSING = false;
class BufferedReader { class BufferedReader {
private: private:
static const int BUFSIZE = 1024; static const int BUFSIZE = 1024;
...@@ -1043,6 +1045,11 @@ static ParseResult _reparse(const char* fn, const std::string& cache_fn, AST_Mod ...@@ -1043,6 +1045,11 @@ static ParseResult _reparse(const char* fn, const std::string& cache_fn, AST_Mod
if (!cache_fp) if (!cache_fp)
return ParseResult::PYC_UNWRITABLE; return ParseResult::PYC_UNWRITABLE;
if (DEBUG_PARSING) {
fprintf(stderr, "_reparse('%s', '%s'), pypa=%d\n", fn, cache_fn.c_str(), ENABLE_PYPA_PARSER);
fprintf(stderr, "writing magic string: %d %d %d %d\n", getMagic()[0], getMagic()[1], getMagic()[2],
getMagic()[3]);
}
fwrite(getMagic(), 1, MAGIC_STRING_LENGTH, cache_fp); fwrite(getMagic(), 1, MAGIC_STRING_LENGTH, cache_fp);
int checksum_start = ftell(cache_fp); int checksum_start = ftell(cache_fp);
...@@ -1094,6 +1101,9 @@ static ParseResult _reparse(const char* fn, const std::string& cache_fn, AST_Mod ...@@ -1094,6 +1101,9 @@ static ParseResult _reparse(const char* fn, const std::string& cache_fn, AST_Mod
// it's not a huge deal right now, but this caching version can significantly cut down // it's not a huge deal right now, but this caching version can significantly cut down
// on the startup time (40ms -> 10ms). // on the startup time (40ms -> 10ms).
AST_Module* caching_parse_file(const char* fn) { AST_Module* caching_parse_file(const char* fn) {
if (DEBUG_PARSING) {
fprintf(stderr, "caching_parse_file('%s'), pypa=%d\n", fn, ENABLE_PYPA_PARSER);
}
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_caching_parse_file"); UNAVOIDABLE_STAT_TIMER(t0, "us_timer_caching_parse_file");
static StatCounter us_parsing("us_parsing"); static StatCounter us_parsing("us_parsing");
Timer _t("parsing"); Timer _t("parsing");
...@@ -1214,6 +1224,9 @@ AST_Module* caching_parse_file(const char* fn) { ...@@ -1214,6 +1224,9 @@ AST_Module* caching_parse_file(const char* fn) {
assert(!good); assert(!good);
tries++; tries++;
RELEASE_ASSERT(tries <= MAX_TRIES, "repeatedly failing to parse file"); RELEASE_ASSERT(tries <= MAX_TRIES, "repeatedly failing to parse file");
if (tries == MAX_TRIES)
DEBUG_PARSING = true;
if (!good) { if (!good) {
assert(!fp); assert(!fp);
file_data.clear(); file_data.clear();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment