Skip to content

Commit

Permalink
Fix #93 (#98)
Browse files Browse the repository at this point in the history
* Fix for empty frames being pushed to the profile data

* Fix for functions missing from the table when using `from_c=false`

* small fixes

* fix test

---------

Co-authored-by: Konstantin Kliakhandler <[email protected]>
  • Loading branch information
vchuravy and sprig authored Sep 10, 2024
1 parent 30785d3 commit 4b0f039
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/PProf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ function pprof(data::Union{Nothing, Vector{UInt}} = nothing,
]
idx -= (Profile.nmeta + 2) # skip all the metas, plus the 2 nulls that end a block.
continue
elseif !has_meta && data[idx] == 0
elseif data[idx] == 0
if has_meta
# This should never happen in has_meta mode
@error "Unexpected 0 in data, please file an issue." idx
continue
end
# Avoid creating empty samples
# ip == 0x0 is the sentinel value for finishing a backtrace (when meta is disabled), therefore finising a sample
# On some platforms, we sometimes get two 0s in a row for some reason...
Expand Down Expand Up @@ -274,10 +279,8 @@ function pprof(data::Union{Nothing, Vector{UInt}} = nothing,
end
file = Base.find_source_file(file)
filename = enter!(file)
# Only keep C functions if from_c=true
if (from_c || !frame.from_c)
funcs[func_id] = Function(func_id, name, system_name, filename, start_line)
end
# Decode C functions always
funcs[func_id] = Function(func_id, name, system_name, filename, start_line)
end
locs_from_c[ip] = location_from_c
# Only keep C frames if from_c=true
Expand Down
2 changes: 1 addition & 1 deletion test/PProf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ end
# Test that C frames were excluded
@test length(with_c.sample) == length(without_c.sample)
@test length(with_c.location) > length(without_c.location)
@test length(with_c.var"#function") > length(without_c.var"#function")
@test length(with_c.var"#function") == length(without_c.var"#function")
end
end

Expand Down

0 comments on commit 4b0f039

Please sign in to comment.