base: Refactor function to collect stack traces

Currently base::debug::StackTrace collects a stack trace in its
constructor; however, this doesn't allow users to control the amount of
memory allocated per stack trace. The maximum stack trace length is
currently has each StackTrace consuming 2kb of memory on non-Windows
platforms. This is far too much for GWP-ASan which currently stores
hundreds of StackTraces.

Instead, have StackTrace use a publicly exposed function that allows
callers to specify the size of the stack trace.

Bug: 912286
Change-Id: Ib0ba0ec645df8801568b983fe86ee156259ecb84
Commit-Queue: Vlad Tsyrklevich <>
Reviewed-by: Albert J. Wong <>
Cr-Commit-Position: refs/heads/master@{#625067}
6 files changed