Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile.print: Shorten C paths too #55683

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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