Skip to content
Merged
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
43 changes: 37 additions & 6 deletions Valgrind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
#
### MEMCHECK SPECIFIC OPTIONS:
#
# LEAK_CHECK searches for memory leaks when the application finishes.
# LEAK_CHECK=<no|summary|yes|full> [default: summary], searches for memory leaks
# when the application finishes.
#
# * If set to `summary`, it says how many leaks occurred.
# * If set to `full` or `yes`, each individual leak will be shown in detail
Expand All @@ -109,22 +110,36 @@
#
### MASSIF SPECIFIC OPTIONS:
#
# DEPTH=<number> [default: 30], maximum depth of the allocation trees recorded
# for detailed snapshots.
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a unit or range to use as argument to depth?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did mention that the parameter expects a number and specified the default value. I've made this change to all the other single variable parameters as well.

There is no upper range within Valgrinds documentation (in my implementation it caps at 200), so I didn't want to specify the range as that isn't set in stone from the looks of things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super! 👍

# DETAILED_FREQUENCY=<number> [default: 10], frequency of detailed snapshots.
# With value of `1`, every snapshot is detailed.
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above, can I use decimal numbers as argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️, marked it as float, the notation that is used in Valgrind of m.n seems a bit strange

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you prefer decimal over float I can use decimal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I prefer float :P looks good 👍

# MAX_SNAPSHOTS=<number> [default: 100], the maximum number of snapshots
# recorded.
#
# PEAK_INACCURACY=<float> [default: 1.0], Massif does not necessarily record
# the actual global memory allocation peak; by default it records a peak only
# when the global memory allocation size exceeds the previous peak by at least
# 1.0%. Setting this value to `0.0` gives the true value of the peak.
#
# STACKS specifies whether stack profiling should be done. This option slows
# Massif down greatly.
#
# PAGES_AS_HEAP tells Massif to profile memory at the page level rather than at
# the malloc'd block level.
#
# TIME_UNIT offers three settings:
# TIME_UNIT=<i|ms|B>, offers three settings:
#
# * Instructions executed `i`, which is good for most cases.
# * Time `ms`, which is sometimes useful.
# * Bytes allocated/deallocated on the heap and/or stack `B`, which is useful
# for very short-run programs and for testing purposes.
#
# THRESHOLD the significance threshold for heap allocations, as a percentage of
# total memory size. Allocation tree entries that account for less than this
# will be aggregated.
# THRESHOLD=<float> [default: 1.0], the significance threshold for heap
# allocations, as a percentage of total memory size. Allocation tree entries
# that account for less than this will be aggregated.
#
### NOTES
#
Expand Down Expand Up @@ -284,7 +299,7 @@ endfunction()

function(swift_add_valgrind_massif target)
set(argOption STACKS PAGES_AS_HEAP XTREE_MEMORY)
set(argSingle THRESHOLD TIME_UNIT)
set(argSingle DEPTH DETAILED_FREQUENCY MAX_SNAPSHOTS PEAK_INACCURACY THRESHOLD TIME_UNIT)
set(argMulti "")

_valgrind_arguments_setup(${target} massif "${argOption}" "${argSingle}" "${argMulti}" "${ARGN}")
Expand All @@ -309,6 +324,22 @@ function(swift_add_valgrind_massif target)
list(APPEND valgrind_tool_options --xtree-memory-file=${target}.kcg.%p)
endif()

if (x_DEPTH)
list(APPEND valgrind_tool_options "--depth=${x_DEPTH}")
endif()

if (x_DETAILED_FREQUENCY)
list(APPEND valgrind_tool_options "--detailed-freq=${x_DETAILED_FREQUENCY}")
endif()

if (x_MAX_SNAPSHOTS)
list(APPEND valgrind_tool_options "--max-snapshots=${x_MAX_SNAPSHOTS}")
endif()

if (x_PEAK_INACCURACY)
list(APPEND valgrind_tool_options "--peak-inaccuracy=${x_PEAK_INACCURACY}")
endif()

if (x_THRESHOLD)
list(APPEND valgrind_tool_options "--threshold=${x_THRESHOLD}")
endif()
Expand Down