diff options
author | Filipe Cabecinhas <me@filcab.net> | 2015-06-04 01:20:06 +0000 |
---|---|---|
committer | Filipe Cabecinhas <me@filcab.net> | 2015-06-04 01:20:06 +0000 |
commit | 215046bf98ef1dc7a380c35da5ca44166e74ae0b (patch) | |
tree | c222c0b97790cc15a9830c2625bf4614a7efb614 /compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cc | |
parent | 1ba52feb9673f805c5b74cf185e5384f23032522 (diff) | |
download | bcm5719-llvm-215046bf98ef1dc7a380c35da5ca44166e74ae0b.tar.gz bcm5719-llvm-215046bf98ef1dc7a380c35da5ca44166e74ae0b.zip |
[sanitizer_common] Added VS-style output for source locations
Summary:
With this patch, we have a flag to toggle displaying source locations in
the regular style:
file:line:column
or Visual Studio style:
file(line,column)
This way, they get picked up on the Visual Studio output window and one
can double-click them to get to that file location.
Reviewers: samsonov, rnk
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10113
llvm-svn: 239000
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cc')
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cc index 7b37dbcf386..d56e47e0727 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cc @@ -26,8 +26,8 @@ static const char *StripFunctionName(const char *function, const char *prefix) { static const char kDefaultFormat[] = " #%n %p %F %L"; void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no, - const AddressInfo &info, const char *strip_path_prefix, - const char *strip_func_prefix) { + const AddressInfo &info, bool vs_style, + const char *strip_path_prefix, const char *strip_func_prefix) { if (0 == internal_strcmp(format, "DEFAULT")) format = kDefaultFormat; for (const char *p = format; *p != '\0'; p++) { @@ -82,14 +82,14 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no, break; case 'S': // File/line information. - RenderSourceLocation(buffer, info.file, info.line, info.column, + RenderSourceLocation(buffer, info.file, info.line, info.column, vs_style, strip_path_prefix); break; case 'L': // Source location, or module location. if (info.file) { RenderSourceLocation(buffer, info.file, info.line, info.column, - strip_path_prefix); + vs_style, strip_path_prefix); } else if (info.module) { RenderModuleLocation(buffer, info.module, info.module_offset, strip_path_prefix); @@ -106,15 +106,24 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no, buffer->append("(%p)", (void *)info.address); break; default: - Report("Unsupported specifier in stack frame format: %c (0x%zx)!\n", - *p, *p); + Report("Unsupported specifier in stack frame format: %c (0x%zx)!\n", *p, + *p); Die(); } } } void RenderSourceLocation(InternalScopedString *buffer, const char *file, - int line, int column, const char *strip_path_prefix) { + int line, int column, bool vs_style, + const char *strip_path_prefix) { + if (vs_style && line > 0) { + buffer->append("%s(%d", StripPathPrefix(file, strip_path_prefix), line); + if (column > 0) + buffer->append(",%d", column); + buffer->append(")"); + return; + } + buffer->append("%s", StripPathPrefix(file, strip_path_prefix)); if (line > 0) { buffer->append(":%d", line); |