<div dir="ltr"><div><br></div><div class="gmail_extra"><div class="gmail_quote">On Fri, May 16, 2014 at 5:54 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">What're the use cases you have in mind for this? When using the short<br>
name, are you not going to provide the qualifications (namespace,<br>
etc)?<br></blockquote><div><br></div><div>See <a href="http://comments.gmane.org/gmane.comp.compilers.llvm.devel/72792">http://comments.gmane.org/gmane.comp.compilers.llvm.devel/72792</a>.</div><div><br></div><div>In fact, I'm ok with reverting the changes to llvm-symbolizer and just extending the DebugInfo</div>
<div>library functionality, but that would make the code untested. Unfortunately, it's still challenging</div><div>to test the DWARF parser on anything except actual binary DWARF data.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
I was rather hoping the symbolizer would only want/need the mangled<br>
name - to keep things simple (thinking about this in terms of just how<br>
minimal the DIEs can be for -gmlt as I'm changing it to cope with<br>
fission)<br>
<div class=""><div class="h5"><br>
On Fri, May 16, 2014 at 5:07 PM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
> Author: samsonov<br>
> Date: Fri May 16 19:07:48 2014<br>
> New Revision: 209050<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=209050&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=209050&view=rev</a><br>
> Log:<br>
> [DWARF parser] Teach DIContext to fetch short (non-linkage) function names for a given address.<br>
><br>
> Change --functions option in llvm-symbolizer tool to accept<br>
> values "none", "short" or "linkage". Update the tests and docs<br>
> accordingly.<br>
><br>
> Modified:<br>
> llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst<br>
> llvm/trunk/include/llvm/DebugInfo/DIContext.h<br>
> llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp<br>
> llvm/trunk/test/DebugInfo/llvm-symbolizer.test<br>
> llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp<br>
> llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h<br>
> llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp<br>
><br>
> Modified: llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst?rev=209050&r1=209049&r2=209050&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst?rev=209050&r1=209049&r2=209050&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst (original)<br>
> +++ llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst Fri May 16 19:07:48 2014<br>
> @@ -61,11 +61,14 @@ OPTIONS<br>
> -------<br>
><br>
> .. option:: -obj<br>
> +<br>
> Path to object file to be symbolized.<br>
><br>
> -.. option:: -functions<br>
> +.. option:: -functions=[none|short|linkage]<br>
><br>
> - Print function names as well as source file/line locations. Defaults to true.<br>
> + Specify the way function names are printed (omit function name,<br>
> + print short function name, or print full linkage name, respectively).<br>
> + Defaults to ``linkage``.<br>
><br>
> .. option:: -use-symbol-table<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=209050&r1=209049&r2=209050&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=209050&r1=209049&r2=209050&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Fri May 16 19:07:48 2014<br>
> @@ -70,7 +70,7 @@ class DIInliningInfo {<br>
> /// should be filled with data.<br>
> struct DILineInfoSpecifier {<br>
> enum class FileLineInfoKind { None, Default, AbsoluteFilePath };<br>
> - enum class FunctionNameKind { None, LinkageName };<br>
> + enum class FunctionNameKind { None, ShortName, LinkageName };<br>
><br>
> FileLineInfoKind FLIKind;<br>
> FunctionNameKind FNKind;<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp?rev=209050&r1=209049&r2=209050&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp?rev=209050&r1=209049&r2=209050&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp Fri May 16 19:07:48 2014<br>
> @@ -277,13 +277,15 @@ DWARFDebugInfoEntryMinimal::getSubroutin<br>
> FunctionNameKind Kind) const {<br>
> if (!isSubroutineDIE() || Kind == FunctionNameKind::None)<br>
> return nullptr;<br>
> - // Try to get mangled name if possible.<br>
> - if (const char *name =<br>
> - getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, nullptr))<br>
> - return name;<br>
> - if (const char *name = getAttributeValueAsString(U, DW_AT_linkage_name,<br>
> - nullptr))<br>
> - return name;<br>
> + // Try to get mangled name only if it was asked for.<br>
> + if (Kind == FunctionNameKind::LinkageName) {<br>
> + if (const char *name =<br>
> + getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, nullptr))<br>
> + return name;<br>
> + if (const char *name =<br>
> + getAttributeValueAsString(U, DW_AT_linkage_name, nullptr))<br>
> + return name;<br>
> + }<br>
> if (const char *name = getAttributeValueAsString(U, DW_AT_name, nullptr))<br>
> return name;<br>
> // Try to get name from specification DIE.<br>
><br>
> Modified: llvm/trunk/test/DebugInfo/llvm-symbolizer.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer.test?rev=209050&r1=209049&r2=209050&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer.test?rev=209050&r1=209049&r2=209050&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/DebugInfo/llvm-symbolizer.test (original)<br>
> +++ llvm/trunk/test/DebugInfo/llvm-symbolizer.test Fri May 16 19:07:48 2014<br>
> @@ -10,7 +10,7 @@ RUN: echo "%p/Inputs/macho-universal:i38<br>
> RUN: echo "%p/Inputs/macho-universal:x86_64 0x100000f05" >> %t.input<br>
> RUN: echo "%p/Inputs/llvm-symbolizer-dwo-test 0x400514" >> %t.input<br>
><br>
> -RUN: llvm-symbolizer --functions --inlining --demangle=false \<br>
> +RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \<br>
> RUN: --default-arch=i386 < %t.input | FileCheck %s<br>
><br>
> CHECK: main<br>
> @@ -87,3 +87,9 @@ RUN: llvm-symbolizer --obj %p/Inputs/sha<br>
> RUN: | FileCheck %s --check-prefix=STRIPPED<br>
><br>
> STRIPPED: global_func<br>
> +<br>
> +RUN: echo "%p/Inputs/dwarfdump-test4.elf-x86-64 0x62c" > %t.input7<br>
> +RUN: llvm-symbolizer --functions=short --use-symbol-table=false --demangle=false < %t.input7 \<br>
> +RUN: | FileCheck %s --check-prefix=SHORT_FUNCTION_NAME<br>
> +<br>
> +SHORT_FUNCTION_NAME-NOT: _Z1cv<br>
><br>
> Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=209050&r1=209049&r2=209050&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=209050&r1=209049&r2=209050&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Fri May 16 19:07:48 2014<br>
> @@ -39,8 +39,7 @@ static DILineInfoSpecifier<br>
> getDILineInfoSpecifier(const LLVMSymbolizer::Options &Opts) {<br>
> return DILineInfoSpecifier(<br>
> DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,<br>
> - Opts.PrintFunctions ? DILineInfoSpecifier::FunctionNameKind::LinkageName<br>
> - : DILineInfoSpecifier::FunctionNameKind::None);<br>
> + Opts.PrintFunctions);<br>
> }<br>
><br>
> ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx)<br>
> @@ -117,7 +116,7 @@ DILineInfo ModuleInfo::symbolizeCode(<br>
> ModuleOffset, getDILineInfoSpecifier(Opts));<br>
> }<br>
> // Override function name from symbol table if necessary.<br>
> - if (Opts.PrintFunctions && Opts.UseSymbolTable) {<br>
> + if (Opts.PrintFunctions != FunctionNameKind::None && Opts.UseSymbolTable) {<br>
> std::string FunctionName;<br>
> uint64_t Start, Size;<br>
> if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset,<br>
> @@ -140,7 +139,7 @@ DIInliningInfo ModuleInfo::symbolizeInli<br>
> InlinedContext.addFrame(DILineInfo());<br>
> }<br>
> // Override the function name in lower frame with name from symbol table.<br>
> - if (Opts.PrintFunctions && Opts.UseSymbolTable) {<br>
> + if (Opts.PrintFunctions != FunctionNameKind::None && Opts.UseSymbolTable) {<br>
> DIInliningInfo PatchedInlinedContext;<br>
> for (uint32_t i = 0, n = InlinedContext.getNumberOfFrames(); i < n; i++) {<br>
> DILineInfo LineInfo = InlinedContext.getFrame(i);<br>
> @@ -398,7 +397,7 @@ std::string LLVMSymbolizer::printDILineI<br>
> // cannot fetch. We replace it to "??" to make our output closer to addr2line.<br>
> static const std::string kDILineInfoBadString = "<invalid>";<br>
> std::stringstream Result;<br>
> - if (Opts.PrintFunctions) {<br>
> + if (Opts.PrintFunctions != FunctionNameKind::None) {<br>
> std::string FunctionName = LineInfo.FunctionName;<br>
> if (FunctionName == kDILineInfoBadString)<br>
> FunctionName = kBadString;<br>
><br>
> Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h?rev=209050&r1=209049&r2=209050&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h?rev=209050&r1=209049&r2=209050&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h (original)<br>
> +++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h Fri May 16 19:07:48 2014<br>
> @@ -24,6 +24,7 @@<br>
><br>
> namespace llvm {<br>
><br>
> +typedef DILineInfoSpecifier::FunctionNameKind FunctionNameKind;<br>
> using namespace object;<br>
><br>
> namespace symbolize {<br>
> @@ -34,17 +35,17 @@ class LLVMSymbolizer {<br>
> public:<br>
> struct Options {<br>
> bool UseSymbolTable : 1;<br>
> - bool PrintFunctions : 1;<br>
> + FunctionNameKind PrintFunctions;<br>
> bool PrintInlining : 1;<br>
> bool Demangle : 1;<br>
> std::string DefaultArch;<br>
> - Options(bool UseSymbolTable = true, bool PrintFunctions = true,<br>
> + Options(bool UseSymbolTable = true,<br>
> + FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName,<br>
> bool PrintInlining = true, bool Demangle = true,<br>
> std::string DefaultArch = "")<br>
> : UseSymbolTable(UseSymbolTable), PrintFunctions(PrintFunctions),<br>
> PrintInlining(PrintInlining), Demangle(Demangle),<br>
> - DefaultArch(DefaultArch) {<br>
> - }<br>
> + DefaultArch(DefaultArch) {}<br>
> };<br>
><br>
> LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {}<br>
><br>
> Modified: llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=209050&r1=209049&r2=209050&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=209050&r1=209049&r2=209050&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp Fri May 16 19:07:48 2014<br>
> @@ -35,10 +35,15 @@ ClUseSymbolTable("use-symbol-table", cl:<br>
> cl::desc("Prefer names in symbol table to names "<br>
> "in debug info"));<br>
><br>
> -static cl::opt<bool><br>
> -ClPrintFunctions("functions", cl::init(true),<br>
> - cl::desc("Print function names as well as line "<br>
> - "information for a given address"));<br>
> +static cl::opt<FunctionNameKind> ClPrintFunctions(<br>
> + "functions", cl::init(FunctionNameKind::LinkageName),<br>
> + cl::desc("Print function name for a given address:"),<br>
> + cl::values(clEnumValN(FunctionNameKind::None, "none", "omit function name"),<br>
> + clEnumValN(FunctionNameKind::ShortName, "short",<br>
> + "print short function name"),<br>
> + clEnumValN(FunctionNameKind::LinkageName, "linkage",<br>
> + "print function linkage name"),<br>
> + clEnumValEnd));<br>
><br>
> static cl::opt<bool><br>
> ClPrintInlining("inlining", cl::init(true),<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Alexey Samsonov, Mountain View, CA</div></div>
</div></div>