Skip to content

Commit

Permalink
Profile.print: Shorten C paths too (JuliaLang#55683)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Sep 4, 2024
1 parent 4aac5ae commit bada969
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ global STDLIB::String = "$BINDIR/../share/julia/stdlib/v$(VERSION.major).$(VERSI
# In case STDLIB change after julia is built, the variable below can be used
# to update cached method locations to updated ones.
const BUILD_STDLIB_PATH = STDLIB
# Similarly, this is the root of the julia repo directory that julia was built from
const BUILD_ROOT_PATH = "$BINDIR/../.."

# helper to avoid triggering precompile warnings

Expand Down
12 changes: 11 additions & 1 deletion stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,23 @@ function flatten(data::Vector, lidict::LineInfoDict)
return (newdata, newdict)
end

const SRC_DIR = normpath(joinpath(Sys.BUILD_ROOT_PATH, "src"))

# Take a file-system path and try to form a concise representation of it
# based on the package ecosystem
function short_path(spath::Symbol, filenamecache::Dict{Symbol, Tuple{String,String,String}})
return get!(filenamecache, spath) do
path = Base.fixup_stdlib_path(string(spath))
path_norm = normpath(path)
possible_base_path = normpath(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "base", path))
if isabspath(path)
lib_dir = abspath(Sys.BINDIR, Base.LIBDIR)
if startswith(path_norm, SRC_DIR)
remainder = only(split(path_norm, SRC_DIR, keepempty=false))
return (isfile(path_norm) ? path_norm : ""), "@juliasrc", remainder
elseif startswith(path_norm, lib_dir)
remainder = only(split(path_norm, lib_dir, keepempty=false))
return (isfile(path_norm) ? path_norm : ""), "@julialib", remainder
elseif isabspath(path)
if ispath(path)
# try to replace the file-system prefix with a short "@Module" one,
# assuming that profile came from the current machine
Expand Down

0 comments on commit bada969

Please sign in to comment.