Skip to content

Commit

Permalink
avoid empty function names, problematic for Rprof files
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Dec 22, 2017
1 parent 02888ed commit e37cb76
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ validate_profile_v1 <- function(x) {
stopifnot(!anyDuplicated(x$functions$function_id))
#' The `name`, `system_name` and `filename` columns describe function names
#' (demangled and mangled), and source file names for a function.
#' Both `name` and `system_name` must not contain empty strings.
stopifnot(x$functions$name != "")
stopifnot(x$functions$system_name != "")
#' The `start_line` column describes the start line of a function in its
#' source file, zero if unknown. All values must be nonnegative.
stopifnot(x$functions$start_line >= 0)
Expand Down
3 changes: 3 additions & 0 deletions R/pprof-from-ds.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ add_locations_to_msg <- function(locations, msg) {
}

add_functions_to_msg <- function(functions, msg) {
functions$name[functions$name == "<?>"] <- ""
functions$system_name[functions$system_name == "<?>"] <- ""

functions$name <- match(functions$name, msg$string_table) - 1L
functions$system_name <- match(functions$system_name, msg$string_table) - 1L
functions$filename <- match(functions$filename, msg$string_table) - 1L
Expand Down
2 changes: 2 additions & 0 deletions R/pprof-to-ds.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ get_functions_from_msg <- function(msg) {
functions$id <- NULL

functions$name <- msg$string_table[functions$name + 1]
functions$name[functions$name == ""] <- "<?>"
functions$system_name <- msg$string_table[functions$system_name + 1]
functions$system_name[functions$system_name == ""] <- "<?>"
functions$filename <- msg$string_table[functions$filename + 1]

functions$start_line <- as.integer(functions$start_line)
Expand Down
1 change: 1 addition & 0 deletions man/validate_profile.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e37cb76

Please sign in to comment.