@@ -6976,15 +6976,20 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
69766976 return (!jl_is_submodule (mod, jl_base_module) &&
69776977 !jl_is_submodule (mod, jl_core_module));
69786978 };
6979+ auto in_tracked_path = [] (StringRef file) {
6980+ return jl_options.tracked_path != NULL && file.startswith (jl_options.tracked_path );
6981+ };
69796982 bool mod_is_user_mod = in_user_mod (ctx.module );
6983+ bool mod_is_tracked = in_tracked_path (ctx.file );
69806984 struct DebugLineTable {
69816985 DebugLoc loc;
69826986 StringRef file;
69836987 ssize_t line;
69846988 bool is_user_code;
6989+ bool is_tracked; // falls within an explicitly set file or directory
69856990 unsigned inlined_at;
69866991 bool operator ==(const DebugLineTable &other) const {
6987- return other.loc == loc && other.file == file && other.line == line && other.is_user_code == is_user_code && other.inlined_at == inlined_at;
6992+ return other.loc == loc && other.file == file && other.line == line && other.is_user_code == is_user_code && other.is_tracked == is_tracked && other. inlined_at == inlined_at;
69886993 }
69896994 };
69906995 std::vector<DebugLineTable> linetable;
@@ -6997,6 +7002,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
69977002 topinfo.file = ctx.file ;
69987003 topinfo.line = toplineno;
69997004 topinfo.is_user_code = mod_is_user_mod;
7005+ topinfo.is_tracked = mod_is_tracked;
70007006 topinfo.inlined_at = 0 ;
70017007 topinfo.loc = topdebugloc;
70027008 for (size_t i = 0 ; i < nlocs; i++) {
@@ -7010,13 +7016,14 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
70107016 info.line = jl_unbox_long (jl_fieldref (locinfo, 3 ));
70117017 info.inlined_at = jl_unbox_long (jl_fieldref (locinfo, 4 ));
70127018 assert (info.inlined_at <= i);
7019+ info.file = jl_symbol_name (filesym);
7020+ if (info.file .empty ())
7021+ info.file = " <missing>" ;
70137022 if (module == ctx.module )
70147023 info.is_user_code = mod_is_user_mod;
70157024 else
70167025 info.is_user_code = in_user_mod (module );
7017- info.file = jl_symbol_name (filesym);
7018- if (info.file .empty ())
7019- info.file = " <missing>" ;
7026+ info.is_tracked = in_tracked_path (info.file );
70207027 if (ctx.debug_enabled ) {
70217028 StringRef fname;
70227029 if (jl_is_method_instance (method))
@@ -7130,13 +7137,15 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
71307137 cursor = -1 ;
71317138 };
71327139
7133- auto do_coverage = [&] (bool in_user_code) {
7140+ auto do_coverage = [&] (bool in_user_code, bool is_tracked ) {
71347141 return (coverage_mode == JL_LOG_ALL ||
7135- (coverage_mode == JL_LOG_USER && in_user_code));
7142+ (in_user_code && coverage_mode == JL_LOG_USER) ||
7143+ (is_tracked && coverage_mode == JL_LOG_PATH));
71367144 };
7137- auto do_malloc_log = [&] (bool in_user_code) {
7145+ auto do_malloc_log = [&] (bool in_user_code, bool is_tracked ) {
71387146 return (malloc_log_mode == JL_LOG_ALL ||
7139- (malloc_log_mode == JL_LOG_USER && in_user_code));
7147+ (in_user_code && malloc_log_mode == JL_LOG_USER) ||
7148+ (is_tracked && malloc_log_mode == JL_LOG_PATH));
71407149 };
71417150 std::vector<unsigned > current_lineinfo, new_lineinfo;
71427151 auto coverageVisitStmt = [&] (size_t dbg) {
@@ -7155,15 +7164,15 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
71557164 if (newdbg != current_lineinfo[dbg]) {
71567165 current_lineinfo[dbg] = newdbg;
71577166 const auto &info = linetable.at (newdbg);
7158- if (do_coverage (info.is_user_code ))
7167+ if (do_coverage (info.is_user_code , info. is_tracked ))
71597168 coverageVisitLine (ctx, info.file , info.line );
71607169 }
71617170 }
71627171 new_lineinfo.clear ();
71637172 };
71647173 auto mallocVisitStmt = [&] (unsigned dbg, Value *sync) {
7165- if (!do_malloc_log (mod_is_user_mod) || dbg == 0 ) {
7166- if (do_malloc_log (true ) && sync)
7174+ if (!do_malloc_log (mod_is_user_mod, mod_is_tracked ) || dbg == 0 ) {
7175+ if (do_malloc_log (true , mod_is_tracked ) && sync)
71677176 ctx.builder .CreateCall (prepare_call (sync_gc_total_bytes_func), {sync});
71687177 return ;
71697178 }
@@ -7174,7 +7183,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
71747183 if (coverage_mode != JL_LOG_NONE) {
71757184 // record all lines that could be covered
71767185 for (const auto &info : linetable)
7177- if (do_coverage (info.is_user_code ))
7186+ if (do_coverage (info.is_user_code , info. is_tracked ))
71787187 jl_coverage_alloc_line (info.file , info.line );
71797188 }
71807189
@@ -7229,15 +7238,15 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
72297238 }
72307239
72317240 Value *sync_bytes = nullptr ;
7232- if (do_malloc_log (true ))
7241+ if (do_malloc_log (true , mod_is_tracked ))
72337242 sync_bytes = ctx.builder .CreateCall (prepare_call (diff_gc_total_bytes_func), {});
72347243 { // coverage for the function definition line number
72357244 const auto &topinfo = linetable.at (0 );
72367245 if (linetable.size () > 1 ) {
72377246 if (topinfo == linetable.at (1 ))
72387247 current_lineinfo.push_back (1 );
72397248 }
7240- if (do_coverage (topinfo.is_user_code ))
7249+ if (do_coverage (topinfo.is_user_code , topinfo. is_tracked ))
72417250 coverageVisitLine (ctx, topinfo.file , topinfo.line );
72427251 }
72437252
0 commit comments