Skip to content

Commit d1b3bf3

Browse files
IanButterworthKristofferC
authored and
KristofferC
committed
Profile.print: Shorten C paths too (#55683)
1 parent 4f0eac8 commit d1b3bf3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

base/sysinfo.jl

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ global STDLIB::String = "$BINDIR/../share/julia/stdlib/v$(VERSION.major).$(VERSI
5656
# In case STDLIB change after julia is built, the variable below can be used
5757
# to update cached method locations to updated ones.
5858
const BUILD_STDLIB_PATH = STDLIB
59+
# Similarly, this is the root of the julia repo directory that julia was built from
60+
const BUILD_ROOT_PATH = "$BINDIR/../.."
5961

6062
# helper to avoid triggering precompile warnings
6163

stdlib/Profile/src/Profile.jl

+11-1
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,23 @@ function flatten(data::Vector, lidict::LineInfoDict)
503503
return (newdata, newdict)
504504
end
505505

506+
const SRC_DIR = normpath(joinpath(Sys.BUILD_ROOT_PATH, "src"))
507+
506508
# Take a file-system path and try to form a concise representation of it
507509
# based on the package ecosystem
508510
function short_path(spath::Symbol, filenamecache::Dict{Symbol, Tuple{String,String,String}})
509511
return get!(filenamecache, spath) do
510512
path = Base.fixup_stdlib_path(string(spath))
513+
path_norm = normpath(path)
511514
possible_base_path = normpath(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "base", path))
512-
if isabspath(path)
515+
lib_dir = abspath(Sys.BINDIR, Base.LIBDIR)
516+
if startswith(path_norm, SRC_DIR)
517+
remainder = only(split(path_norm, SRC_DIR, keepempty=false))
518+
return (isfile(path_norm) ? path_norm : ""), "@juliasrc", remainder
519+
elseif startswith(path_norm, lib_dir)
520+
remainder = only(split(path_norm, lib_dir, keepempty=false))
521+
return (isfile(path_norm) ? path_norm : ""), "@julialib", remainder
522+
elseif isabspath(path)
513523
if ispath(path)
514524
# try to replace the file-system prefix with a short "@Module" one,
515525
# assuming that profile came from the current machine

0 commit comments

Comments
 (0)