From 25ce596cd111ba93777338412ff9731b16f45cc6 Mon Sep 17 00:00:00 2001 From: James Henderson Date: Wed, 23 Jan 2019 17:27:48 +0000 Subject: [llvm-symbolizer] Improve compatibility of --functions with GNU addr2line This fixes https://bugs.llvm.org/show_bug.cgi?id=40072. GNU addr2line's --functions switch is off by default, has a short alias of -f, and does not take an argument. This patch changes llvm-symbolizer to allow the second and third point (changing the default behaviour may have negative impacts on users). If the option is missing a value, it now treats it as "linkage". This change does cause one previously valid command-line to behave differently. Before --functions was accepted, but now only --functions= is allowed (as well as --functions). The old behaviour will result in the value being treated as a positional argument. The previous testing for --functions=short has been pulled out into a new test that also tests the other accepted values and option formats. Reviewed by: ruiu Differential Revision: https://reviews.llvm.org/D57049 llvm-svn: 351968 --- llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'llvm/tools') diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp index 7affb0fdd33..83b39d9d018 100644 --- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -38,12 +38,17 @@ ClUseSymbolTable("use-symbol-table", cl::init(true), static cl::opt ClPrintFunctions( "functions", cl::init(FunctionNameKind::LinkageName), - cl::desc("Print function name for a given address:"), + cl::desc("Print function name for a given address:"), cl::ValueOptional, cl::values(clEnumValN(FunctionNameKind::None, "none", "omit function name"), clEnumValN(FunctionNameKind::ShortName, "short", "print short function name"), clEnumValN(FunctionNameKind::LinkageName, "linkage", - "print function linkage name"))); + "print function linkage name (default)"), + // Sentinel value for unspecified value. + clEnumValN(FunctionNameKind::LinkageName, "", ""))); +static cl::alias ClPrintFunctionsShort("f", cl::desc("Alias for -functions"), + cl::NotHidden, cl::Grouping, + cl::aliasopt(ClPrintFunctions)); static cl::opt ClUseRelativeAddress("relative-address", cl::init(false), -- cgit v1.2.3