Skip to content

Commit 39fec54

Browse files
committed
Revert "[symbolizer] Support symbol lookup"
This reverts commit 2b27948. On some buildbots the test LLVM::interrupts.test start failing.
1 parent 9aedb60 commit 39fec54

23 files changed

+41
-329
lines changed

llvm/docs/CommandGuide/llvm-symbolizer.rst

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ DESCRIPTION
1414
:program:`llvm-symbolizer` reads input names and addresses from the command-line
1515
and prints corresponding source code locations to standard output. It can also
1616
symbolize logs containing :doc:`Symbolizer Markup </SymbolizerMarkupFormat>` via
17-
:option:`--filter-markup`. Addresses may be specified as numbers or symbol names.
17+
:option:`--filter-markup`.
1818

1919
If no address is specified on the command-line, it reads the addresses from
2020
standard input. If no input name is specified on the command-line, but addresses
@@ -196,17 +196,6 @@ shows --relativenames.
196196
main
197197
foo/test.cpp:15:0
198198
199-
Example 7 - Addresses as symbol names:
200-
201-
.. code-block:: console
202-
203-
$ llvm-symbolizer --obj=test.elf main
204-
main
205-
/tmp/test.cpp:14:0
206-
$ llvm-symbolizer --obj=test.elf "CODE foz"
207-
foz
208-
/tmp/test.h:1:0
209-
210199
OPTIONS
211200
-------
212201

llvm/docs/ReleaseNotes.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ Changes to the LLVM tools
180180
* ``llvm-nm`` now supports the ``--line-numbers`` (``-l``) option to use
181181
debugging information to print symbols' filenames and line numbers.
182182

183-
* llvm-symbolizer and llvm-addr2line now support addresses specified as symbol names.
184-
185183
Changes to LLDB
186184
---------------------------------
187185

llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class SourceCode;
3434
struct Request {
3535
StringRef ModuleName;
3636
std::optional<uint64_t> Address;
37-
StringRef Symbol;
3837
};
3938

4039
class DIPrinter {
@@ -47,8 +46,6 @@ class DIPrinter {
4746
virtual void print(const Request &Request, const DIGlobal &Global) = 0;
4847
virtual void print(const Request &Request,
4948
const std::vector<DILocal> &Locals) = 0;
50-
virtual void print(const Request &Request,
51-
const std::vector<DILineInfo> &Locations) = 0;
5249

5350
virtual bool printError(const Request &Request,
5451
const ErrorInfoBase &ErrorInfo) = 0;
@@ -94,8 +91,6 @@ class PlainPrinterBase : public DIPrinter {
9491
void print(const Request &Request, const DIGlobal &Global) override;
9592
void print(const Request &Request,
9693
const std::vector<DILocal> &Locals) override;
97-
void print(const Request &Request,
98-
const std::vector<DILineInfo> &Locations) override;
9994

10095
bool printError(const Request &Request,
10196
const ErrorInfoBase &ErrorInfo) override;
@@ -146,8 +141,6 @@ class JSONPrinter : public DIPrinter {
146141
void print(const Request &Request, const DIGlobal &Global) override;
147142
void print(const Request &Request,
148143
const std::vector<DILocal> &Locals) override;
149-
void print(const Request &Request,
150-
const std::vector<DILineInfo> &Locations) override;
151144

152145
bool printError(const Request &Request,
153146
const ErrorInfoBase &ErrorInfo) override;

llvm/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ class SymbolizableModule {
3636
virtual std::vector<DILocal>
3737
symbolizeFrame(object::SectionedAddress ModuleOffset) const = 0;
3838

39-
virtual std::vector<object::SectionedAddress>
40-
findSymbol(StringRef Symbol) const = 0;
41-
4239
// Return true if this is a 32-bit x86 PE COFF module.
4340
virtual bool isWin32Module() const = 0;
4441

llvm/include/llvm/DebugInfo/Symbolize/SymbolizableObjectFile.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ class SymbolizableObjectFile : public SymbolizableModule {
4343
DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const override;
4444
std::vector<DILocal>
4545
symbolizeFrame(object::SectionedAddress ModuleOffset) const override;
46-
std::vector<object::SectionedAddress>
47-
findSymbol(StringRef Symbol) const override;
4846

4947
// Return true if this is a 32-bit x86 PE COFF module.
5048
bool isWin32Module() const override;

llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ class LLVMSymbolizer {
104104
Expected<std::vector<DILocal>>
105105
symbolizeFrame(ArrayRef<uint8_t> BuildID,
106106
object::SectionedAddress ModuleOffset);
107-
108-
Expected<std::vector<DILineInfo>> findSymbol(const ObjectFile &Obj,
109-
StringRef Symbol);
110-
Expected<std::vector<DILineInfo>> findSymbol(StringRef ModuleName,
111-
StringRef Symbol);
112-
Expected<std::vector<DILineInfo>> findSymbol(ArrayRef<uint8_t> BuildID,
113-
StringRef Symbol);
114-
115107
void flush();
116108

117109
// Evict entries from the binary cache until it is under the maximum size
@@ -154,9 +146,6 @@ class LLVMSymbolizer {
154146
Expected<std::vector<DILocal>>
155147
symbolizeFrameCommon(const T &ModuleSpecifier,
156148
object::SectionedAddress ModuleOffset);
157-
template <typename T>
158-
Expected<std::vector<DILineInfo>> findSymbolCommon(const T &ModuleSpecifier,
159-
StringRef Symbol);
160149

161150
Expected<SymbolizableModule *> getOrCreateModuleInfo(const ObjectFile &Obj);
162151

llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,6 @@ void PlainPrinterBase::print(const Request &Request,
260260
printFooter();
261261
}
262262

263-
void PlainPrinterBase::print(const Request &Request,
264-
const std::vector<DILineInfo> &Locations) {
265-
if (Locations.empty()) {
266-
print(Request, DILineInfo());
267-
} else {
268-
for (const DILineInfo &L : Locations)
269-
print(L, false);
270-
printFooter();
271-
}
272-
}
273-
274263
bool PlainPrinterBase::printError(const Request &Request,
275264
const ErrorInfoBase &ErrorInfo) {
276265
ErrHandler(ErrorInfo, Request.ModuleName);
@@ -284,8 +273,6 @@ static std::string toHex(uint64_t V) {
284273

285274
static json::Object toJSON(const Request &Request, StringRef ErrorMsg = "") {
286275
json::Object Json({{"ModuleName", Request.ModuleName.str()}});
287-
if (!Request.Symbol.empty())
288-
Json["SymName"] = Request.Symbol.str();
289276
if (Request.Address)
290277
Json["Address"] = toHex(*Request.Address);
291278
if (!ErrorMsg.empty())
@@ -375,19 +362,6 @@ void JSONPrinter::print(const Request &Request,
375362
printJSON(std::move(Json));
376363
}
377364

378-
void JSONPrinter::print(const Request &Request,
379-
const std::vector<DILineInfo> &Locations) {
380-
json::Array Definitions;
381-
for (const DILineInfo &L : Locations)
382-
Definitions.push_back(toJSON(L));
383-
json::Object Json = toJSON(Request);
384-
Json["Loc"] = std::move(Definitions);
385-
if (ObjectList)
386-
ObjectList->push_back(std::move(Json));
387-
else
388-
printJSON(std::move(Json));
389-
}
390-
391365
bool JSONPrinter::printError(const Request &Request,
392366
const ErrorInfoBase &ErrorInfo) {
393367
json::Object Json = toJSON(Request, ErrorInfo.message());

llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,19 +351,6 @@ std::vector<DILocal> SymbolizableObjectFile::symbolizeFrame(
351351
return DebugInfoContext->getLocalsForAddress(ModuleOffset);
352352
}
353353

354-
std::vector<object::SectionedAddress>
355-
SymbolizableObjectFile::findSymbol(StringRef Symbol) const {
356-
std::vector<object::SectionedAddress> Result;
357-
for (const SymbolDesc &Sym : Symbols) {
358-
if (Sym.Name.equals(Symbol)) {
359-
object::SectionedAddress A{Sym.Addr,
360-
getModuleSectionIndexForAddress(Sym.Addr)};
361-
Result.push_back(A);
362-
}
363-
}
364-
return Result;
365-
}
366-
367354
/// Search for the first occurence of specified Address in ObjectFile.
368355
uint64_t SymbolizableObjectFile::getModuleSectionIndexForAddress(
369356
uint64_t Address) const {

llvm/lib/DebugInfo/Symbolize/Symbolize.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -231,50 +231,6 @@ LLVMSymbolizer::symbolizeFrame(ArrayRef<uint8_t> BuildID,
231231
return symbolizeFrameCommon(BuildID, ModuleOffset);
232232
}
233233

234-
template <typename T>
235-
Expected<std::vector<DILineInfo>>
236-
LLVMSymbolizer::findSymbolCommon(const T &ModuleSpecifier, StringRef Symbol) {
237-
auto InfoOrErr = getOrCreateModuleInfo(ModuleSpecifier);
238-
if (!InfoOrErr)
239-
return InfoOrErr.takeError();
240-
241-
SymbolizableModule *Info = *InfoOrErr;
242-
std::vector<DILineInfo> Result;
243-
244-
// A null module means an error has already been reported. Return an empty
245-
// result.
246-
if (!Info)
247-
return Result;
248-
249-
for (object::SectionedAddress A : Info->findSymbol(Symbol)) {
250-
DILineInfo LineInfo = Info->symbolizeCode(
251-
A, DILineInfoSpecifier(Opts.PathStyle, Opts.PrintFunctions),
252-
Opts.UseSymbolTable);
253-
if (LineInfo.FileName != DILineInfo::BadString) {
254-
if (Opts.Demangle)
255-
LineInfo.FunctionName = DemangleName(LineInfo.FunctionName, Info);
256-
Result.push_back(LineInfo);
257-
}
258-
}
259-
260-
return Result;
261-
}
262-
263-
Expected<std::vector<DILineInfo>>
264-
LLVMSymbolizer::findSymbol(const ObjectFile &Obj, StringRef Symbol) {
265-
return findSymbolCommon(Obj, Symbol);
266-
}
267-
268-
Expected<std::vector<DILineInfo>>
269-
LLVMSymbolizer::findSymbol(StringRef ModuleName, StringRef Symbol) {
270-
return findSymbolCommon(ModuleName.str(), Symbol);
271-
}
272-
273-
Expected<std::vector<DILineInfo>>
274-
LLVMSymbolizer::findSymbol(ArrayRef<uint8_t> BuildID, StringRef Symbol) {
275-
return findSymbolCommon(BuildID, Symbol);
276-
}
277-
278234
void LLVMSymbolizer::flush() {
279235
ObjectForUBPathAndArch.clear();
280236
LRUBinaries.clear();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
something not a valid address
1+
some text
22
0x40054d
3-
some text possibly a symbol
3+
some text2

llvm/test/tools/llvm-symbolizer/Inputs/discrim.inp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ some text
55
0x4005b9
66
0x4005ce
77
0x4005d4
8-
another text
8+
some more text

llvm/test/tools/llvm-symbolizer/Inputs/symbols.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

llvm/test/tools/llvm-symbolizer/Inputs/symbols.part1.cpp

Lines changed: 0 additions & 25 deletions
This file was deleted.

llvm/test/tools/llvm-symbolizer/Inputs/symbols.part2.cpp

Lines changed: 0 additions & 18 deletions
This file was deleted.

llvm/test/tools/llvm-symbolizer/Inputs/symbols.part3.c

Lines changed: 0 additions & 12 deletions
This file was deleted.

llvm/test/tools/llvm-symbolizer/Inputs/symbols.part4.c

Lines changed: 0 additions & 13 deletions
This file was deleted.
Binary file not shown.

llvm/test/tools/llvm-symbolizer/output-style-json-code.test

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,39 @@
2525
# RUN: llvm-symbolizer --output-style=JSON --no-inlines -e %p/Inputs/addr.exe < %p/Inputs/addr.inp | \
2626
# RUN: FileCheck %s --check-prefix=NO-INLINES --strict-whitespace --match-full-lines --implicit-check-not={{.}}
2727
## Invalid first argument before any valid one.
28-
# NO-INLINES:{"Loc":[],"ModuleName":"{{.*}}/Inputs/addr.exe","SymName":"something"}
28+
# NO-INLINES:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
2929
## Resolve valid address.
3030
# NO-INLINES-NEXT:{"Address":"0x40054d","ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":3,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"main","Line":3,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":2}]}
3131
## Invalid argument after a valid one.
32-
# NO-INLINES-NEXT:{"Loc":[],"ModuleName":"{{.*}}/Inputs/addr.exe","SymName":"some"}
32+
# NO-INLINES-NEXT:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
3333

3434
## This test case is testing stdin input, inlines by default.
3535
# RUN: llvm-symbolizer --output-style=JSON -e %p/Inputs/addr.exe < %p/Inputs/addr.inp | \
3636
# RUN: FileCheck %s --check-prefix=INLINE --strict-whitespace --match-full-lines --implicit-check-not={{.}}
3737
## Invalid first argument before any valid one.
38-
# INLINE:{"Loc":[],"ModuleName":"{{.*}}/Inputs/addr.exe","SymName":"something"}
38+
# INLINE:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
3939
## Resolve valid address.
4040
# INLINE-NEXT:{"Address":"0x40054d","ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":3,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"inctwo","Line":3,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":2},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"inc","Line":7,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":6},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"main","Line":14,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":12}]}
4141
## Invalid argument after a valid one.
42-
# INLINE-NEXT:{"Loc":[],"ModuleName":"{{.*}}/Inputs/addr.exe","SymName":"some"}
42+
# INLINE-NEXT:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
4343

4444
## Also check the last test case with llvm-adr2line.
4545
## The expected result is the same with -f -i.
4646
# RUN: llvm-addr2line --output-style=JSON -f -i -e %p/Inputs/addr.exe < %p/Inputs/addr.inp | \
4747
# RUN: FileCheck %s --check-prefix=INLINE-A2L --strict-whitespace --match-full-lines --implicit-check-not={{.}}
4848
## Invalid first argument before any valid one.
49-
# INLINE-A2L:{"Loc":[],"ModuleName":"{{.*}}/Inputs/addr.exe","SymName":"something"}
49+
# INLINE-A2L:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
5050
## Resolve valid address.
5151
# INLINE-A2L-NEXT:{"Address":"0x40054d","ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":3,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"inctwo","Line":3,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":2},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"inc","Line":7,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":6},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"main","Line":14,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":12}]}
5252
## Invalid argument after a valid one.
53-
# INLINE-A2L:{"Loc":[],"ModuleName":"{{.*}}/Inputs/addr.exe","SymName":"some"}
53+
# INLINE-A2L-NEXT:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
5454

5555
## Note llvm-addr2line without -f does not print the function name in JSON too.
5656
# RUN: llvm-addr2line --output-style=JSON -i -e %p/Inputs/addr.exe < %p/Inputs/addr.inp | \
5757
# RUN: FileCheck %s --check-prefix=NO-FUNC-A2L --strict-whitespace --match-full-lines --implicit-check-not={{.}}
5858
## Invalid first argument before any valid one.
59-
# NO-FUNC-A2L:{"Loc":[],"ModuleName":"{{.*}}/Inputs/addr.exe","SymName":"something"}
59+
# NO-FUNC-A2L:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}
6060
## Resolve valid address.
6161
# NO-FUNC-A2L-NEXT:{"Address":"0x40054d","ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":3,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"","Line":3,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":2},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"","Line":7,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":6},{"Column":0,"Discriminator":0,"FileName":"/tmp{{/|\\\\}}x.c","FunctionName":"","Line":14,"StartAddress":"0x400540","StartFileName":"/tmp{{/|\\\\}}x.c","StartLine":12}]}
6262
## Invalid argument after a valid one.
63-
# NO-FUNC-A2L-NEXT:{"Loc":[],"ModuleName":"{{.*}}/Inputs/addr.exe","SymName":"some"}
64-
65-
## When a module offset is specified by a symbol, more than one source location can be found.
66-
# RUN: llvm-symbolizer --output-style=JSON --no-inlines -e %p/Inputs/symbols.so "static_func" | \
67-
# RUN: FileCheck %s --check-prefix=MULTIPLE --strict-whitespace --match-full-lines --implicit-check-not={{.}}
68-
# MULTIPLE:[{"Loc":[{"Column":24,"Discriminator":0,"FileName":"/tmp/dbginfo{{/|\\\\}}symbols.part3.c","FunctionName":"static_func","Line":4,"StartAddress":"0x121d","StartFileName":"/tmp/dbginfo{{/|\\\\}}symbols.part3.c","StartLine":4},{"Column":24,"Discriminator":0,"FileName":"/tmp/dbginfo{{/|\\\\}}symbols.part4.c","FunctionName":"static_func","Line":4,"StartAddress":"0x125f","StartFileName":"/tmp/dbginfo{{/|\\\\}}symbols.part4.c","StartLine":4}],"ModuleName":"{{.*}}Inputs/symbols.so","SymName":"static_func"}]
63+
# NO-FUNC-A2L-NEXT:{"ModuleName":"{{.*}}/Inputs/addr.exe","Symbol":[{"Column":0,"Discriminator":0,"FileName":"","FunctionName":"","Line":0,"StartAddress":"","StartFileName":"","StartLine":0}]}

0 commit comments

Comments
 (0)