[PATCH] D67390: [LLDB][ELF] Load both, .symtab and .dynsym sections

Konrad Wilhelm Kleine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 02:17:03 PDT 2019


kwk added a comment.

@clayborg thank you for this explanation. My patch for minidebuginfo is already done in D66791 <https://reviews.llvm.org/D66791> . But this one here I was asked to pull out as a separate patch. For good reasons as we see. I wonder how this extra parameter `SymbolMapType` of yours does help. In the end I have to identify duplicates. But if no symbol with the same **name** should be added then why do I care about where the symbol is coming from?

Please help me understand of follow my thoughts here:

When I'm in the `(lldb)` console and type `b foo` I expect LLDB to set a breakpoint on the **function** foo, right? The type of the symbol `foo` is deduced as **function**. I ask this question because `Symtab` has no function to just search for a symbol by name; instead you always have to pass an address, a type or an ID:

  Symbol *FindSymbolByID(lldb::user_id_t uid) const;
  Symbol *FindSymbolWithType(lldb::SymbolType symbol_type,
  size_t FindAllSymbolsWithNameAndType(ConstString name,
  size_t FindAllSymbolsWithNameAndType(ConstString name,
  size_t FindAllSymbolsMatchingRexExAndType(
  Symbol *FindFirstSymbolWithNameAndType(ConstString name,
  Symbol *FindSymbolAtFileAddress(lldb::addr_t file_addr);
  Symbol *FindSymbolContainingFileAddress(lldb::addr_t file_addr);
  size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask,

So my point of this whole question is: What makes a symbol unique in the sense that it shouldn't be added to the symtab if it is already there?

Shouldn't the type of the symbol together with it's name define uniqueness? We shouldn't care about where the symbol is coming from nor if it is located at a different address. Well, if there's an overloaded function `foo(int)` and `foo(char*)` then both symbols are of type **function** and they both share the same **name**. When you type `b foo` you DO want 2 breakpoints to be set. Hence, niqueness cannot be defined over the name and the type . But wait, the **name** is mangled, so it IS unique enough unless I use `Symbol::GetNameNoArguments()`; there only the name is returned.

Here's my naive approach to test the admittedly very weird thought process from above: https://github.com/kwk/llvm-project/commit/5da4559a00c73ebefd8f8199890bd1991c94fa3f


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67390/new/

https://reviews.llvm.org/D67390





More information about the llvm-commits mailing list