[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2023-03-17 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a subscriber: phosek.
kwk added a comment.

@iridinite please see these:

- https://discourse.llvm.org/t/http-library-in-llvm/56317/10
- https://discourse.llvm.org/t/rfc-building-llvm-debuginfod/59011
- https://discourse.llvm.org/t/rfc-building-llvm-debuginfod/58994
- https://discourse.llvm.org/t/debuginfod-credential-helper-rfc/64092

I suggest, you contact @phosek on the status of debuginfod implementation in 
LLVM. I'd love to know where it is at, so please leave a trace ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2023-03-17 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

Looks like it  is already there: 
https://github.com/llvm/llvm-project/tree/main/llvm/include/llvm/Debuginfod


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2023-03-17 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk abandoned this revision.
kwk added a comment.

There already is a Debuginfod implementation in LLVM by now. Abandoning 
revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs

2023-05-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk accepted this revision.
kwk added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149641

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Optionally follow DW_AT_decl_file when setting breakpoint

2020-02-11 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath @jingham to summarize from what I read here and what I chatted about 
with @labath , the following  is a possible way to go for now, right?

1. We're not going to introduce my flag.
2. You're both not perfectly happy with the way things are documented at the 
moment and dislike some of the implementation as in in LLDB but chaning it 
should not be part of this patch.
3. @jingham wouldn't want to introduce `--compile-unit` as a flag that @labath 
proposed.
4. You want `breakpoint set --file` to search everything, that is to say 
compilation units and files referenced in `DW_AT_decl_file`.

If you can confirm that this is correct, then I can refactor this patch to 
remove the switch and change the default behavior for `breakpoint set --file`. 
Especially point 4. is important I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74650: [lldb] WIP: idea for keeping filenames in raw form when coming from DWARF

2020-02-14 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
kwk added a reviewer: labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

PLEASE DO NOT REVIEW YET. This is for brainstorming an idea with @labath


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74650

Files:
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Utility/FileSpec.cpp

Index: lldb/source/Utility/FileSpec.cpp
===
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -68,8 +68,9 @@
 FileSpec::FileSpec() : m_style(GetNativeStyle()) {}
 
 // Default constructor that can take an optional full path to a file on disk.
-FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) {
-  SetFile(path, style);
+FileSpec::FileSpec(llvm::StringRef path, Style style, bool normalize)
+: m_style(style) {
+  SetFile(path, style, normalize);
 }
 
 FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &triple)
@@ -171,7 +172,7 @@
 // Update the contents of this object with a new path. The path will be split
 // up into a directory and filename and stored as uniqued string values for
 // quick comparison and efficient memory usage.
-void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
+void FileSpec::SetFile(llvm::StringRef pathname, Style style, bool normalize) {
   m_filename.Clear();
   m_directory.Clear();
   m_is_resolved = false;
@@ -183,11 +184,11 @@
   llvm::SmallString<128> resolved(pathname);
 
   // Normalize the path by removing ".", ".." and other redundant components.
-  if (needsNormalization(resolved))
+  if (normalize && needsNormalization(resolved))
 llvm::sys::path::remove_dots(resolved, true, m_style);
 
   // Normalize back slashes to forward slashes
-  if (m_style == Style::windows)
+  if (normalize && m_style == Style::windows)
 std::replace(resolved.begin(), resolved.end(), '\\', '/');
 
   if (resolved.empty()) {
@@ -213,6 +214,10 @@
   return SetFile(path, triple.isOSWindows() ? Style::windows : Style::posix);
 }
 
+bool FileSpec::IsNormalized() const {
+  return *this == FileSpec(GetPath(), m_style, true);
+}
+
 // Convert to pointer operator. This allows code to check any FileSpec objects
 // to see if they contain anything valid using code such as:
 //
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -213,7 +213,7 @@
 remapped_file = std::move(*file_path);
 
 // Unconditionally add an entry, so the indices match up.
-support_files.EmplaceBack(remapped_file, style);
+support_files.EmplaceBack(remapped_file, style, false);
   }
 
   return support_files;
Index: lldb/include/lldb/Utility/FileSpec.h
===
--- lldb/include/lldb/Utility/FileSpec.h
+++ lldb/include/lldb/Utility/FileSpec.h
@@ -70,8 +70,12 @@
   /// \param[in] style
   /// The style of the path
   ///
+  /// \param[in] normalize
+  /// Whether or not to cleanup the filepath or not.
+  ///
   /// \see FileSpec::SetFile (const char *path)
-  explicit FileSpec(llvm::StringRef path, Style style = Style::native);
+  explicit FileSpec(llvm::StringRef path, Style style = Style::native,
+bool normalize = true);
 
   explicit FileSpec(llvm::StringRef path, const llvm::Triple &triple);
 
@@ -348,7 +352,10 @@
   ///
   /// \param[in] style
   /// The style for the given path.
-  void SetFile(llvm::StringRef path, Style style);
+  ///
+  /// \param[in] normalize
+  /// Whether or not to cleanup the filepath or not.
+  void SetFile(llvm::StringRef path, Style style, bool normalize = true);
 
   /// Change the file specified with a new path.
   ///
@@ -363,6 +370,10 @@
   /// The triple which is used to set the Path style.
   void SetFile(llvm::StringRef path, const llvm::Triple &triple);
 
+  /// \returns \c true if the normalized FileSpec is the same as this; otherwise
+  /// \c false is returned.
+  bool IsNormalized() const;
+
   bool IsResolved() const { return m_is_resolved; }
 
   /// Set if the file path has been resolved or not.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74895: [lldb]: fix typo in lldb-gdb-remote.txt

2020-02-20 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
kwk added a reviewer: labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The logic of the sentence made more sense when "with" is replaced with 
"without".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74895

Files:
  lldb/docs/lldb-gdb-remote.txt


Index: lldb/docs/lldb-gdb-remote.txt
===
--- lldb/docs/lldb-gdb-remote.txt
+++ lldb/docs/lldb-gdb-remote.txt
@@ -3,7 +3,7 @@
 correct GDB server when debugging. If you have mismatch, then things go wrong
 very quickly. LLDB makes extensive use of the GDB remote protocol and we
 wanted to make sure that the experience was a bit more dynamic where we can
-discover information about a remote target with having to know anything up
+discover information about a remote target without having to know anything up
 front. We also ran into performance issues with the existing GDB remote
 protocol that can be overcome when using a reliable communications layer.
 Some packets improve performance, others allow for remote process launching


Index: lldb/docs/lldb-gdb-remote.txt
===
--- lldb/docs/lldb-gdb-remote.txt
+++ lldb/docs/lldb-gdb-remote.txt
@@ -3,7 +3,7 @@
 correct GDB server when debugging. If you have mismatch, then things go wrong
 very quickly. LLDB makes extensive use of the GDB remote protocol and we
 wanted to make sure that the experience was a bit more dynamic where we can
-discover information about a remote target with having to know anything up
+discover information about a remote target without having to know anything up
 front. We also ran into performance issues with the existing GDB remote
 protocol that can be overcome when using a reliable communications layer.
 Some packets improve performance, others allow for remote process launching
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74895: [lldb]: fix typo in lldb-gdb-remote.txt

2020-02-20 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc7b7f76ae6ae: [lldb]: fix typo in lldb-gdb-remote.txt 
(authored by kwk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74895

Files:
  lldb/docs/lldb-gdb-remote.txt


Index: lldb/docs/lldb-gdb-remote.txt
===
--- lldb/docs/lldb-gdb-remote.txt
+++ lldb/docs/lldb-gdb-remote.txt
@@ -3,7 +3,7 @@
 correct GDB server when debugging. If you have mismatch, then things go wrong
 very quickly. LLDB makes extensive use of the GDB remote protocol and we
 wanted to make sure that the experience was a bit more dynamic where we can
-discover information about a remote target with having to know anything up
+discover information about a remote target without having to know anything up
 front. We also ran into performance issues with the existing GDB remote
 protocol that can be overcome when using a reliable communications layer.
 Some packets improve performance, others allow for remote process launching


Index: lldb/docs/lldb-gdb-remote.txt
===
--- lldb/docs/lldb-gdb-remote.txt
+++ lldb/docs/lldb-gdb-remote.txt
@@ -3,7 +3,7 @@
 correct GDB server when debugging. If you have mismatch, then things go wrong
 very quickly. LLDB makes extensive use of the GDB remote protocol and we
 wanted to make sure that the experience was a bit more dynamic where we can
-discover information about a remote target with having to know anything up
+discover information about a remote target without having to know anything up
 front. We also ran into performance issues with the existing GDB remote
 protocol that can be overcome when using a reliable communications layer.
 Some packets improve performance, others allow for remote process launching
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Optionally follow DW_AT_decl_file when setting breakpoint

2020-02-24 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 246160.
kwk added a comment.

Updated tests and code to remove the --search-source-files flag and make it the 
default behavior to also search source files.

TODO: rename class SearchFilterByModuleListAndCU to something more meaningful 
when an agreement on the behavior was made.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Target/Target.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
  lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
  lldb/test/Shell/Breakpoint/search-support-files.test

Index: lldb/test/Shell/Breakpoint/search-support-files.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/search-support-files.test
@@ -0,0 +1,51 @@
+# In these tests we will set breakpoints on a function by name. That function
+# is defined in a header file (search-support-files.h) and will therefore be
+# inlined into the file that includes it (search-support-files.cpp).
+#
+# TODO(kwk): Check that we can also do the same with C++ methods in files?
+#(See https://lldb.llvm.org/use/tutorial.html and look for --method.)
+
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: %build %p/Inputs/search-support-files.cpp -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck --color --dump-input=fail %s 
+
+#---
+# Set breakpoint by function name.
+
+breakpoint set -n inlined_42
+# CHECK: (lldb) breakpoint set -n inlined_42
+# CHECK-NEXT: Breakpoint 1: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}}
+
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 2: where = dummy.out`main + 22 at search-support-files.cpp:5:11, address = 0x0{{.*}}
+
+#---
+# Set breakpoint by function name and filename (the one in which the function is
+# inlined, aka the compilation unit).
+
+breakpoint set -n inlined_42 -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n inlined_42 -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 3: no locations (pending).
+
+#---
+# Set breakpoint by function name and source filename (the file in which the
+# function is defined).
+#
+# NOTE: This test is the really interesting one as it shows that we can now
+#   search by source files that are themselves no compulation units.
+
+breakpoint set -n inlined_42 -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n inlined_42 -f search-support-files.h
+# CHECK-NEXT: Breakpoint 4: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}}
+
+#---
+# Set breakpoint by function name and source filename. This time the file
+# doesn't exist to prove that we haven't widen the search space too much. When
+# we search for a function in file that doesn't exist, we should get no results.
+
+breakpoint set -n inlined_42 -f file-not-existing.h
+# CHECK: (lldb) breakpoint set -n inlined_42 -f file-not-existing.h
+# CHECK-NEXT: Breakpoint 5: no locations (pending).
+# CHECK-NEXT: WARNING: Unable to resolve breakpoint to any actual locations.
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
@@ -0,0 +1 @@
+int return_zero() { return 0; }
\ No newline at end of file
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
@@ -0,0 +1 @@
+int inlined_42() { return 42; }
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
@@ -0,0 +1,7 @@
+#include "search-support-files.h"
+#include "search-support-files2.h"
+
+int main(int argc, char *argv[]) {
+  int a = inlined_42();
+  return return_zero() + a;
+}
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -324,7 +324,7 @@
   

[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Optionally follow DW_AT_decl_file when setting breakpoint

2020-02-24 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 246162.
kwk added a comment.

- Clear formatting
- Make list private again
- Remove open from CommandObjectBreakpoint.cpp
- Remove change in unrelated file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
  lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
  lldb/test/Shell/Breakpoint/search-support-files.test

Index: lldb/test/Shell/Breakpoint/search-support-files.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/search-support-files.test
@@ -0,0 +1,51 @@
+# In these tests we will set breakpoints on a function by name. That function
+# is defined in a header file (search-support-files.h) and will therefore be
+# inlined into the file that includes it (search-support-files.cpp).
+#
+# TODO(kwk): Check that we can also do the same with C++ methods in files?
+#(See https://lldb.llvm.org/use/tutorial.html and look for --method.)
+
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: %build %p/Inputs/search-support-files.cpp -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck --color --dump-input=fail %s 
+
+#---
+# Set breakpoint by function name.
+
+breakpoint set -n inlined_42
+# CHECK: (lldb) breakpoint set -n inlined_42
+# CHECK-NEXT: Breakpoint 1: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}}
+
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 2: where = dummy.out`main + 22 at search-support-files.cpp:5:11, address = 0x0{{.*}}
+
+#---
+# Set breakpoint by function name and filename (the one in which the function is
+# inlined, aka the compilation unit).
+
+breakpoint set -n inlined_42 -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n inlined_42 -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 3: no locations (pending).
+
+#---
+# Set breakpoint by function name and source filename (the file in which the
+# function is defined).
+#
+# NOTE: This test is the really interesting one as it shows that we can now
+#   search by source files that are themselves no compulation units.
+
+breakpoint set -n inlined_42 -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n inlined_42 -f search-support-files.h
+# CHECK-NEXT: Breakpoint 4: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}}
+
+#---
+# Set breakpoint by function name and source filename. This time the file
+# doesn't exist to prove that we haven't widen the search space too much. When
+# we search for a function in file that doesn't exist, we should get no results.
+
+breakpoint set -n inlined_42 -f file-not-existing.h
+# CHECK: (lldb) breakpoint set -n inlined_42 -f file-not-existing.h
+# CHECK-NEXT: Breakpoint 5: no locations (pending).
+# CHECK-NEXT: WARNING: Unable to resolve breakpoint to any actual locations.
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
@@ -0,0 +1 @@
+int return_zero() { return 0; }
\ No newline at end of file
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
@@ -0,0 +1 @@
+int inlined_42() { return 42; }
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
@@ -0,0 +1,7 @@
+#include "search-support-files.h"
+#include "search-support-files2.h"
+
+int main(int argc, char *argv[]) {
+  int a = inlined_42();
+  return return_zero() + a;
+}
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -324,7 +324,7 @@
   LazyBool check_inlines,
   LazyBool skip_prologue, bool internal,
   bool hardware,
-  LazyBool move_to_nearest_code) {
+ 

[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-02-24 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

I figured it might be the easiest to re-use `SearchFilterByModuleListAndCU` but 
it needs to be renamed still. If you have a good suggestion, please let me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-02-24 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath @jingham Can you please have a look at the 
`lldb/test/Shell/Breakpoint/search-support-files.test` to see if the test 
reflects the desired behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74650: [lldb] WIP: idea for keeping filenames in raw form when coming from DWARF

2020-02-24 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk abandoned this revision.
kwk added a comment.

I abandon this revision because @labath mentioned that in the past we must have 
had something similar: two file specs where one was normalized and one doesn't 
and then the behavior was not very predictable. I hope this recaptures our 
conversation on IRC well enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74650



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.
kwk planned changes to this revision.

This first patch does the heavy lifting of bootstrapping debuginfod with
CMake and integrating it to find a source file using debuginfod when
using `(lldb) source list` and the file cannot be found locally.

TODOs:

- tests are missing
- fetching debuginfo from debuginfod is missing

Read more about debuginfod here:
https://sourceware.org/elfutils/Debuginfod.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp

Index: lldb/source/Host/common/DebugInfoD.cpp
===
--- /dev/null
+++ lldb/source/Host/common/DebugInfoD.cpp
@@ -0,0 +1,119 @@
+//===-- DebugInfoD.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Module.h"
+#include "lldb/Host/Config.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+#if LLDB_ENABLE_DEBUGINFOD
+#include "elfutils/debuginfod.h"
+#endif
+
+namespace lldb_private {
+
+namespace debuginfod {
+
+using namespace lldb;
+using namespace lldb_private;
+
+#if !LLDB_ENABLE_DEBUGINFOD
+bool isAvailable() { return false; }
+
+llvm::Expected getBuildIDFromModule(const ModuleSP &module) {
+  llvm_unreachable("debuginfod::getBuildIDFromModule is unavailable");
+};
+
+llvm::Error findSource(UUID buildID, const std::string &path,
+   std::string &cache_path, sys::TimePoint<> &mod_time) {
+  llvm_unreachable("debuginfod::findSource is unavailable");
+}
+
+#else // LLDB_ENABLE_DEBUGINFOD
+
+bool isAvailable() { return true; }
+
+llvm::Expected getBuildIDFromModule(const ModuleSP &module) {
+  UUID buildID;
+
+  if (!module)
+return buildID;
+
+  const FileSpec &moduleFileSpec = module->GetFileSpec();
+  ModuleSpecList specList;
+  size_t nSpecs =
+  ObjectFile::GetModuleSpecifications(moduleFileSpec, 0, 0, specList);
+
+  for (size_t i = 0; i < nSpecs; i++) {
+ModuleSpec spec;
+if (!specList.GetModuleSpecAtIndex(i, spec))
+  continue;
+
+const UUID &uuid = spec.GetUUID();
+if (!uuid.IsValid())
+  continue;
+
+buildID = uuid;
+break;
+  }
+  return buildID;
+}
+
+llvm::Error findSource(UUID buildID, const std::string &path,
+   std::string &result_path) {
+  if (!buildID.IsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid build ID: %s",
+   buildID.GetAsString("").c_str());
+
+  debuginfod_client *client = debuginfod_begin();
+
+  if (!client)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"failed to create debuginfod connection handle: %s", strerror(errno));
+
+  // debuginfod_set_progressfn(client, [](debuginfod_client *client, long a,
+  // long b) -> int {
+  //   fprintf(stderr, "KWK === a: %ld b : %ld \n", a, b);
+  //   return 0; // continue
+  // });
+
+  char *cache_path = nullptr;
+  int rc = debuginfod_find_source(client, buildID.GetBytes().data(),
+  buildID.GetBytes().size(), path.c_str(),
+  &cache_path);
+
+  if (rc < 0)
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "buginfod_find_source query failed: %s",
+   strerror(-rc));
+
+  if (cache_path) {
+result_path = std::string(cache_path);
+free(cache_path);
+  }
+
+  llvm::Error err = llvm::Error::success();
+  if (close(rc) < 0) {
+err = llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"failed to close result of call to debuginfo_find_source: %s",
+strerror(errno));
+  }
+
+  debuginfod_end(client);
+
+  return err;
+}
+
+#endif // LLDB_ENABLE_DEBUGINFOD
+
+} // end of namespace debuginfod
+} // namespace lldb_private
Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -30,6 +30,7 @@
   common/HostThread.cpp
   common/LockFileBase.cpp
   common/LZMA.cpp
+  common/DebugInfoD.cpp
   common/MainLoop.cpp
   common/MonitoringProcessLauncher

[Lldb-commits] [PATCH] D75753: Simplified return type of getBuildIDFromModule

2020-03-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
kwk added a child revision: D75754: Fix typo.
kwk abandoned this revision.
kwk added a comment.

I didn't intend to create a new revision.


Depends on D75750 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75753

Files:
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/common/DebugInfoD.cpp


Index: lldb/source/Host/common/DebugInfoD.cpp
===
--- lldb/source/Host/common/DebugInfoD.cpp
+++ lldb/source/Host/common/DebugInfoD.cpp
@@ -11,6 +11,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "lldb/Host/DebugInfoD.h"
 
 #if LLDB_ENABLE_DEBUGINFOD
 #include "elfutils/debuginfod.h"
@@ -26,7 +27,7 @@
 #if !LLDB_ENABLE_DEBUGINFOD
 bool isAvailable() { return false; }
 
-llvm::Expected getBuildIDFromModule(const ModuleSP &module) {
+UUID getBuildIDFromModule(const ModuleSP &module) {
   llvm_unreachable("debuginfod::getBuildIDFromModule is unavailable");
 };
 
@@ -39,7 +40,7 @@
 
 bool isAvailable() { return true; }
 
-llvm::Expected getBuildIDFromModule(const ModuleSP &module) {
+UUID getBuildIDFromModule(const ModuleSP &module) {
   UUID buildID;
 
   if (!module)
Index: lldb/source/Core/SourceManager.cpp
===
--- lldb/source/Core/SourceManager.cpp
+++ lldb/source/Core/SourceManager.cpp
@@ -460,25 +460,18 @@
   // Try finding the file using elfutils' debuginfod
   if (!FileSystem::Instance().Exists(m_file_spec) &&
   debuginfod::isAvailable() && sc.module_sp) {
-llvm::Expected buildID =
-debuginfod::getBuildIDFromModule(sc.module_sp);
-if (auto err = buildID.takeError()) {
-  sc.module_sp->ReportWarning("An error occurred while getting the "
-  "build ID from the module: %s",
+UUID buildID = debuginfod::getBuildIDFromModule(sc.module_sp);
+std::string cache_path;
+llvm::Error err =
+debuginfod::findSource(buildID, file_spec.GetCString(), 
cache_path);
+if (err) {
+  sc.module_sp->ReportWarning("An error occurred while finding the "
+  "source file %s using debuginfod: %s",
+  file_spec.GetCString(),
   llvm::toString(std::move(err)).c_str());
 } else {
-  std::string cache_path;
-  err = debuginfod::findSource(*buildID, file_spec.GetCString(),
-   cache_path);
-  if (err) {
-sc.module_sp->ReportWarning("An error occurred while finding the "
-"source file %s using debuginfod: %s",
-file_spec.GetCString(),
-
llvm::toString(std::move(err)).c_str());
-  } else {
-m_file_spec = FileSpec(cache_path);
-m_mod_time = 
FileSystem::Instance().GetModificationTime(cache_path);
-  }
+  m_file_spec = FileSpec(cache_path);
+  m_mod_time = FileSystem::Instance().GetModificationTime(cache_path);
 }
   }
 }
Index: lldb/include/lldb/Host/DebugInfoD.h
===
--- lldb/include/lldb/Host/DebugInfoD.h
+++ lldb/include/lldb/Host/DebugInfoD.h
@@ -21,7 +21,7 @@

 bool isAvailable();
 
-llvm::Expected getBuildIDFromModule(const lldb::ModuleSP &module);
+UUID getBuildIDFromModule(const lldb::ModuleSP &module);
 
 llvm::Error findSource(UUID buildID, const std::string &path,
std::string &result_path);


Index: lldb/source/Host/common/DebugInfoD.cpp
===
--- lldb/source/Host/common/DebugInfoD.cpp
+++ lldb/source/Host/common/DebugInfoD.cpp
@@ -11,6 +11,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "lldb/Host/DebugInfoD.h"
 
 #if LLDB_ENABLE_DEBUGINFOD
 #include "elfutils/debuginfod.h"
@@ -26,7 +27,7 @@
 #if !LLDB_ENABLE_DEBUGINFOD
 bool isAvailable() { return false; }
 
-llvm::Expected getBuildIDFromModule(const ModuleSP &module) {
+UUID getBuildIDFromModule(const ModuleSP &module) {
   llvm_unreachable("debuginfod::getBuildIDFromModule is unavailable");
 };
 
@@ -39,7 +40,7 @@
 
 bool isAvailable() { return true; }
 
-llvm::Expected getBuildIDFromModule(const ModuleSP &module) {
+UUID getBuildIDFromModule(const ModuleSP &module) {
   UUID buildID;
 
   if (!module)
Index: lldb/source/Core/SourceManager.cpp
===
--- lldb/source/Core/SourceManager.cpp
+++ lldb/source/

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 248746.
kwk added a comment.

- Simplified return type of getBuildIDFromModule
- fixed typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp

Index: lldb/source/Host/common/DebugInfoD.cpp
===
--- /dev/null
+++ lldb/source/Host/common/DebugInfoD.cpp
@@ -0,0 +1,120 @@
+//===-- DebugInfoD.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Module.h"
+#include "lldb/Host/Config.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include "lldb/Host/DebugInfoD.h"
+
+#if LLDB_ENABLE_DEBUGINFOD
+#include "elfutils/debuginfod.h"
+#endif
+
+namespace lldb_private {
+
+namespace debuginfod {
+
+using namespace lldb;
+using namespace lldb_private;
+
+#if !LLDB_ENABLE_DEBUGINFOD
+bool isAvailable() { return false; }
+
+UUID getBuildIDFromModule(const ModuleSP &module) {
+  llvm_unreachable("debuginfod::getBuildIDFromModule is unavailable");
+};
+
+llvm::Error findSource(UUID buildID, const std::string &path,
+   std::string &cache_path, sys::TimePoint<> &mod_time) {
+  llvm_unreachable("debuginfod::findSource is unavailable");
+}
+
+#else // LLDB_ENABLE_DEBUGINFOD
+
+bool isAvailable() { return true; }
+
+UUID getBuildIDFromModule(const ModuleSP &module) {
+  UUID buildID;
+
+  if (!module)
+return buildID;
+
+  const FileSpec &moduleFileSpec = module->GetFileSpec();
+  ModuleSpecList specList;
+  size_t nSpecs =
+  ObjectFile::GetModuleSpecifications(moduleFileSpec, 0, 0, specList);
+
+  for (size_t i = 0; i < nSpecs; i++) {
+ModuleSpec spec;
+if (!specList.GetModuleSpecAtIndex(i, spec))
+  continue;
+
+const UUID &uuid = spec.GetUUID();
+if (!uuid.IsValid())
+  continue;
+
+buildID = uuid;
+break;
+  }
+  return buildID;
+}
+
+llvm::Error findSource(UUID buildID, const std::string &path,
+   std::string &result_path) {
+  if (!buildID.IsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid build ID: %s",
+   buildID.GetAsString("").c_str());
+
+  debuginfod_client *client = debuginfod_begin();
+
+  if (!client)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"failed to create debuginfod connection handle: %s", strerror(errno));
+
+  // debuginfod_set_progressfn(client, [](debuginfod_client *client, long a,
+  // long b) -> int {
+  //   fprintf(stderr, "KWK === a: %ld b : %ld \n", a, b);
+  //   return 0; // continue
+  // });
+
+  char *cache_path = nullptr;
+  int rc = debuginfod_find_source(client, buildID.GetBytes().data(),
+  buildID.GetBytes().size(), path.c_str(),
+  &cache_path);
+
+  if (rc < 0)
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "debuginfod_find_source query failed: %s",
+   strerror(-rc));
+
+  if (cache_path) {
+result_path = std::string(cache_path);
+free(cache_path);
+  }
+
+  llvm::Error err = llvm::Error::success();
+  if (close(rc) < 0) {
+err = llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"failed to close result of call to debuginfo_find_source: %s",
+strerror(errno));
+  }
+
+  debuginfod_end(client);
+
+  return err;
+}
+
+#endif // LLDB_ENABLE_DEBUGINFOD
+
+} // end of namespace debuginfod
+} // namespace lldb_private
Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -30,6 +30,7 @@
   common/HostThread.cpp
   common/LockFileBase.cpp
   common/LZMA.cpp
+  common/DebugInfoD.cpp
   common/MainLoop.cpp
   common/MonitoringProcessLauncher.cpp
   common/NativeProcessProtocol.cpp
@@ -161,6 +162,9 @@
 if (LLDB_ENABLE_LZMA)
   list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES})
 endif()
+if (LLDB_ENABLE_DEBUGINFOD)
+  list(APPEND EXTRA_LIBS ${Debuginfod_LIBRARIES})
+endif()
 if (WIN32)
   list(APPEND LLDB_SYSTEM_LIBS psapi)
 endif ()
Index: lld

[Lldb-commits] [PATCH] D75754: Fix typo

2020-03-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
kwk abandoned this revision.
kwk added a comment.

I didn't intend to create a new revision.


Depends on D75753 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75754

Files:
  lldb/source/Host/common/DebugInfoD.cpp


Index: lldb/source/Host/common/DebugInfoD.cpp
===
--- lldb/source/Host/common/DebugInfoD.cpp
+++ lldb/source/Host/common/DebugInfoD.cpp
@@ -93,7 +93,7 @@
 
   if (rc < 0)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "buginfod_find_source query failed: %s",
+   "debuginfod_find_source query failed: %s",
strerror(-rc));
 
   if (cache_path) {


Index: lldb/source/Host/common/DebugInfoD.cpp
===
--- lldb/source/Host/common/DebugInfoD.cpp
+++ lldb/source/Host/common/DebugInfoD.cpp
@@ -93,7 +93,7 @@
 
   if (rc < 0)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "buginfod_find_source query failed: %s",
+   "debuginfod_find_source query failed: %s",
strerror(-rc));
 
   if (cache_path) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75753: Simplified return type of getBuildIDFromModule

2020-03-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk abandoned this revision.
kwk added a comment.

I didn't intend to create a new revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75753



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75754: Fix typo

2020-03-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk abandoned this revision.
kwk added a comment.

I didn't intend to create a new revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75754



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-09 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 249047.
kwk marked 3 inline comments as done.
kwk added a comment.

Changes suggested by elfutils maintainers:

- Silently ignore error when no DEBUGINFOD_URLS was given as an environment 
variable (ENOSYS).
- Silently ignore error when the build ID could not be found on any server 
(ENOENT).
- End debuginfod client before dealing with return code.

Applied review comments from labath:

- Removed getBuildIDFromModule because we have Module->GetUUID()
- Make findSource return an llvm::Expected instead of an error
- Various formatting issues with clang-format
- use llvm::sys::StrError instead of strerror directly

Other changes:

- Comments on functions in lldb_privat::debuginfod


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp

Index: lldb/source/Host/common/DebugInfoD.cpp
===
--- /dev/null
+++ lldb/source/Host/common/DebugInfoD.cpp
@@ -0,0 +1,96 @@
+//===-- DebugInfoD.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/DebugInfoD.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/Config.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Errno.h"
+
+#if LLDB_ENABLE_DEBUGINFOD
+#include "elfutils/debuginfod.h"
+#endif
+
+namespace lldb_private {
+
+namespace debuginfod {
+
+using namespace lldb;
+using namespace lldb_private;
+
+#if !LLDB_ENABLE_DEBUGINFOD
+bool isAvailable() { return false; }
+
+llvm::Error findSource(UUID buildID, const std::string &path,
+   std::string &cache_path) {
+  llvm_unreachable("debuginfod::findSource is unavailable");
+}
+
+#else // LLDB_ENABLE_DEBUGINFOD
+
+bool isAvailable() { return true; }
+
+llvm::Expected findSource(UUID buildID, const std::string &path) {
+  if (!buildID.IsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid build ID: %s",
+   buildID.GetAsString("").c_str());
+
+  debuginfod_client *client = debuginfod_begin();
+
+  if (!client)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"failed to create debuginfod connection handle: %s", strerror(errno));
+
+  // debuginfod_set_progressfn(client, [](debuginfod_client *client, long a,
+  // long b) -> int {
+  //   fprintf(stderr, "KWK === a: %ld b : %ld \n", a, b);
+  //   return 0; // continue
+  // });
+
+  char *cache_path = nullptr;
+  int rc = debuginfod_find_source(client, buildID.GetBytes().data(),
+  buildID.GetBytes().size(), path.c_str(),
+  &cache_path);
+
+  debuginfod_end(client);
+
+  std::string result_path;
+  if (cache_path) {
+result_path = std::string(cache_path);
+free(cache_path);
+  }
+
+  if (rc < 0) {
+if (rc == -ENOSYS) // No DEBUGINFO_URLS were specified
+  return result_path;
+else if (rc == -ENOENT) // No such file or directory, aka build-id not
+// available on servers.
+  return result_path;
+else
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "debuginfod_find_source query failed: %s",
+ llvm::sys::StrError(-rc).c_str());
+  }
+
+  if (close(rc) < 0) {
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"failed to close result of call to debuginfo_find_source: %s",
+llvm::sys::StrError(errno).c_str());
+  }
+
+  return result_path;
+}
+
+#endif // LLDB_ENABLE_DEBUGINFOD
+
+} // end of namespace debuginfod
+} // namespace lldb_private
Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -30,6 +30,7 @@
   common/HostThread.cpp
   common/LockFileBase.cpp
   common/LZMA.cpp
+  common/DebugInfoD.cpp
   common/MainLoop.cpp
   common/MonitoringProcessLauncher.cpp
   common/NativeProcessProtocol.cpp
@@ -161,6 +162,9 @@
 if (LLDB_ENABLE_LZMA)
   list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES})
 endif()
+if (LLDB_ENABLE_DEBUGINFOD)
+  list(APPEND EXTRA

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-09 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk marked an inline comment as done.
kwk added a comment.

@labath thank you for your early feedback. It was helpful even though this is 
still a work in progress.




Comment at: lldb/source/Host/common/DebugInfoD.cpp:43-67
+UUID getBuildIDFromModule(const ModuleSP &module) {
+  UUID buildID;
+
+  if (!module)
+return buildID;
+
+  const FileSpec &moduleFileSpec = module->GetFileSpec();

labath wrote:
> How is all this different from `module->GetUUID()` ?
I didn't know about that :) . Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-09 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 249096.
kwk added a comment.

- Fix include ordering based on clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp

Index: lldb/source/Host/common/DebugInfoD.cpp
===
--- /dev/null
+++ lldb/source/Host/common/DebugInfoD.cpp
@@ -0,0 +1,96 @@
+//===-- DebugInfoD.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/DebugInfoD.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/Config.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Errno.h"
+
+#if LLDB_ENABLE_DEBUGINFOD
+#include "elfutils/debuginfod.h"
+#endif
+
+namespace lldb_private {
+
+namespace debuginfod {
+
+using namespace lldb;
+using namespace lldb_private;
+
+#if !LLDB_ENABLE_DEBUGINFOD
+bool isAvailable() { return false; }
+
+llvm::Error findSource(UUID buildID, const std::string &path,
+   std::string &cache_path) {
+  llvm_unreachable("debuginfod::findSource is unavailable");
+}
+
+#else // LLDB_ENABLE_DEBUGINFOD
+
+bool isAvailable() { return true; }
+
+llvm::Expected findSource(UUID buildID, const std::string &path) {
+  if (!buildID.IsValid())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid build ID: %s",
+   buildID.GetAsString("").c_str());
+
+  debuginfod_client *client = debuginfod_begin();
+
+  if (!client)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"failed to create debuginfod connection handle: %s", strerror(errno));
+
+  // debuginfod_set_progressfn(client, [](debuginfod_client *client, long a,
+  // long b) -> int {
+  //   fprintf(stderr, "KWK === a: %ld b : %ld \n", a, b);
+  //   return 0; // continue
+  // });
+
+  char *cache_path = nullptr;
+  int rc = debuginfod_find_source(client, buildID.GetBytes().data(),
+  buildID.GetBytes().size(), path.c_str(),
+  &cache_path);
+
+  debuginfod_end(client);
+
+  std::string result_path;
+  if (cache_path) {
+result_path = std::string(cache_path);
+free(cache_path);
+  }
+
+  if (rc < 0) {
+if (rc == -ENOSYS) // No DEBUGINFO_URLS were specified
+  return result_path;
+else if (rc == -ENOENT) // No such file or directory, aka build-id not
+// available on servers.
+  return result_path;
+else
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "debuginfod_find_source query failed: %s",
+ llvm::sys::StrError(-rc).c_str());
+  }
+
+  if (close(rc) < 0) {
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"failed to close result of call to debuginfo_find_source: %s",
+llvm::sys::StrError(errno).c_str());
+  }
+
+  return result_path;
+}
+
+#endif // LLDB_ENABLE_DEBUGINFOD
+
+} // end of namespace debuginfod
+} // namespace lldb_private
Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -30,6 +30,7 @@
   common/HostThread.cpp
   common/LockFileBase.cpp
   common/LZMA.cpp
+  common/DebugInfoD.cpp
   common/MainLoop.cpp
   common/MonitoringProcessLauncher.cpp
   common/NativeProcessProtocol.cpp
@@ -161,6 +162,9 @@
 if (LLDB_ENABLE_LZMA)
   list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES})
 endif()
+if (LLDB_ENABLE_DEBUGINFOD)
+  list(APPEND EXTRA_LIBS ${Debuginfod_LIBRARIES})
+endif()
 if (WIN32)
   list(APPEND LLDB_SYSTEM_LIBS psapi)
 endif ()
Index: lldb/source/Core/SourceManager.cpp
===
--- lldb/source/Core/SourceManager.cpp
+++ lldb/source/Core/SourceManager.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Core/Highlighter.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
+#include "lldb/Host/DebugInfoD.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/Function.h"
@@ -402,7 +403,9 @@
 if (target) {
   m_source_map_m

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-18 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 251086.
kwk added a comment.
Herald added a reviewer: jdoerfert.

- Added debuginfod2.py
- after running: autopep8 --in-place --aggressive --aggressive debuginfod2.py
- exponential backoff implemented
- Added http.py with doctests
- autopep8 --in-place  --aggressive http.py
- change import
- Removed simulated startup time
- fixup
- Changed wording
- Using os.path.abspath on directory before using it
- Fixups
- Fixups
- Fixups
- hide port and hostname from ServeDirectoryWithHTTP
- lit test working for debuginfod and source list


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/httpserver.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,121 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//--
+// Test Purpose:
+// =
+// Test that we can display the source of functions using debuginfod when the
+// original source file is no longer present.
+// 
+// The debuginfod client requires a buildid in the binary, so we compile one in.
+// We can create the directory structure on disc that the client expects on a
+// webserver that serves source files. Then we fire up a python based http
+// server in the root of that mock directory, set the DEBUGINFOD_URLS
+// environment variable and let LLDB do the rest. 
+//
+// Go here to find more about debuginfod:
+// https://sourceware.org/elfutils/Debuginfod.html
+//--
+
+// We copy this file because we want to compile and later move it away
+// ===
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+// We cd into the directory before compiling to get DW_AT_comp_dir pickup
+// %t.buildroot as well so it will be replaced by /my/new/path.
+// ===
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   test.cpp
+
+// We move the original source file to a directory that looks like a debuginfod
+// URL part.
+// 
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mvtest.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+// Adjust where debuginfod stores cache files:
+// ===
+// RUN: rm -rfv %t.debuginfod_cache_path
+// RUN: mkdir -pv %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+// Start HTTP file server on port picked by OS and wait until it is ready
+// The server will be closed on exit of the test.
+// ==
+// RUN: rm -fv "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'echo "SERVER LOG:"; cat %t.server.log; kill $PID;' EXIT INT
+

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-18 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath I've updated my patch and would love to hear your opinion on it. So far 
I've only written the python `ServeDirectoryWithHTTP()` function with proper 
doctest and documentation but since you mentioned the `0` port thingy I've 
tried that on the command line when using `python -m http.server 0` and it 
works smoothly. That's why I've included the `llvm-lit` test I was working on. 
Maybe `lldb/test/Shell/SymbolFile/DWARF/source-list.cpp` is the wrong file for 
this, but we can move it around if you like it so far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-19 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk planned changes to this revision.
kwk added a comment.

In D75750#1929967 , @jankratochvil 
wrote:

> On Fedora 31 x86_64 with LLDB using python3 I got:
>
>   llvm-lit: .../llvm-monorepo2/llvm/utils/lit/lit/TestingConfig.py:102: 
> fatal: unable to parse config file 
> '.../llvm-monorepo2-clangassert/tools/lldb/test/Shell/lit.site.cfg.py', 
> traceback: Traceback (most recent call last):
> File ".../llvm-monorepo2/llvm/utils/lit/lit/TestingConfig.py", line 89, 
> in load_from_path 
>   exec(compile(data, path, 'exec'), cfg_globals, None)
> File 
> ".../llvm-monorepo2-clangassert/tools/lldb/test/Shell/lit.site.cfg.py", line 
> 20, in 
>   config.lldb_enable_debuginfod = TRUE
>   NameError: name 'TRUE' is not defined
>   make[3]: *** [tools/lldb/test/CMakeFiles/check-lldb-lit.dir/build.make:58: 
> tools/lldb/test/CMakeFiles/check-lldb-lit] Error 2
>


Right, I manually fixed it locally and have forgotton to fix it. Thank you 
@jankratochvil for bringing it up.

> It helped to change:
> 
>   -  set(Debuginfod_FOUND TRUE)
>   +  set(Debuginfod_FOUND 1)

I'm sure this helps but we have a better way by using 
`llvm_canonicalize_cmake_booleans` in CMake. I did use this before for 
minidebuginfo and LZMA integration but the place in which I've put it was moved 
around which is why I needed some time. Expect a fix soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-19 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 251297.
kwk added a comment.

- Fix NameError: name 'TRUE' is not defined


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/httpserver.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,121 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//--
+// Test Purpose:
+// =
+// Test that we can display the source of functions using debuginfod when the
+// original source file is no longer present.
+// 
+// The debuginfod client requires a buildid in the binary, so we compile one in.
+// We can create the directory structure on disc that the client expects on a
+// webserver that serves source files. Then we fire up a python based http
+// server in the root of that mock directory, set the DEBUGINFOD_URLS
+// environment variable and let LLDB do the rest. 
+//
+// Go here to find more about debuginfod:
+// https://sourceware.org/elfutils/Debuginfod.html
+//--
+
+// We copy this file because we want to compile and later move it away
+// ===
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+// We cd into the directory before compiling to get DW_AT_comp_dir pickup
+// %t.buildroot as well so it will be replaced by /my/new/path.
+// ===
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   test.cpp
+
+// We move the original source file to a directory that looks like a debuginfod
+// URL part.
+// 
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mvtest.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+// Adjust where debuginfod stores cache files:
+// ===
+// RUN: rm -rfv %t.debuginfod_cache_path
+// RUN: mkdir -pv %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+// Start HTTP file server on port picked by OS and wait until it is ready
+// The server will be closed on exit of the test.
+// ==
+// RUN: rm -fv "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'echo "SERVER LOG:"; cat %t.server.log; kill $PID;' EXIT INT
+
+// Extract HTTP address from the first line of the server log
+// (e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+// ==
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(hea

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-19 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath I've improved my test file for readability.




Comment at: lldb/include/lldb/Host/DebugInfoD.h:26
+
+llvm::Error findSource(UUID buildID, const std::string &path,
+   std::string &result_path);

labath wrote:
> Expected ?
Removed.



Comment at: lldb/include/lldb/Host/DebugInfoD.h:16-18
+namespace llvm {
+class Error;
+} // End of namespace llvm

labath wrote:
> I guess this is not needed now.
Right.



Comment at: lldb/packages/Python/lldbsuite/test/httpserver.py:75
+# Block only for 0.5 seconds max
+httpd.timeout = 0.5
+# Allow for reusing the address

labath wrote:
> What exactly is this timeout for? It seems rather small...
uff, I guess I had an idea when I wrote it but its lost now.  



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:4
 
-The concrete subclass can override lldbtest.TesBase in order to inherit the
+The concrete subclass can override lldbtest.TestBase in order to inherit the
 common behavior for unitest.TestCase.setUp/tearDown implemented in this file.

labath wrote:
> just commit this separately.  no review needed.
Done in 44361782e2c252c8886cd77f6b7d4ebe64fb6e8d.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-19 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 251376.
kwk marked 6 inline comments as done.
kwk added a comment.

- Removed not needed forward decl
- Format comments for better readability in my test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/httpserver.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,128 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+
+//We cd into the directory before compiling to get DW_AT_comp_dir pickup
+//%t.buildroot as well so it will be replaced by /my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mvtest.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rfv %t.debuginfod_cache_path
+// RUN: mkdir -pv %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -fv "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'echo "SERVER LOG:"; cat %t.server.log; kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+"; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL pointing in wrong place --
+
+
+// RUN: DEBUGINFOD_URLS="http://exampl

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-19 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 251383.
kwk added a comment.

- Validate that the server received the request from debuginfod client


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/httpserver.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,134 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+
+//We cd into the directory before compiling to get DW_AT_comp_dir pickup
+//%t.buildroot as well so it will be replaced by /my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mvtest.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rfv %t.debuginfod_cache_path
+// RUN: mkdir -pv %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -fv "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+"; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL pointing in wrong place --
+
+
+// RUN: DEBUGINFOD_URLS="http://example.com/debuginfod"; \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 252026.
kwk added a comment.

- check for valid UUID
- less verbose mkdir and rm output
- More explicit test and documentation
- fixup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/packages/Python/lldbsuite/test/httpserver.py
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,135 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -f "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+"; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL pointing in wrong place -

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath @fche2 @jankratochvil I've implemented the logic to ignore invalid 
UUIDs and the ones that are too short. Can you have another look please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 252054.
kwk marked 2 inline comments as done.
kwk added a comment.

- Remove commented out code
- Remove lldb/packages/Python/lldbsuite/test/httpserver.py in favor of lit test
- Removed commented out left-over code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,135 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -f "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+"; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL point

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-23 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 252059.
kwk added a comment.

- Adjust buildID verification


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,135 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -f "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+"; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL pointing in wrong place --
+
+
+// RUN: DEBUGINFOD_URLS="http://example.com/debuginfod"; \
+// RUN: %lldb -f %t -o 'source list -n main'

[Lldb-commits] [PATCH] D75750: WIP: [lldb] integrate debuginfod

2020-03-24 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 252353.
kwk added a comment.

- Add documentation for workaround on rejecting special build UUIDs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,135 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -f "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+"; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL pointing in wrong place --
+
+
+// RUN: DEBUGINFOD_URLS="http://example.com/debuginfod"; \
+// RUN

[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-03-24 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk marked 10 inline comments as done.
kwk added a comment.

@labath @jankratochvil @fche2 I've addressed all your comments and hope the 
patch is good to go now.




Comment at: lldb/source/Host/common/DebugInfoD.cpp:43
+  buildID.GetBytes().size() ==
+  sizeof(llvm::support::ulittle32_t)) // .gnu_debuglink crc32
+return llvm::createStringError(llvm::inconvertibleErrorCode(),

labath wrote:
> jankratochvil wrote:
> > If it is done this way (and not in `libdebuginfod.so`) I think there should 
> > be `<=8` because LLDB contains:
> > ```
> > if (gnu_debuglink_crc) {
> >   // Use 4 bytes of crc from the .gnu_debuglink section.
> >   u32le data(gnu_debuglink_crc);
> >   uuid = UUID::fromData(&data, sizeof(data));
> > } else if (core_notes_crc) {
> >   // Use 8 bytes - first 4 bytes for *magic* prefix, mainly to 
> > make
> >   // it look different form .gnu_debuglink crc followed by 4 
> > bytes
> >   // of note segments crc.
> >   u32le data[] = {u32le(g_core_uuid_magic), 
> > u32le(core_notes_crc)};
> >   uuid = UUID::fromData(data, sizeof(data));
> > }
> > ```
> > 
> 4 would have probably been fine too, as I don't think a core file "uuid" can 
> make its way into here. In either case, we should document what is this 
> working around, as 4 or 8 byte uuids are technically valid.
@labath. I've added a documentation for the workaround.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-03-25 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@jankratochvil thanks for this thorough review. I have to think about one 
comment more precisely but the rest was fixed.




Comment at: lldb/source/Host/common/DebugInfoD.cpp:50
+   "invalid build ID: %s",
+   buildID.GetAsString("").c_str());
+

jankratochvil wrote:
> It should not be an error:
> ```
> echo 'int main(void) { return 0; }' >/tmp/main2.c;gcc -o /tmp/main2 
> /tmp/main2.c -Wall -g -Wl,--build-id=none;rm 
> /tmp/main2.c;DEBUGINFOD_URLS=http://localhost:8002/ ./bin/lldb /tmp/main2 -o 
> 'l main' -o q
> (lldb) target create "/tmp/main2"
> Current executable set to '/tmp/main2' (x86_64).
> (lldb) l main
> warning: (x86_64) /tmp/main2 An error occurred while finding the source file 
> /tmp/main2.c using debuginfod for build ID A9C3D738: invalid build ID: 
> A9C3D738
> File: /tmp/main2.c
> (lldb) q
> ```
> 
Okay, I'll have it return just an empty string. And adjust the comment on the 
empty string in findSource documentation. I fully understand that an error is 
undesirable in your test case. My question is if the caller should sanitize 
it's parameters passed to `findSource` of if the latter should silently ignore 
those wrong UUIDs. For now I silently ignore them and treat a wrong build ID 
like a not found (e.g. empty string is returned).



Comment at: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp:103
+// TEST-3: File: /my/new/path/test.cpp
+// TEST-3: 123
+// TEST-3-NEXT:{{[0-9]+}}   // Some context lines before

jankratochvil wrote:
> `s/123/{{[0-9]+}}/?`
Both are fine, but I'll go with your's if that helps. If you can tell me how to 
get a lit `CHECK` statement that checks for incremental numbers, that'll be 
awesome ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-03-25 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 252510.
kwk marked 10 inline comments as done.
kwk added a comment.

- Add newline to end of FindDebuginfod.cmake
- Describe empty string returned from debuginfod::findSource()
- Don't treat build IDs of len <= 8 as an error but simply as not found
- move inexpensive debuginfod::isAvailable() check to beginning of if-stmt
- Simplify line number check in test file to avoid adjusting the line number 
every time the test changes
- Add newline to source-list.cpp test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,135 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. Then we fire up a python based http
+//  server in the root of that mock directory, set the DEBUGINFOD_URLS
+//  environment variable and let LLDB do the rest. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//Start HTTP file server on port picked by OS and wait until it is ready
+//The server will be closed on exit of the test.
+
+// RUN: rm -f "%t.server.log"
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind "localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+
+
+//Extract HTTP address from the first line of the server log
+//(e.g. "Serving HTTP on 127.0.0.1 port 40587 (http://127.0.0.1:40587/) ..")
+
+// RUN: echo -n "Waiting for server to be ready"
+// RUN: SERVER_ADDRESS=""
+// RUN: while [ -z "$SERVER_ADDRESS" ]; do \
+// RUN: echo -n "."; \
+// RUN: sleep 0.01; \
+// RUN: SERVER_ADDRESS=$(head -n1 %t.server.log | grep "http://.\+/\+"; -o); \
+// RUN: done
+// RUN: echo "DONE"
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEB

[Lldb-commits] [PATCH] D76736: [LLDB] Fix parsing of IPv6 host:port inside brackets

2020-03-25 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

LGTM but I haven't tested it.


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

https://reviews.llvm.org/D76736



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74187: [lldb] Add method Language::IsMangledName

2020-03-25 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk requested changes to this revision.
kwk added a comment.
This revision now requires changes to proceed.

I agree with @friss that there is a change in behavior. I'm not sure it is 
fixable with what I wrote but I think so.




Comment at: lldb/include/lldb/Target/Language.h:191
 
+  virtual bool IsMangledName(llvm::StringRef name) const = 0;
+

In `Mangled::GuessLanguage()` you call this function with `if 
(lang->IsMangledName(mangled.GetCString()))`. `mangled` in that case is a 
`ConstString`. I wonder why you don't pass that to `IsMangledName`? Is a 
`StringRef` faster? I'm asking because I see  `GetMethodNameVariants` below and 
that also must be called with a `ConstString`.



Comment at: lldb/source/Core/Mangled.cpp:416
-  return lldb::eLanguageTypeC_plus_plus;
-else if (ObjCLanguage::IsPossibleObjCMethodName(mangled_name))
-  return lldb::eLanguageTypeObjC;

In the `ObjCLanguage`'s implementation of `IsMangledName()` I hope to see  a 
call to `sPossibleObjCMethodName`. I think that is what @friss is aiming for 
with D74187#1865342. 



Comment at: lldb/source/Plugins/Language/ObjC/ObjCLanguage.h:97
+  bool IsMangledName(llvm::StringRef name) const override {
+return false;
+  }

Essentially, just `return ObjCLanguage::IsPossibleObjCMethodName(name)`, no? It 
is defined only a few lines further down below.


@friss is that what you mean in order to restore the original behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74187



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-03-26 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk marked 3 inline comments as done.
kwk added a comment.

@labath I made a signficant simplification of starting and killing the server. 
I hope you like that better.




Comment at: lldb/source/Core/SourceManager.cpp:408
+  if ((!file_spec.GetDirectory() && file_spec.GetFilename()) ||
+  !FileSystem::Instance().Exists(m_file_spec)) {
 // If this is just a file name, lets see if we can find it in the

labath wrote:
> jankratochvil wrote:
> > I do not like this extra line as it changes behavior of LLDB unrelated to 
> > `debuginfod`. IIUC if the source file with fully specified 
> > directory+filename in DWARF does not exist but the same filename exists in 
> > a different directory of the sourcetree LLDB will now quietly use the 
> > different file. That's a bug.
> > I think it is there as you needed to initialize `sc.module_sp`.
> Yes, that does not sound right. It may be good to break this function into 
> smaller pieces so you can invoke the thing you need when you need it.
My intention wasn't to leave this as is to be honest. I had comments in here 
that I removed upon request but they existed to remind myself that I haven't 
double checked the logic well enough. I just wanted access to the symbol 
context further down below and thought, that I can take it from up here.



Comment at: lldb/source/Host/common/DebugInfoD.cpp:50
+   "invalid build ID: %s",
+   buildID.GetAsString("").c_str());
+

labath wrote:
> kwk wrote:
> > jankratochvil wrote:
> > > It should not be an error:
> > > ```
> > > echo 'int main(void) { return 0; }' >/tmp/main2.c;gcc -o /tmp/main2 
> > > /tmp/main2.c -Wall -g -Wl,--build-id=none;rm 
> > > /tmp/main2.c;DEBUGINFOD_URLS=http://localhost:8002/ ./bin/lldb /tmp/main2 
> > > -o 'l main' -o q
> > > (lldb) target create "/tmp/main2"
> > > Current executable set to '/tmp/main2' (x86_64).
> > > (lldb) l main
> > > warning: (x86_64) /tmp/main2 An error occurred while finding the source 
> > > file /tmp/main2.c using debuginfod for build ID A9C3D738: invalid build 
> > > ID: A9C3D738
> > > File: /tmp/main2.c
> > > (lldb) q
> > > ```
> > > 
> > Okay, I'll have it return just an empty string. And adjust the comment on 
> > the empty string in findSource documentation. I fully understand that an 
> > error is undesirable in your test case. My question is if the caller should 
> > sanitize it's parameters passed to `findSource` of if the latter should 
> > silently ignore those wrong UUIDs. For now I silently ignore them and treat 
> > a wrong build ID like a not found (e.g. empty string is returned).
> It would be nice to make a test case out of that.
I agree, a test would be nice but not at this stage, where the whole patch 
seems to be at danger.



Comment at: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp:57
+// RUN: timeout 5 python3 -u -m http.server 0 --directory %t.mock --bind 
"localhost" &> %t.server.log & export PID=$!
+// RUN: trap 'kill $PID;' EXIT INT
+

@labath My bad. I interpreted `timeout 5` wrongly. It will kill the python 
server after `5 seconds` no matter what. If we increase this time to `timeout 
5m` it will kill the server after 5 minutes and we don't need the bash trap. 
Does that sound better? At least the only ugly part would be done this way.  
The whole section would look like this:

```lang=yaml
// RUN: rm -f "%t.server.log"
// RUN: timeout 5m python3 -u -m http.server 0 --directory %t.mock --bind 
"localhost" &> %t.server.log &
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76697: [lldb] Replace debug-only assert in AppleObjCTypeEncodingParser::BuildObjCObjectPointerType with lldbassert

2020-03-26 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

Let's summarize this.

1. In the old and the new version, the program is aborted with an `assert()` if 
the configuration is `LLDB_CONFIGURATION_DEBUG`.
2. In the old version, nothing happens, when the configuration is non-Debug.
3. In the new version, the assert in non-Debug configurations will be turned 
into a warning and *print a warning and encourage the user to file a bug 
report* (@JDevlieghere that is the noise you're referring to, right?)


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

https://reviews.llvm.org/D76697



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-03-30 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 253531.
kwk added a comment.

- Use file:// and require debuginfod 0.179
- simplify FindDebuginfod.cmake


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750

Files:
  lldb/cmake/modules/FindDebuginfod.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/DebugInfoD.h
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/DebugInfoD.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
+config.lldb_enable_debuginfod = @LLDB_ENABLE_DEBUGINFOD@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -117,6 +117,9 @@
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
+if config.lldb_enable_debuginfod:
+config.available_features.add('debuginfod')
+
 if find_executable('xz') != None:
 config.available_features.add('xz')
 
Index: lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/source-list.cpp
@@ -0,0 +1,114 @@
+// clang-format off
+// REQUIRES: debuginfod
+// UNSUPPORTED: darwin, windows
+
+//  Test that we can display the source of functions using debuginfod when the
+//  original source file is no longer present.
+//  
+//  The debuginfod client requires a buildid in the binary, so we compile one in.
+//  We can create the directory structure on disc that the client expects on a
+//  webserver that serves source files. We then set DEBUGINFOD_URLS to the mock
+//  directory using file://. This avoids the need for a
+//  debuginfod server to be run. 
+//  
+//  Go here to find more about debuginfod:
+//  https://sourceware.org/elfutils/Debuginfod.html
+
+
+//We copy this file because we want to compile and later move it away
+
+// RUN: mkdir -p %t.buildroot
+// RUN: cp %s %t.buildroot/test.cpp
+
+//We use the prefix map in order to overwrite all DW_AT_decl_file paths
+//in the DWARF. We cd into the directory before compiling to get
+//DW_AT_comp_dir pickup %t.buildroot as well so it will be replaced by
+///my/new/path.
+
+// RUN: cd %t.buildroot
+// RUN: %clang_host \
+// RUN:   -g \
+// RUN:   -Wl,--build-id="0xaabbccdd" \
+// RUN:   -fdebug-prefix-map=%t.buildroot=/my/new/path \
+// RUN:   -o %t \
+// RUN:   %t.buildroot/test.cpp
+
+
+//We move the original source file to a directory that looks like a debuginfod
+//URL part.
+
+// RUN: rm -rf %t.mock
+// RUN: mkdir -p   %t.mock/buildid/aabbccdd/source/my/new/path
+// RUN: mv%t.buildroot/test.cpp %t.mock/buildid/aabbccdd/source/my/new/path
+
+
+//Adjust where debuginfod stores cache files:
+
+// RUN: rm -rf %t.debuginfod_cache_path
+// RUN: mkdir -p %t.debuginfod_cache_path
+// RUN: export DEBUGINFOD_CACHE_PATH=%t.debuginfod_cache_path
+
+
+//-- TEST 1 --  No debuginfod awareness 
+
+
+// RUN: DEBUGINFOD_URLS="" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-1
+
+// TEST-1: (lldb) source list -n main
+// TEST-1: File: /my/new/path/test.cpp
+// TEST-1-EMPTY:
+
+
+//-- TEST 2 -- debuginfod URL pointing in wrong place --
+
+
+// RUN: DEBUGINFOD_URLS="http://example.com/debuginfod"; \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-2
+
+// TEST-2: (lldb) source list -n main
+// TEST-2: File: /my/new/path/test.cpp
+// TEST-2-EMPTY:
+
+
+//-- TEST 3 -- debuginfod URL pointing corectly 
+
+
+// RUN: DEBUGINFOD_URLS="file://%t.mock/" \
+// RUN: %lldb -f %t -o 'source list -n main' | FileCheck --dump-input=fail %s --check-prefix=TEST-3
+
+// TEST-3: (lldb) source list -n main
+// TEST-3: File: /my/new/path/test.cpp
+// TEST-3: {{[0-9]+}}
+// TEST-3-NEXT:{{[0-9]+}}   // Some context lines before
+// TEST-3-NEXT:{{[0-9]+}}   // the function.
+// TEST-3-NEXT:{{[0-9]+}}
+// TEST-3-NEXT:{{[0-9]+}}
+// TEST-3-NEXT:{{[0-9]+}}   int main(int argc, char **argv) {
+// TEST-3-NEXT

[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

In D77108#1951879 , @labath wrote:

> In D77108#1951610 , @aprantl wrote:
>
> > This is obviously good! Do you think that a similar error handling bug 
> > might exist in other cases that depend top-of-stack?
>
>
> Most DW_OP cases check their stack, but it's quite possible that others were 
> missed too. It might be a nice cleanup to make a function like 
> (`getMinimalStackSize(op)`) and move this check up in front of the big 
> switch. That could not handle all operators, as for some of them, the value 
> is not statically known, but it would handle the vast majority of them.


@labath I somewhat like that the logic for each `op` is close to the `case` 
statement. Creating the function that you suggested would separate this check 
out somewhere else and you would have to look at two places. At least for code 
review, the current solution is much clearer to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-04-02 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

In D77108#1952039 , @labath wrote:

> In D77108#1951997 , @kwk wrote:
>
> > In D77108#1951879 , @labath wrote:
> >
> > > Most DW_OP cases check their stack, but it's quite possible that others 
> > > were missed too. It might be a nice cleanup to make a function like 
> > > (`getMinimalStackSize(op)`) and move this check up in front of the big 
> > > switch. That could not handle all operators, as for some of them, the 
> > > value is not statically known, but it would handle the vast majority of 
> > > them.
> >
> >
> > @labath I somewhat like that the logic for each `op` is close to the `case` 
> > statement. Creating the function that you suggested would separate this 
> > check out somewhere else and you would have to look at two places. At least 
> > for code review, the current solution is much clearer to me.
>
>
> I don't have a problem with the current patch (modulo the test tweak) -- it 
> fixes a real problem and it follows the style of the surrounding code. 
> However, DWARFExpression::Evaluate is gigantic (2600LOC), and nearly half of 
> that is error handling. Tastes may vary, but I think that's a bigger 
> readability problem than having to look at two places to understand an opcode.


@labath okay, that makes sense. Sorry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77326: 1/2: [nfc] [lldb] Unindent code

2020-04-02 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

Overall looks good to me except for one larger logic change. Maybe a your 
comment can clarify this. The code was in a very bad shape before, given the 
countless amounts of shortcuts you could take.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:2014
 
-if (!method_die_offsets.empty()) {
-  DWARFDebugInfo &debug_info = dwarf->DebugInfo();

I assume this can be removed because you're iterating over `num_matches == 0` 
when it's empty. But I cannot tell about the `DWARFDebugInfo &debug_info = 
dwarf->DebugInfo();` and how costly this call is and if it makes sense to run 
when the offsets are empty.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp:524
   DIEInfoArray die_info_array;
-  if (FindByName(name, die_info_array))
-DWARFMappedHash::ExtractDIEArray(die_info_array, die_offsets);
+  FindByName(name, die_info_array);
+  DWARFMappedHash::ExtractDIEArray(die_info_array, die_offsets);

Why is the `if` no longer needed?



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2061
+if (!die) {
+  m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
+  continue;

Nice shortcut.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2943
+// Make sure the decl contexts match all the way up
+if (dwarf_decl_ctx != type_dwarf_decl_ctx)
+  continue;

This looks like a logic change and I wonder if it should go in a separate 
patch, maybe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77326



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77326: 1/2: [nfc] [lldb] Unindent code

2020-04-03 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk accepted this revision.
kwk added a comment.
This revision is now accepted and ready to land.

No need to split this into multiples revisions. It is just a rewrite of some 
odd nesting.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2943
+// Make sure the decl contexts match all the way up
+if (dwarf_decl_ctx != type_dwarf_decl_ctx)
+  continue;

jankratochvil wrote:
> kwk wrote:
> > This looks like a logic change and I wonder if it should go in a separate 
> > patch, maybe?
> This should be NFC, do I miss something?
> From:
> ```
> if (a == b) {
>   c;
> }
> ```
> The patch changes it to:
> ```
> if (a != b)
>   continue;
> c;
> ```
> 
Ah, now I see that it was previously a block on the right side of the diff :).




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77326



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77336: Findtypes -gmodules fix

2020-04-03 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

Could you explain, why this was done please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77336



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-03 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

These three `SearchFilter` methods all return `true` by their default
implementation:

  virtual bool ModulePasses(const FileSpec &spec);
  virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
  virtual bool AddressPasses(Address &addr);
  virtual bool CompUnitPasses(FileSpec &fileSpec);
  virtual bool CompUnitPasses(CompileUnit &compUnit);

That's why I've documented the default behavior and remove the overrides
in these `SearchFilter`-subclasses which all just repeated the default
implementation: `SearchFilterByModule`, `SearchFilterByModuleList`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77376

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/source/Core/SearchFilter.cpp

Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -412,17 +412,6 @@
   return FileSpec::Match(m_module_spec, spec);
 }
 
-bool SearchFilterByModule::AddressPasses(Address &address) {
-  // FIXME: Not yet implemented
-  return true;
-}
-
-bool SearchFilterByModule::CompUnitPasses(FileSpec &fileSpec) { return true; }
-
-bool SearchFilterByModule::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModule::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
@@ -538,19 +527,6 @@
   return m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX;
 }
 
-bool SearchFilterByModuleList::AddressPasses(Address &address) {
-  // FIXME: Not yet implemented
-  return true;
-}
-
-bool SearchFilterByModuleList::CompUnitPasses(FileSpec &fileSpec) {
-  return true;
-}
-
-bool SearchFilterByModuleList::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModuleList::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
Index: lldb/include/lldb/Core/SearchFilter.h
===
--- lldb/include/lldb/Core/SearchFilter.h
+++ lldb/include/lldb/Core/SearchFilter.h
@@ -98,6 +98,8 @@
   ///The file spec to check against the filter.
   /// \return
   ///\b true if \a spec passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, default implementation always \c true.
   virtual bool ModulePasses(const FileSpec &spec);
 
   /// Call this method with a Module to see if that module passes the filter.
@@ -107,6 +109,8 @@
   ///
   /// \return
   ///\b true if \a module passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, default implementation always \c true.
   virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
 
   /// Call this method with a Address to see if \a address passes the filter.
@@ -116,6 +120,8 @@
   ///
   /// \return
   ///\b true if \a address passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, default implementation always \c true.
   virtual bool AddressPasses(Address &addr);
 
   /// Call this method with a FileSpec to see if \a file spec passes the
@@ -126,6 +132,8 @@
   ///
   /// \return
   ///\b true if \a file spec passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, default implementation always \c true.
   virtual bool CompUnitPasses(FileSpec &fileSpec);
 
   /// Call this method with a CompileUnit to see if \a comp unit passes the
@@ -136,6 +144,8 @@
   ///
   /// \return
   ///\b true if \a Comp Unit passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, default implementation always \c true.
   virtual bool CompUnitPasses(CompileUnit &compUnit);
 
   /// Call this method with a Function to see if \a function passes the
@@ -319,12 +329,6 @@
 
   bool ModulePasses(const FileSpec &spec) override;
 
-  bool AddressPasses(Address &address) override;
-
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
@@ -370,12 +374,6 @@
 
   bool ModulePasses(const FileSpec &spec) override;
 
-  bool AddressPasses(Address &address) override;
-
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77377: [lldb][nfc] early exit/continue

2020-04-03 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This commit just tries to invert some `if`'s logic to
`return`/`continue` early.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77377

Files:
  lldb/source/Breakpoint/BreakpointResolverName.cpp

Index: lldb/source/Breakpoint/BreakpointResolverName.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -332,65 +332,66 @@
 
   // Remove any duplicates between the function list and the symbol list
   SymbolContext sc;
-  if (func_list.GetSize()) {
-for (uint32_t i = 0; i < func_list.GetSize(); i++) {
-  if (func_list.GetContextAtIndex(i, sc)) {
-bool is_reexported = false;
-
-if (sc.block && sc.block->GetInlinedFunctionInfo()) {
-  if (!sc.block->GetStartAddress(break_addr))
-break_addr.Clear();
-} else if (sc.function) {
-  break_addr = sc.function->GetAddressRange().GetBaseAddress();
-  if (m_skip_prologue && break_addr.IsValid()) {
-const uint32_t prologue_byte_size =
-sc.function->GetPrologueByteSize();
-if (prologue_byte_size)
-  break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
-  }
-} else if (sc.symbol) {
-  if (sc.symbol->GetType() == eSymbolTypeReExported) {
-const Symbol *actual_symbol =
-sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
-if (actual_symbol) {
-  is_reexported = true;
-  break_addr = actual_symbol->GetAddress();
-}
-  } else {
-break_addr = sc.symbol->GetAddress();
-  }
-
-  if (m_skip_prologue && break_addr.IsValid()) {
-const uint32_t prologue_byte_size =
-sc.symbol->GetPrologueByteSize();
-if (prologue_byte_size)
-  break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
-else {
-  const Architecture *arch =
-  breakpoint.GetTarget().GetArchitecturePlugin();
-  if (arch)
-arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
-}
-  }
+  if (!func_list.GetSize())
+return Searcher::eCallbackReturnContinue;
+
+  for (uint32_t i = 0; i < func_list.GetSize(); i++) {
+if (!func_list.GetContextAtIndex(i, sc))
+  continue;
+
+bool is_reexported = false;
+
+if (sc.block && sc.block->GetInlinedFunctionInfo()) {
+  if (!sc.block->GetStartAddress(break_addr))
+break_addr.Clear();
+} else if (sc.function) {
+  break_addr = sc.function->GetAddressRange().GetBaseAddress();
+  if (m_skip_prologue && break_addr.IsValid()) {
+const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+if (prologue_byte_size)
+  break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+  }
+} else if (sc.symbol) {
+  if (sc.symbol->GetType() == eSymbolTypeReExported) {
+const Symbol *actual_symbol =
+sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
+if (actual_symbol) {
+  is_reexported = true;
+  break_addr = actual_symbol->GetAddress();
 }
+  } else {
+break_addr = sc.symbol->GetAddress();
+  }
 
-if (break_addr.IsValid()) {
-  if (filter.AddressPasses(break_addr)) {
-bool new_location;
-BreakpointLocationSP bp_loc_sp(
-AddLocation(break_addr, &new_location));
-bp_loc_sp->SetIsReExported(is_reexported);
-if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
-  if (log) {
-StreamString s;
-bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
-LLDB_LOGF(log, "Added location: %s\n", s.GetData());
-  }
-}
-  }
+  if (m_skip_prologue && break_addr.IsValid()) {
+const uint32_t prologue_byte_size = sc.symbol->GetPrologueByteSize();
+if (prologue_byte_size)
+  break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+else {
+  const Architecture *arch =
+  breakpoint.GetTarget().GetArchitecturePlugin();
+  if (arch)
+arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
 }
   }
 }
+
+if (!break_addr.IsValid())
+  continue;
+
+if (!filter.AddressPasses(break_addr))
+  continue;
+
+bool new_location;
+BreakpointLocationSP bp_loc_sp(AddLocation(break_addr, &new_location));
+bp_loc_sp->SetIsReExported(is_reexported);
+if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
+  if (log) {
+StreamString s;
+bp_loc_sp->GetDescription(&s, ll

[Lldb-commits] [PATCH] D77377: [lldb][nfc] early exit/continue

2020-04-03 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG107200ae0a03: [lldb][nfc] early exit/continue (authored by 
kwk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77377

Files:
  lldb/source/Breakpoint/BreakpointResolverName.cpp

Index: lldb/source/Breakpoint/BreakpointResolverName.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -332,65 +332,66 @@
 
   // Remove any duplicates between the function list and the symbol list
   SymbolContext sc;
-  if (func_list.GetSize()) {
-for (uint32_t i = 0; i < func_list.GetSize(); i++) {
-  if (func_list.GetContextAtIndex(i, sc)) {
-bool is_reexported = false;
-
-if (sc.block && sc.block->GetInlinedFunctionInfo()) {
-  if (!sc.block->GetStartAddress(break_addr))
-break_addr.Clear();
-} else if (sc.function) {
-  break_addr = sc.function->GetAddressRange().GetBaseAddress();
-  if (m_skip_prologue && break_addr.IsValid()) {
-const uint32_t prologue_byte_size =
-sc.function->GetPrologueByteSize();
-if (prologue_byte_size)
-  break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
-  }
-} else if (sc.symbol) {
-  if (sc.symbol->GetType() == eSymbolTypeReExported) {
-const Symbol *actual_symbol =
-sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
-if (actual_symbol) {
-  is_reexported = true;
-  break_addr = actual_symbol->GetAddress();
-}
-  } else {
-break_addr = sc.symbol->GetAddress();
-  }
-
-  if (m_skip_prologue && break_addr.IsValid()) {
-const uint32_t prologue_byte_size =
-sc.symbol->GetPrologueByteSize();
-if (prologue_byte_size)
-  break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
-else {
-  const Architecture *arch =
-  breakpoint.GetTarget().GetArchitecturePlugin();
-  if (arch)
-arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
-}
-  }
+  if (!func_list.GetSize())
+return Searcher::eCallbackReturnContinue;
+
+  for (uint32_t i = 0; i < func_list.GetSize(); i++) {
+if (!func_list.GetContextAtIndex(i, sc))
+  continue;
+
+bool is_reexported = false;
+
+if (sc.block && sc.block->GetInlinedFunctionInfo()) {
+  if (!sc.block->GetStartAddress(break_addr))
+break_addr.Clear();
+} else if (sc.function) {
+  break_addr = sc.function->GetAddressRange().GetBaseAddress();
+  if (m_skip_prologue && break_addr.IsValid()) {
+const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+if (prologue_byte_size)
+  break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+  }
+} else if (sc.symbol) {
+  if (sc.symbol->GetType() == eSymbolTypeReExported) {
+const Symbol *actual_symbol =
+sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
+if (actual_symbol) {
+  is_reexported = true;
+  break_addr = actual_symbol->GetAddress();
 }
+  } else {
+break_addr = sc.symbol->GetAddress();
+  }
 
-if (break_addr.IsValid()) {
-  if (filter.AddressPasses(break_addr)) {
-bool new_location;
-BreakpointLocationSP bp_loc_sp(
-AddLocation(break_addr, &new_location));
-bp_loc_sp->SetIsReExported(is_reexported);
-if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
-  if (log) {
-StreamString s;
-bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
-LLDB_LOGF(log, "Added location: %s\n", s.GetData());
-  }
-}
-  }
+  if (m_skip_prologue && break_addr.IsValid()) {
+const uint32_t prologue_byte_size = sc.symbol->GetPrologueByteSize();
+if (prologue_byte_size)
+  break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+else {
+  const Architecture *arch =
+  breakpoint.GetTarget().GetArchitecturePlugin();
+  if (arch)
+arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
 }
   }
 }
+
+if (!break_addr.IsValid())
+  continue;
+
+if (!filter.AddressPasses(break_addr))
+  continue;
+
+bool new_location;
+BreakpointLocationSP bp_loc_sp(AddLocation(break_addr, &new_location));
+bp_loc_sp->SetIsReExported(is_reexported);
+if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
+  if (log) {
+StreamString 

[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 255022.
kwk added a comment.

- fix comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77376

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/source/Core/SearchFilter.cpp

Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -412,17 +412,6 @@
   return FileSpec::Match(m_module_spec, spec);
 }
 
-bool SearchFilterByModule::AddressPasses(Address &address) {
-  // FIXME: Not yet implemented
-  return true;
-}
-
-bool SearchFilterByModule::CompUnitPasses(FileSpec &fileSpec) { return true; }
-
-bool SearchFilterByModule::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModule::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
@@ -538,19 +527,6 @@
   return m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX;
 }
 
-bool SearchFilterByModuleList::AddressPasses(Address &address) {
-  // FIXME: Not yet implemented
-  return true;
-}
-
-bool SearchFilterByModuleList::CompUnitPasses(FileSpec &fileSpec) {
-  return true;
-}
-
-bool SearchFilterByModuleList::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModuleList::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
Index: lldb/include/lldb/Core/SearchFilter.h
===
--- lldb/include/lldb/Core/SearchFilter.h
+++ lldb/include/lldb/Core/SearchFilter.h
@@ -98,6 +98,8 @@
   ///The file spec to check against the filter.
   /// \return
   ///\b true if \a spec passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool ModulePasses(const FileSpec &spec);
 
   /// Call this method with a Module to see if that module passes the filter.
@@ -107,6 +109,8 @@
   ///
   /// \return
   ///\b true if \a module passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
 
   /// Call this method with a Address to see if \a address passes the filter.
@@ -116,6 +120,8 @@
   ///
   /// \return
   ///\b true if \a address passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool AddressPasses(Address &addr);
 
   /// Call this method with a FileSpec to see if \a file spec passes the
@@ -126,6 +132,8 @@
   ///
   /// \return
   ///\b true if \a file spec passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool CompUnitPasses(FileSpec &fileSpec);
 
   /// Call this method with a CompileUnit to see if \a comp unit passes the
@@ -136,6 +144,8 @@
   ///
   /// \return
   ///\b true if \a Comp Unit passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool CompUnitPasses(CompileUnit &compUnit);
 
   /// Call this method with a Function to see if \a function passes the
@@ -319,12 +329,6 @@
 
   bool ModulePasses(const FileSpec &spec) override;
 
-  bool AddressPasses(Address &address) override;
-
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
@@ -370,12 +374,6 @@
 
   bool ModulePasses(const FileSpec &spec) override;
 
-  bool AddressPasses(Address &address) override;
-
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 255024.
kwk marked 3 inline comments as done.
kwk added a comment.

Re-added `AddressPasses` with FIXME comment


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

https://reviews.llvm.org/D77376

Files:
  lldb/source/Core/SearchFilter.cpp


Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -412,6 +412,11 @@
   return FileSpec::Match(m_module_spec, spec);
 }
 
+bool SearchFilterByModule::AddressPasses(Address &address) {
+  // FIXME: Not yet implemented
+  return true;
+}
+
 void SearchFilterByModule::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
@@ -527,6 +532,11 @@
   return m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX;
 }
 
+bool SearchFilterByModuleList::AddressPasses(Address &address) {
+  // FIXME: Not yet implemented
+  return true;
+}
+
 void SearchFilterByModuleList::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;


Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -412,6 +412,11 @@
   return FileSpec::Match(m_module_spec, spec);
 }
 
+bool SearchFilterByModule::AddressPasses(Address &address) {
+  // FIXME: Not yet implemented
+  return true;
+}
+
 void SearchFilterByModule::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
@@ -527,6 +532,11 @@
   return m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX;
 }
 
+bool SearchFilterByModuleList::AddressPasses(Address &address) {
+  // FIXME: Not yet implemented
+  return true;
+}
+
 void SearchFilterByModuleList::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a subscriber: lattner.
kwk added a comment.

Had some problem with my `arc diff` reporting that another git was running 
which it wasn't so I had to update the diff by hand with a bit of trouble.




Comment at: lldb/include/lldb/Core/SearchFilter.h:102
+  ///
+  /// \note if not overriden, default implementation always \c true.
   virtual bool ModulePasses(const FileSpec &spec);

jankratochvil wrote:
> I am not against it but FYI in a paragraph above there is already written: 
> `The default implementation is "Everything Passes."`
> English: IMO missing "returns".
Thank you for the missing "returns". I'd like to keep the comment.



Comment at: lldb/source/Core/SearchFilter.cpp:416
-bool SearchFilterByModule::AddressPasses(Address &address) {
-  // FIXME: Not yet implemented
-  return true;

jankratochvil wrote:
> This comment will get lost. Maybe you could keep this override just due to 
> the FIXME comment. Or keep the FIXME comment some other way there. Or file a 
> Bugzilla tracking Bug instead.
> It is there since: [[ 
> https://github.com/llvm/llvm-project/commit/30fdc8d841c9d24ac5f3d452b6ece84ee0ac991c
>  | Initial checkin of lldb code from internal Apple repo. ]]
I've checked the code myself to find out where it was coming from and found out 
that the FIXME is there for almost 10 years. I wonder if @lattner still 
remembers why it was there or if it can be removed.  By the nature of the other 
default implementations below, I wonder if this was accidentally a left-over or 
should be put into `SearchFilterByModule::CompUnitPasses` as well? 


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

https://reviews.llvm.org/D77376



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 255026.
kwk edited the summary of this revision.

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

https://reviews.llvm.org/D77376

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/source/Core/SearchFilter.cpp

Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -417,12 +417,6 @@
   return true;
 }
 
-bool SearchFilterByModule::CompUnitPasses(FileSpec &fileSpec) { return true; }
-
-bool SearchFilterByModule::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModule::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
@@ -543,14 +537,6 @@
   return true;
 }
 
-bool SearchFilterByModuleList::CompUnitPasses(FileSpec &fileSpec) {
-  return true;
-}
-
-bool SearchFilterByModuleList::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModuleList::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
Index: lldb/include/lldb/Core/SearchFilter.h
===
--- lldb/include/lldb/Core/SearchFilter.h
+++ lldb/include/lldb/Core/SearchFilter.h
@@ -98,6 +98,8 @@
   ///The file spec to check against the filter.
   /// \return
   ///\b true if \a spec passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool ModulePasses(const FileSpec &spec);
 
   /// Call this method with a Module to see if that module passes the filter.
@@ -107,6 +109,8 @@
   ///
   /// \return
   ///\b true if \a module passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
 
   /// Call this method with a Address to see if \a address passes the filter.
@@ -116,6 +120,8 @@
   ///
   /// \return
   ///\b true if \a address passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool AddressPasses(Address &addr);
 
   /// Call this method with a FileSpec to see if \a file spec passes the
@@ -126,6 +132,8 @@
   ///
   /// \return
   ///\b true if \a file spec passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool CompUnitPasses(FileSpec &fileSpec);
 
   /// Call this method with a CompileUnit to see if \a comp unit passes the
@@ -136,6 +144,8 @@
   ///
   /// \return
   ///\b true if \a Comp Unit passes, and \b false otherwise.
+  ///
+  /// \note if not overriden, the default implementation always returns \c true.
   virtual bool CompUnitPasses(CompileUnit &compUnit);
 
   /// Call this method with a Function to see if \a function passes the
@@ -321,10 +331,6 @@
 
   bool AddressPasses(Address &address) override;
 
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
@@ -372,10 +378,6 @@
 
   bool AddressPasses(Address &address) override;
 
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@jankratochvil for now I've re-added the `AddressPasses` functions and the 
`FIXME` comment. Can you approve?


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

https://reviews.llvm.org/D77376



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 255300.
kwk added a comment.

- Simplify comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77376

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/source/Core/SearchFilter.cpp

Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -417,12 +417,6 @@
   return true;
 }
 
-bool SearchFilterByModule::CompUnitPasses(FileSpec &fileSpec) { return true; }
-
-bool SearchFilterByModule::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModule::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
@@ -543,14 +537,6 @@
   return true;
 }
 
-bool SearchFilterByModuleList::CompUnitPasses(FileSpec &fileSpec) {
-  return true;
-}
-
-bool SearchFilterByModuleList::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModuleList::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
Index: lldb/include/lldb/Core/SearchFilter.h
===
--- lldb/include/lldb/Core/SearchFilter.h
+++ lldb/include/lldb/Core/SearchFilter.h
@@ -98,6 +98,8 @@
   ///The file spec to check against the filter.
   /// \return
   ///\b true if \a spec passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool ModulePasses(const FileSpec &spec);
 
   /// Call this method with a Module to see if that module passes the filter.
@@ -107,6 +109,8 @@
   ///
   /// \return
   ///\b true if \a module passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
 
   /// Call this method with a Address to see if \a address passes the filter.
@@ -116,6 +120,8 @@
   ///
   /// \return
   ///\b true if \a address passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool AddressPasses(Address &addr);
 
   /// Call this method with a FileSpec to see if \a file spec passes the
@@ -126,6 +132,8 @@
   ///
   /// \return
   ///\b true if \a file spec passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool CompUnitPasses(FileSpec &fileSpec);
 
   /// Call this method with a CompileUnit to see if \a comp unit passes the
@@ -136,6 +144,8 @@
   ///
   /// \return
   ///\b true if \a Comp Unit passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool CompUnitPasses(CompileUnit &compUnit);
 
   /// Call this method with a Function to see if \a function passes the
@@ -321,10 +331,6 @@
 
   bool AddressPasses(Address &address) override;
 
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
@@ -372,10 +378,6 @@
 
   bool AddressPasses(Address &address) override;
 
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk marked 2 inline comments as done.
kwk added a comment.

@jankratochvil thanks for the tip.
@labath, addressed your comments and will now push it.




Comment at: lldb/include/lldb/Core/SearchFilter.h:102
+  ///
+  /// \note if not overriden, default implementation always \c true.
   virtual bool ModulePasses(const FileSpec &spec);

labath wrote:
> kwk wrote:
> > jankratochvil wrote:
> > > I am not against it but FYI in a paragraph above there is already 
> > > written: `The default implementation is "Everything Passes."`
> > > English: IMO missing "returns".
> > Thank you for the missing "returns". I'd like to keep the comment.
> You can keep _a_ comment if you want, but this comment is even internally 
> redundant. I don't see a need to mention overriding, saying "The default 
> (base?) implementation returns true" should be clear enough.
@labath. That is fine. I've changed the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77376



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77376: [lldb][nfc] remove overriden funcs with default impl

2020-04-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
kwk marked an inline comment as done.
Closed by commit rG9072df8ac143: [lldb][nfc] remove overriden funcs with 
default impl (authored by kwk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77376

Files:
  lldb/include/lldb/Core/SearchFilter.h
  lldb/source/Core/SearchFilter.cpp

Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -417,12 +417,6 @@
   return true;
 }
 
-bool SearchFilterByModule::CompUnitPasses(FileSpec &fileSpec) { return true; }
-
-bool SearchFilterByModule::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModule::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
@@ -543,14 +537,6 @@
   return true;
 }
 
-bool SearchFilterByModuleList::CompUnitPasses(FileSpec &fileSpec) {
-  return true;
-}
-
-bool SearchFilterByModuleList::CompUnitPasses(CompileUnit &compUnit) {
-  return true;
-}
-
 void SearchFilterByModuleList::Search(Searcher &searcher) {
   if (!m_target_sp)
 return;
Index: lldb/include/lldb/Core/SearchFilter.h
===
--- lldb/include/lldb/Core/SearchFilter.h
+++ lldb/include/lldb/Core/SearchFilter.h
@@ -98,6 +98,8 @@
   ///The file spec to check against the filter.
   /// \return
   ///\b true if \a spec passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool ModulePasses(const FileSpec &spec);
 
   /// Call this method with a Module to see if that module passes the filter.
@@ -107,6 +109,8 @@
   ///
   /// \return
   ///\b true if \a module passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
 
   /// Call this method with a Address to see if \a address passes the filter.
@@ -116,6 +120,8 @@
   ///
   /// \return
   ///\b true if \a address passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool AddressPasses(Address &addr);
 
   /// Call this method with a FileSpec to see if \a file spec passes the
@@ -126,6 +132,8 @@
   ///
   /// \return
   ///\b true if \a file spec passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool CompUnitPasses(FileSpec &fileSpec);
 
   /// Call this method with a CompileUnit to see if \a comp unit passes the
@@ -136,6 +144,8 @@
   ///
   /// \return
   ///\b true if \a Comp Unit passes, and \b false otherwise.
+  ///
+  /// \note the default implementation always returns \c true.
   virtual bool CompUnitPasses(CompileUnit &compUnit);
 
   /// Call this method with a Function to see if \a function passes the
@@ -321,10 +331,6 @@
 
   bool AddressPasses(Address &address) override;
 
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
@@ -372,10 +378,6 @@
 
   bool AddressPasses(Address &address) override;
 
-  bool CompUnitPasses(FileSpec &fileSpec) override;
-
-  bool CompUnitPasses(CompileUnit &compUnit) override;
-
   void GetDescription(Stream *s) override;
 
   uint32_t GetFilterRequiredItems() override;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-04-06 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 255339.
kwk added a comment.

- rebased onto master to get rid of NFC change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136

Files:
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
  lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
  lldb/test/Shell/Breakpoint/search-support-files.test

Index: lldb/test/Shell/Breakpoint/search-support-files.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/search-support-files.test
@@ -0,0 +1,51 @@
+# In these tests we will set breakpoints on a function by name. That function
+# is defined in a header file (search-support-files.h) and will therefore be
+# inlined into the file that includes it (search-support-files.cpp).
+#
+# TODO(kwk): Check that we can also do the same with C++ methods in files?
+#(See https://lldb.llvm.org/use/tutorial.html and look for --method.)
+
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: %build %p/Inputs/search-support-files.cpp -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck --color --dump-input=fail %s 
+
+#---
+# Set breakpoint by function name.
+
+breakpoint set -n inlined_42
+# CHECK: (lldb) breakpoint set -n inlined_42
+# CHECK-NEXT: Breakpoint 1: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}}
+
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 2: where = dummy.out`main + 22 at search-support-files.cpp:5:11, address = 0x0{{.*}}
+
+#---
+# Set breakpoint by function name and filename (the one in which the function is
+# inlined, aka the compilation unit).
+
+breakpoint set -n inlined_42 -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n inlined_42 -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 3: no locations (pending).
+
+#---
+# Set breakpoint by function name and source filename (the file in which the
+# function is defined).
+#
+# NOTE: This test is the really interesting one as it shows that we can now
+#   search by source files that are themselves no compulation units.
+
+breakpoint set -n inlined_42 -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n inlined_42 -f search-support-files.h
+# CHECK-NEXT: Breakpoint 4: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}}
+
+#---
+# Set breakpoint by function name and source filename. This time the file
+# doesn't exist to prove that we haven't widen the search space too much. When
+# we search for a function in file that doesn't exist, we should get no results.
+
+breakpoint set -n inlined_42 -f file-not-existing.h
+# CHECK: (lldb) breakpoint set -n inlined_42 -f file-not-existing.h
+# CHECK-NEXT: Breakpoint 5: no locations (pending).
+# CHECK-NEXT: WARNING: Unable to resolve breakpoint to any actual locations.
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files2.h
@@ -0,0 +1 @@
+int return_zero() { return 0; }
\ No newline at end of file
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
@@ -0,0 +1 @@
+int inlined_42() { return 42; }
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
@@ -0,0 +1,7 @@
+#include "search-support-files.h"
+#include "search-support-files2.h"
+
+int main(int argc, char *argv[]) {
+  int a = inlined_42();
+  return return_zero() + a;
+}
Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -715,9 +715,13 @@
   FileSpec cu_spec;
   if (sym_ctx.comp_unit)
 cu_spec = sym_ctx.comp_unit->GetPrimaryFile();
-  if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX)
-return false; // Fails the file check
-  return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); 
+  if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) != UINT32_MAX)
+return true;
+  // ^ If the primary source file associated with the symbol's compile unit is in
+ 

[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-04-07 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 255648.
kwk added a comment.

- Simplified test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136

Files:
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
  lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
  lldb/test/Shell/Breakpoint/search-support-files.test

Index: lldb/test/Shell/Breakpoint/search-support-files.test
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/search-support-files.test
@@ -0,0 +1,46 @@
+# In these tests we will set breakpoints on a function by name. That function
+# is defined in a header file (search-support-files.h) and will therefore be
+# inlined into the file that includes it (search-support-files.cpp).
+#
+# TODO(kwk): Check that we can also do the same with C++ methods in files?
+#(See https://lldb.llvm.org/use/tutorial.html and look for --method.)
+
+# RUN: %build %p/Inputs/search-support-files.cpp -o dummy.out
+# RUN: %lldb -b -s %s dummy.out | FileCheck --color --dump-input=fail %s 
+
+#Set breakpoint by function name.
+
+breakpoint set -n inlined_42
+# CHECK: (lldb) breakpoint set -n inlined_42
+# CHECK-NEXT: Breakpoint 1: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}}
+
+breakpoint set -n main
+# CHECK: (lldb) breakpoint set -n main
+# CHECK-NEXT: Breakpoint 2: where = dummy.out`main + 22 at search-support-files.cpp:4:11, address = 0x0{{.*}}
+
+#   Set breakpoint by function name and filename (the one in which the function
+#   is inlined, aka the compilation unit).
+
+breakpoint set -n inlined_42 -f search-support-files.cpp
+# CHECK: (lldb) breakpoint set -n inlined_42 -f search-support-files.cpp
+# CHECK-NEXT: Breakpoint 3: no locations (pending).
+
+#   Set breakpoint by function name and source filename (the file in which the
+#   function is defined).
+#
+#   NOTE: This test is the really interesting one as it shows that we can
+# search by source files that are themselves no compulation units.
+
+breakpoint set -n inlined_42 -f search-support-files.h
+# CHECK: (lldb) breakpoint set -n inlined_42 -f search-support-files.h
+# CHECK-NEXT: Breakpoint 4: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}}
+
+#   Set breakpoint by function name and source filename. This time the file
+#   doesn't exist to prove that we haven't widen the search space too much. When
+#   we search for a function in a file that doesn't exist, we should get no
+#   results.
+
+breakpoint set -n inlined_42 -f file-not-existing.h
+# CHECK: (lldb) breakpoint set -n inlined_42 -f file-not-existing.h
+# CHECK-NEXT: Breakpoint 5: no locations (pending).
+# CHECK-NEXT: WARNING: Unable to resolve breakpoint to any actual locations.
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.h
@@ -0,0 +1 @@
+int inlined_42() { return 42; }
Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
===
--- /dev/null
+++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp
@@ -0,0 +1,6 @@
+#include "search-support-files.h"
+
+int main(int argc, char *argv[]) {
+  int a = inlined_42();
+  return a;
+}
Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -715,9 +715,13 @@
   FileSpec cu_spec;
   if (sym_ctx.comp_unit)
 cu_spec = sym_ctx.comp_unit->GetPrimaryFile();
-  if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX)
-return false; // Fails the file check
-  return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); 
+  if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) != UINT32_MAX)
+return true;
+  // ^ If the primary source file associated with the symbol's compile unit is in
+  // the list of CU's or support files, that's enough.
+  // TODO(kwk): Is that enough?
+
+  return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp);
 }
 
 bool SearchFilterByModuleListAndCU::CompUnitPasses(FileSpec &fileSpec) {
@@ -811,7 +815,7 @@
 }
 
 uint32_t SearchFilterByModuleListAndCU::GetFilterRequiredItems() {
-  return eSymbolContextModule | eSymbolContextCompUnit;
+  return eSymbolContextModule | eSymbolContextCompUnit | eSymbolContextFunction;
 }
 
 void SearchFilterByModuleListAndCU::Dump(Stream *s) const {}
Index: lldb/source/Breakpoint/BreakpointResolverName.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ lldb/source/Breakpoint/BreakpointResolverNam

[Lldb-commits] [PATCH] D97721: [lldb] Support DWARF-5 DW_FORM_line_strp (used by GCC)

2021-03-02 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@jankratochvil out of curiosity. Can you give a pointer to what the C program 
looks like that produces the object code? I know GCC might change and no longer 
produce this code so it's better to have the obj code instead. But still I'm 
not nearly close to understanding


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97721

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2019-09-30 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk marked 8 inline comments as done.
kwk added a comment.

In D67390#1685484 , @labath wrote:

> This looks fairly ok to me, but it could use a more explicit test of the 
> symbol uniqueing code. Right, now I believe the two tests you added check 
> that the symbols are _not_ uniqued. (They're also a bit hard to follow due to 
> the whole
>
>   objcopy business). Could you create a test with a yaml file which will 
> contain various edge cases relevant to this code. I'm thinking of stuff like 
> "a dynsym and a symtab symbol at the same address, but a different name", "a 
> dynsym and symtab symbols with identical names, but different addresses", 
> etc. Then just run "image dump symtab" on that file to check what we have 
> parsed?


I'll give my best to implement this today.

> I am also surprised that you weren't able to just use a Section* (instead of 
> the name) for the uniqueing. I'd expect that all symbols (even those from the 
> separate object file) should be resolved to the sections in the main object. 
> I see that this isn't the case, but I am surprised that this isn't causing 
> any problems. Anyway, as things seem to be working as they are now, we can 
> leave that for another day.

Okay.

> In D67390#1685313 , @kwk wrote:
> 
>> Before I used the bare symbol name with stripped `@VERSION` suffix. Now I've 
>> changed the implementation of `NamedELFSymbol` to include the `@VERSION` 
>> suffix and the tests pass.
> 
> 
> Interesting. I'm pretty sure that the symbol count is irrelevant for that 
> test (it just wants to know if it is there), so we can change that if needed. 
> However, having the uniqueing include the `@VERSION` sounds right to me, so 
> if that makes the test happy too then, great.

Yes, I hoped so. Thank you. Please await another revision of this patch with 
the tests requested.




Comment at: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp:371-373
+  r.st_name = st_name;
+  return elf::ELFSymbol::operator==(r) &&
+ st_name_string == rhs.st_name_string;

labath wrote:
> kwk wrote:
> > clayborg wrote:
> > > I would almost just manually compare only the things we care about here. 
> > > Again, what about st_shndx when comparing a symbol from the main symbol 
> > > table and one from the .gnu_debugdata symbol table. Are those section 
> > > indexes guaranteed to match? I would think not. 
> > @clayborg I explicitly only compare what we care about and therefore always 
> > set the name index to  be the same.
> I'll echo @clayborg here. This business with copying the ELFSymbol and 
> clearing some fields is confusing. Do you even need the ELFSymbol::operator== 
> for anything? If not I'd just delete that, and have the derived version 
> compare all fields.
> 
> Also, it would be nice if the operator== and hash function definitions were 
> next to each other. Can you just forward declare the std::hash stuff in the 
> header, and have the implementation be next to this?
> I'll echo @clayborg here. This business with copying the ELFSymbol and 
> clearing some fields is confusing.

I've cleared up the documentation now and it is exactly the way I like it. 
Every entity deals with it's own business (respects its own fields when 
comparing). I find it pretty dirty to compare fields from the base struct in a 
derived one. The way I compare fields from the base struct is minimally 
invasive.

> Do you even need the ELFSymbol::operator== for anything?

Yes, when you want to compare ELFSymbols. I know that I don't do that 
explicitly but I the function only deals with fields from the entity itself and 
they don't spill into any derived structure (with the exception of explicitly 
ignoring fields).

> If not I'd just delete that, and have the derived version compare all fields.

No because I call it explcitly from the derived NamedELFSymbol.

> Also, it would be nice if the operator== and hash function definitions were 
> next to each other. Can you just forward declare the std::hash stuff in the 
> header, and have the implementation be next to this?

I've found a compromise that is even more appealing to me. The ELFSymbol and 
NamedELFSymbol structs now have a `hash` function which contains the 
implementation next to the one of `operator==()`. This `hash` is called in the 
specialization which remains in the same location as before; the reason being 
that I didn't find a way do define something in the `std::` namespace when I'm 
in the `elf::` namespace.





Comment at: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h:446
+std::size_t h2 = std::hash()(s.st_name_string.AsCString());
+std::size_t h3 = std::hash()(s.st_section_name_string.AsCString());
+return llvm::hash_combine(h1, h2, h3);

jankratochvil wrote:
> I find better to rather define `std::hash` (or provide 
> `ConstString::Hasher` which I do in my DWZ patchset).
On

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

2019-09-30 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222387.
kwk marked an inline comment as done.
kwk added a comment.

- typo: dynmic -> dynamic
- Applied changes requested in review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/Inputs/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/Inputs/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/load-from-dynsym-alone.test
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.test
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -55,7 +56,7 @@
 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
 /// the ObjectFile protocol.
 class ObjectFileELF : public lldb_private::ObjectFile {
-public:
+public:  
   // Static Functions
   static void Initialize();
 
@@ -184,6 +185,8 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +281,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +290,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolColl &unique_elf_symbols) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -2196,20 +2197,27 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  ConstString(symbol_section_sp->GetName()));
+if (unique_elf_symbols.insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- user_id_t start_id,
- lldb_private::Section *symtab) {
+unsigned
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id,
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols) {
   if (symtab->GetObjectFile() != this) {
 // If the symbol table section is owned by a different object file, have it
 // do the parsing.
 ObjectFileELF *obj_file_elf =
 static_cast(symtab->GetObjectFile());
-return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab);
+return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab,
+  unique_elf_symbols);
   }
 
   // Get section list for this object file.
@@ -2237,7 +2245,7 @@
   size_t num_symbols = symtab_data.GetByteSize() / s

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

2019-09-30 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath I did prepare some YAML file but apparently `yaml2obj` isn't meant to 
deal with this properly. Instead I get an Error like this: `yaml2obj: error: 
repeated symbol name: 'main'`. It looks like symbols from the `Symbols:` part 
of the YAML file are just added by name to a map. Changing `yaml2obj` for this 
seems a bit too heavy right now. If you're okay I'll go with a few more c 
programs if I can pull them off.

Here's the part hat causes the error:

  template  void ELFState::buildSymbolIndexes() {
auto Build = [this](ArrayRef V, NameToIdxMap &Map) {
  for (size_t I = 0, S = V.size(); I < S; ++I) {
const ELFYAML::Symbol &Sym = V[I];
if (!Sym.Name.empty() && !Map.addName(Sym.Name, I + 1))
  reportError("repeated symbol name: '" + Sym.Name + "'");
  }
};
  
Build(Doc.Symbols, SymN2I);
Build(Doc.DynamicSymbols, DynSymN2I);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2019-09-30 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222427.
kwk added a comment.

- Added YAML test to merge symbols


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/Inputs/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/Inputs/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/load-from-dynsym-alone.test
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.test
  lldb/lit/Modules/ELF/merge-symbols.yaml
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -55,7 +56,7 @@
 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
 /// the ObjectFile protocol.
 class ObjectFileELF : public lldb_private::ObjectFile {
-public:
+public:  
   // Static Functions
   static void Initialize();
 
@@ -184,6 +185,8 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +281,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +290,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolColl &unique_elf_symbols) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -2196,20 +2197,27 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  ConstString(symbol_section_sp->GetName()));
+if (unique_elf_symbols.insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- user_id_t start_id,
- lldb_private::Section *symtab) {
+unsigned
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id,
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols) {
   if (symtab->GetObjectFile() != this) {
 // If the symbol table section is owned by a different object file, have it
 // do the parsing.
 ObjectFileELF *obj_file_elf =
 static_cast(symtab->GetObjectFile());
-return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab);
+return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab,
+  unique_elf_symbols);
   }
 
   // Get section list for this object file.
@@ -2237,7 +2245,7 @@
   size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;
 

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

2019-09-30 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222441.
kwk added a comment.

- include test code in .c test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/merge-symbols.yaml
  lldb/lit/Modules/lit.local.cfg
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -55,7 +56,7 @@
 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
 /// the ObjectFile protocol.
 class ObjectFileELF : public lldb_private::ObjectFile {
-public:
+public:  
   // Static Functions
   static void Initialize();
 
@@ -184,6 +185,8 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +281,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +290,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolColl &unique_elf_symbols) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -2196,20 +2197,28 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  symbol_section_sp.get() ? symbol_section_sp->GetName()
+  : ConstString());
+if (unique_elf_symbols.insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- user_id_t start_id,
- lldb_private::Section *symtab) {
+unsigned
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id,
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols) {
   if (symtab->GetObjectFile() != this) {
 // If the symbol table section is owned by a different object file, have it
 // do the parsing.
 ObjectFileELF *obj_file_elf =
 static_cast(symtab->GetObjectFile());
-return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab);
+return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab,
+  unique_elf_symbols);
   }
 
   // Get section list for this object file.
@@ -2237,7 +2246,7 @@
   size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;
 
  

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

2019-09-30 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222479.
kwk added a comment.

- Fix comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/merge-symbols.yaml
  lldb/lit/Modules/lit.local.cfg
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -55,7 +56,7 @@
 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
 /// the ObjectFile protocol.
 class ObjectFileELF : public lldb_private::ObjectFile {
-public:
+public:  
   // Static Functions
   static void Initialize();
 
@@ -184,6 +185,8 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +281,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +290,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolColl &unique_elf_symbols) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -2196,20 +2197,28 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  symbol_section_sp.get() ? symbol_section_sp->GetName()
+  : ConstString());
+if (unique_elf_symbols.insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- user_id_t start_id,
- lldb_private::Section *symtab) {
+unsigned
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id,
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols) {
   if (symtab->GetObjectFile() != this) {
 // If the symbol table section is owned by a different object file, have it
 // do the parsing.
 ObjectFileELF *obj_file_elf =
 static_cast(symtab->GetObjectFile());
-return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab);
+return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab,
+  unique_elf_symbols);
   }
 
   // Get section list for this object file.
@@ -2237,7 +2246,7 @@
   size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;
 
   return ParseSymbo

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

2019-10-01 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222569.
kwk marked 8 inline comments as done.
kwk added a comment.

- Remove verbose output in test
- Fix typo: smymtab -> symtab
- Move compare and hash logic out of base class into derived class as requested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/merge-symbols.yaml
  lldb/lit/Modules/lit.local.cfg
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -55,7 +56,7 @@
 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
 /// the ObjectFile protocol.
 class ObjectFileELF : public lldb_private::ObjectFile {
-public:
+public:  
   // Static Functions
   static void Initialize();
 
@@ -184,6 +185,8 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +281,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +290,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolColl &unique_elf_symbols) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -2196,20 +2197,28 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  symbol_section_sp.get() ? symbol_section_sp->GetName()
+  : ConstString());
+if (unique_elf_symbols.insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- user_id_t start_id,
- lldb_private::Section *symtab) {
+unsigned
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id,
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols) {
   if (symtab->GetObjectFile() != this) {
 // If the symbol table section is owned by a different object file, have it
 // do the parsing.
 ObjectFileELF *obj_file_elf =
 static_cast(symtab->GetObjectFile());
-return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab);
+return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab,
+  unique_elf_symbols);
   }
 
   // G

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

2019-10-01 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk marked an inline comment as done.
kwk added a comment.

@labath can you please check this patch one last time (hopefully)?




Comment at: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp:371-373
+  r.st_name = st_name;
+  return elf::ELFSymbol::operator==(r) &&
+ st_name_string == rhs.st_name_string;

labath wrote:
> kwk wrote:
> > labath wrote:
> > > kwk wrote:
> > > > clayborg wrote:
> > > > > I would almost just manually compare only the things we care about 
> > > > > here. Again, what about st_shndx when comparing a symbol from the 
> > > > > main symbol table and one from the .gnu_debugdata symbol table. Are 
> > > > > those section indexes guaranteed to match? I would think not. 
> > > > @clayborg I explicitly only compare what we care about and therefore 
> > > > always set the name index to  be the same.
> > > I'll echo @clayborg here. This business with copying the ELFSymbol and 
> > > clearing some fields is confusing. Do you even need the 
> > > ELFSymbol::operator== for anything? If not I'd just delete that, and have 
> > > the derived version compare all fields.
> > > 
> > > Also, it would be nice if the operator== and hash function definitions 
> > > were next to each other. Can you just forward declare the std::hash stuff 
> > > in the header, and have the implementation be next to this?
> > > I'll echo @clayborg here. This business with copying the ELFSymbol and 
> > > clearing some fields is confusing.
> > 
> > I've cleared up the documentation now and it is exactly the way I like it. 
> > Every entity deals with it's own business (respects its own fields when 
> > comparing). I find it pretty dirty to compare fields from the base struct 
> > in a derived one. The way I compare fields from the base struct is 
> > minimally invasive.
> > 
> > > Do you even need the ELFSymbol::operator== for anything?
> > 
> > Yes, when you want to compare ELFSymbols. I know that I don't do that 
> > explicitly but I the function only deals with fields from the entity itself 
> > and they don't spill into any derived structure (with the exception of 
> > explicitly ignoring fields).
> > 
> > > If not I'd just delete that, and have the derived version compare all 
> > > fields.
> > 
> > No because I call it explcitly from the derived NamedELFSymbol.
> > 
> > > Also, it would be nice if the operator== and hash function definitions 
> > > were next to each other. Can you just forward declare the std::hash stuff 
> > > in the header, and have the implementation be next to this?
> > 
> > I've found a compromise that is even more appealing to me. The ELFSymbol 
> > and NamedELFSymbol structs now have a `hash` function which contains the 
> > implementation next to the one of `operator==()`. This `hash` is called in 
> > the specialization which remains in the same location as before; the reason 
> > being that I didn't find a way do define something in the `std::` namespace 
> > when I'm in the `elf::` namespace.
> > 
> > 
> > Yes, when you want to compare ELFSymbols. I know that I don't do that 
> > explicitly but I the function only deals with fields from the entity itself 
> > and they don't spill into any derived structure (with the exception of 
> > explicitly ignoring fields).
> Yes, but to me that exception kind of invalidates the whole idea. In order to 
> know which fields you need to ignore, you need the knowledge of what fields 
> are present in the struct (and as the fields are public, that is not a big 
> deal), at which point you can just avoid the whole copying business, and 
> explicitly compare the fields that you care about. Given that this also saves 
> a nontrivial amount of code, I still think it's a better way to go. (Also, 
> defining equality operators on class hierarchies is usually not a good idea 
> even if they "nest" nicely, since they can still produce strange results due 
> to object slicing.)
> 
> > I've found a compromise that is even more appealing to me. The ELFSymbol 
> > and NamedELFSymbol structs now have a hash function which contains the 
> > implementation next to the one of operator==().
> 
> That works for me.
@labath okay, I've remove the logic from `ELFSymbol` and coded everything 
straight away. I guess, that I wanted to be able to extend `ELFSymbol` with n 
number of fields and add them to the `ELFSymbol::operator==()` without touching 
the `NamedELFSymbol::operator==()` as long as the added fields shall not be 
ignored. Makes sense? I guess that you can find arguments for both ways to 
implement it. Anyway, I've coded it the way you want now, I hope.



Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2205
+needle.st_section_name_string = 
ConstString(symbol_section_sp->GetName());
+if (unique_elf_symbols.find(needle) == unique_elf_symbols.end()) {
+  symtab->AddSymbol(dc_symbol);

labath wrote:
> kwk wrote:
> > labath wrote:
> > > jankratochvil wrote:
> > > 

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

2019-10-01 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222576.
kwk added a comment.

- Correct comment of test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/merge-symbols.yaml
  lldb/lit/Modules/lit.local.cfg
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -55,7 +56,7 @@
 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
 /// the ObjectFile protocol.
 class ObjectFileELF : public lldb_private::ObjectFile {
-public:
+public:  
   // Static Functions
   static void Initialize();
 
@@ -184,6 +185,8 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +281,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +290,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolColl &unique_elf_symbols) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -2196,20 +2197,28 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  symbol_section_sp.get() ? symbol_section_sp->GetName()
+  : ConstString());
+if (unique_elf_symbols.insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- user_id_t start_id,
- lldb_private::Section *symtab) {
+unsigned
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id,
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols) {
   if (symtab->GetObjectFile() != this) {
 // If the symbol table section is owned by a different object file, have it
 // do the parsing.
 ObjectFileELF *obj_file_elf =
 static_cast(symtab->GetObjectFile());
-return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab);
+return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab,
+  unique_elf_symbols);
   }
 
   // Get section list for this object file.
@@ -2237,7 +2246,7 @@
   size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;
 
   retur

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

2019-10-01 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222577.
kwk added a comment.

- Fix comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/merge-symbols.yaml
  lldb/lit/Modules/lit.local.cfg
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -55,7 +56,7 @@
 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
 /// the ObjectFile protocol.
 class ObjectFileELF : public lldb_private::ObjectFile {
-public:
+public:  
   // Static Functions
   static void Initialize();
 
@@ -184,6 +185,8 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +281,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +290,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolColl &unique_elf_symbols) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -2196,20 +2197,28 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  symbol_section_sp.get() ? symbol_section_sp->GetName()
+  : ConstString());
+if (unique_elf_symbols.insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- user_id_t start_id,
- lldb_private::Section *symtab) {
+unsigned
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id,
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols) {
   if (symtab->GetObjectFile() != this) {
 // If the symbol table section is owned by a different object file, have it
 // do the parsing.
 ObjectFileELF *obj_file_elf =
 static_cast(symtab->GetObjectFile());
-return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab);
+return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab,
+  unique_elf_symbols);
   }
 
   // Get section list for this object file.
@@ -2237,7 +2246,7 @@
   size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;
 
   return ParseSymbo

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

2019-10-01 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222584.
kwk added a comment.

- Simplify NamedELFSymbol::hash()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/merge-symbols.yaml
  lldb/lit/Modules/lit.local.cfg
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -55,7 +56,7 @@
 /// This class provides a generic ELF (32/64 bit) reader plugin implementing
 /// the ObjectFile protocol.
 class ObjectFileELF : public lldb_private::ObjectFile {
-public:
+public:  
   // Static Functions
   static void Initialize();
 
@@ -184,6 +185,9 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
+  typedef std::shared_ptr UniqueElfSymbolCollSP;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +282,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolCollSP unique_elf_symbols_sp);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +291,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolCollSP unique_elf_symbols_sp);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolCollSP unique_elf_symbols_sp) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -1912,6 +1913,21 @@
   // pointer
   std::unordered_map section_name_to_section;
 
+  // Ensure there are enough buckets in our unique ELF symbols set.
+  if (!unique_elf_symbols_sp) {
+fprintf(stderr, "\n\nCREATING NEW SYMBOL SET(num_symbols: %lu)\n\n",
+num_symbols);
+unique_elf_symbols_sp.reset(new UniqueElfSymbolColl(num_symbols));
+  } else {
+fprintf(stderr,
+"\n\nEXTENDING OLD SYMBOL SET(num_symbols: %lu + %lu = %lu)\n\n",
+unique_elf_symbols_sp->bucket_count(), num_symbols,
+unique_elf_symbols_sp->bucket_count() + num_symbols);
+std::unique_ptr newColl(new UniqueElfSymbolColl(
+unique_elf_symbols_sp->bucket_count() + num_symbols));
+newColl->swap(*unique_elf_symbols_sp);
+  }
+
   unsigned i;
   for (i = 0; i < num_symbols; ++i) {
 if (!symbol.Parse(symtab_data, &offset))
@@ -2196,20 +2212,28 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  symbol_section_sp.get() ? symbol_section_sp->GetName()
+  : ConstString());
+if (unique_elf_symbols_sp->insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- 

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

2019-10-01 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp:383
+  std::hash()(st_name_string.AsCString()),
+  std::hash()(st_section_name_string.AsCString()));
+}

jankratochvil wrote:
> llvm::hash_combine already calls std::hash for each of its parameters.
Good to know. Thank you.



Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2651
 Symtab *ObjectFileELF::GetSymtab() {
+  fprintf(stderr, "GetSymtab()\n");
   ModuleSP module_sp(GetModule());

labath wrote:
> delete
Sorry, I noticed this myself as well. Some of the performance experiment 
spilled over in this patch. 



Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2681
+// A unique set of ELF symbols added to the symtab
+UniqueElfSymbolCollSP unique_elf_symbols_sp;
+

jankratochvil wrote:
> For the planned rework of the unification of symbols it could be put (I 
> think) to `Symtab::InitAddressIndexes` which already sorts the Symtab anyway.
Honestly, for the rework I think about not to use an `std::vector` as you 
proposed but instead create the `std::unordered_set` using a bucket count that 
is equal to the number of symbols in `.symtab` and in `.dynsym`. Then inserts 
to that set will be constant as they are for the vector. But let's see how it 
goes in a followup patch. I have the feeling that if I use the approach you 
suggested, I need to keep a vector *and* a set around. The vector for 
collecting all symbols and the set for doing the unification, no? Anyway, let's 
postpone this. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2019-10-01 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222634.
kwk marked 10 inline comments as done.
kwk added a comment.

- Check that no additional symbols follow after the expected ones
- Use compiler-generated copy-ctor
- Cleanup from experiment
- Simplify NamedELFSymbol::hash()
- Cleanup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/merge-symbols.yaml
  lldb/lit/Modules/lit.local.cfg
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -184,6 +185,8 @@
 
   typedef std::map
   FileAddressToAddressClassMap;
+  
+  typedef std::unordered_set UniqueElfSymbolColl;
 
   /// Version of this reader common to all plugins based on this class.
   static const uint32_t m_plugin_version = 1;
@@ -278,7 +281,8 @@
   /// will parse the symbols only once.  Returns the number of symbols parsed.
   unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
 lldb::user_id_t start_id,
-lldb_private::Section *symtab);
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Helper routine for ParseSymbolTable().
   unsigned ParseSymbols(lldb_private::Symtab *symbol_table,
@@ -286,7 +290,8 @@
 lldb_private::SectionList *section_list,
 const size_t num_symbols,
 const lldb_private::DataExtractor &symtab_data,
-const lldb_private::DataExtractor &strtab_data);
+const lldb_private::DataExtractor &strtab_data,
+UniqueElfSymbolColl &unique_elf_symbols);
 
   /// Scans the relocation entries and adds a set of artificial symbols to the
   /// given symbol table for each PLT slot.  Returns the number of symbols
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1871,7 +1871,8 @@
  SectionList *section_list,
  const size_t num_symbols,
  const DataExtractor &symtab_data,
- const DataExtractor &strtab_data) {
+ const DataExtractor &strtab_data,
+ UniqueElfSymbolColl &unique_elf_symbols) {
   ELFSymbol symbol;
   lldb::offset_t offset = 0;
 
@@ -2196,20 +2197,28 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+NamedELFSymbol needle(symbol, ConstString(symbol_ref),
+  symbol_section_sp.get() ? symbol_section_sp->GetName()
+  : ConstString());
+if (unique_elf_symbols.insert(needle).second) {
+  symtab->AddSymbol(dc_symbol);
+}
   }
   return i;
 }
 
-unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
- user_id_t start_id,
- lldb_private::Section *symtab) {
+unsigned
+ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, user_id_t start_id,
+lldb_private::Section *symtab,
+UniqueElfSymbolColl &unique_elf_symbols) {
   if (symtab->GetObjectFile() != this) {
 // If the symbol table section is owned by a different object file, have it
 // do the parsing.
 ObjectFileELF *obj_file_elf =
 static_cast(symtab->GetObjectFile());
-return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab);
+return obj_file_elf->ParseSymbolTable(symbol_table, start_id, symtab,
+  unique_elf_symbols);
   }
 
   // Get section list for this object file.
@@ -2237,7 +2246,7 @@
   size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;
 
   return ParseSymbols(symbol_table, start_id, section_list, num_symbols,
-  

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

2019-10-02 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk planned changes to this revision.
kwk added a comment.

LLVM reasoning for why to go with `std::vector`: 
http://llvm.org/docs/ProgrammersManual.html#set-like-containers-std-set-smallset-setvector-etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2019-10-02 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk abandoned this revision.
kwk added a comment.

Here's the relevant transcript from #lldb@otfc for why this change is abandoned.

  [10/02/19 15:22:25]  labath: Is it acceptable for you?  "BTW 
given how this unique-ness of symbols turns out to be non-trivial is it really 
needed?  Because for regular .symtab we can ignore .dynsym (as current LLDB 
does) and for .gnu_debugdata->.symtab we can just concatenate it with .dynsym 
and there will be no symbol duplicates anyway."
  [10/02/19 15:22:25]  Otherwise it is either a big code 
complication or a big performance regression and it is not really needed for 
anything.
  [10/02/19 15:27:42]  yeah, i suppose that would work
  [10/02/19 15:28:11]  then you just need to make sure the merging does 
not kick in for non-gnu_debugdata sections
  [10/02/19 15:28:30]  a simple check on the existing of this section 
might suffice
  [10/02/19 15:29:39]  it seems to me that it would be useful to have 
information from both sources available, but it is true that nobody has really 
needed that so far
  [10/02/19 15:36:11]  Thanks.
  [10/02/19 15:36:22]  kkleine: ^^^ Let's call it a win-win. :-)
  [10/02/19 16:14:27]  labath, jankratochvil I wonder if we the 
merging with .gnu_debugdata needs to be as "clever" as it is today and if it is 
enough to just add symbols without checking for uniqueness. That would simplify 
things even more.
  [10/02/19 16:16:32]  I think just add it without checks.
  [10/02/19 16:16:53]  works for me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-02 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk planned changes to this revision.
kwk added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2711-2731
 Section *symtab =
 section_list->FindSectionByType(eSectionTypeELFSymbolTable, 
true).get();
-if (!symtab) {
-  // The symtab section is non-allocable and can be stripped, so if it
-  // doesn't exist then use the dynsym section which should always be
-  // there.
-  symtab =
-  section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
-  .get();
-}
 if (symtab) {
   m_symtab_up.reset(new Symtab(symtab->GetObjectFile()));
   symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, symtab);
 }
 

kwk wrote:
> labath wrote:
> > Let's put this bit into a separate patch. As I said over IRC, I view this 
> > bit as functionally independent of the debugdata stuff (it's definitely 
> > independent in it's current form, as it will kick in for non-debugdata 
> > files too, which I think is fine).
> Done in D67390.
We agreed to not have this other patch. See D67390#1691424.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-02 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 222845.
kwk marked 12 inline comments as done.
kwk added a comment.

- Change logic and comment for when .dynsym is parsed
- Use different pattern for error checking
- use less auto
- Remove required system-linux test feature from LZMA tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/CMakeLists.txt
  lldb/lit/Modules/ELF/Inputs/minidebuginfo-main.c
  lldb/lit/Modules/ELF/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Modules/ELF/minidebuginfo-find-symbols.yaml
  lldb/lit/Modules/ELF/minidebuginfo-no-lzma.yaml
  lldb/lit/Modules/ELF/minidebuginfo-set-and-hit-breakpoint.test
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,70 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = unified_section_list.FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  unified_section_list.ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  unified_section_list.AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(data.GetData(), uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occurred while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompressedData.size()));
+  auto fspec = GetFileSpec().CopyByAppendingPathComponent(
+  llvm::StringRef("gnu_debugdata"));
+ 

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-02 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk requested review of this revision.
kwk added a comment.
This revision is now accepted and ready to land.

Tests did pass so this change is ready for review @labath @jankratochvil .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D61847: [lldb] NFC modernize codebase with modernize-use-nullptr

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@JDevlieghere can you please commit this in my name? I don't have commit access 
yet. I've filed an email an hope to get it soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61847



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D61847: [lldb] modernize codebase with modernize-use-nullptr

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@teemperor I've addressed all of your comments. Can you please have another 
look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61847



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D61847: [lldb] modernize codebase with modernize-use-nullptr

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added inline comments.



Comment at: 
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:76
 static constexpr PropertyDefinition g_properties[] = {
-{"load-kexts", OptionValue::eTypeBoolean, true, true, NULL, {},
+{"load-kexts",
+ OptionValue::eTypeBoolean,

teemperor wrote:
> Can you revert the auto-formatting here?
@teemperor I sure could or if you want I can sourround this section with ` // 
clang-format off` and ` // clang-format on` to prevent it from being ever 
formatted again. 



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:114
 static constexpr PropertyDefinition g_properties[] = {
-{"packet-timeout", OptionValue::eTypeUInt64, true, 5
+{"packet-timeout",
+ OptionValue::eTypeUInt64,

teemperor wrote:
> Can you revert the auto-formatting here (and in the next option definition)?
@teemperor sure but same question: shall I use ` // clang-format off` and ` // 
clang-format on` here for the entire section? 



Comment at: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp:603
 public:
-
   CommandObjectProcessMinidumpDump(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "process plugin dump",

teemperor wrote:
> Could you also revert the unrelated whitespace changes here? Phabricator 
> doesn't really display the whitespace changes well, but this patch 
> effectively reformats this whole INIT_BOOL chain (The reformatting itself is 
> fine, but it should be it's own commit).
@teemperor sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61847



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D61847: [lldb] NFC modernize codebase with modernize-use-nullptr

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@JDevlieghere I have commit access now. I'm currently working on rebasing my 
changes and resolving conflicts in these files where my patch wasn't rebaseable.

  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61847



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 218929.
kwk added a comment.
Herald added subscribers: openmp-commits, libcxx-commits, Sanitizers, 
cfe-commits, seiya, erik.pilkington, asbirlea, ormris, Petar.Avramovic, jsji, 
mstorsjo, jfb, kadircet, arphaman, jkorous, george.burgess.iv, christof, 
jakehehrlich, javed.absar, kbarton, aheejin, sbc100, nhaehnle, jvesely, 
nemanjai, arsenm.
Herald added a reviewer: martong.
Herald added a reviewer: shafik.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jhenderson.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, Sanitizers, libc++, OpenMP.

- Fixup
- Test for minidebuginfo image dump symtab
- Fixed test for corrupted xz blob
- Fix test
- Added test that runs when no LZMA is configured


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  .git-blame-ignore-revs
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdUnit.cpp
  clang-tools-extra/clangd/ClangdUnit.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/Threading.h
  clang-tools-extra/clangd/Trace.cpp
  clang-tools-extra/clangd/Trace.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/BackgroundRebuild.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang-tools-extra/modularize/Modularize.cpp
  clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
  clang-tools-extra/test/clang-tidy/misc-definitions-in-headers.hpp
  clang/docs/ConstantInterpreter.rst
  clang/docs/OpenMPSupport.rst
  clang/docs/index.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Mangle.h
  clang/include/clang/AST/OptionalDiagnostic.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Block.cpp
  clang/lib/AST/Interp/Block.h
  clang/lib/AST/Interp/Boolean.h
  clang/lib/AST/Interp/ByteCodeEmitter.cpp
  clang/lib/AST/Interp/ByteCodeEmitter.h
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeGenError.cpp
  clang/lib/AST/Interp/ByteCodeGenError.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.h
  clang/lib/AST/Interp/CMakeLists.txt
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Context.h
  clang/lib/AST/Interp/Descriptor.cpp
  cla

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 218931.
kwk added a comment.

- Better names for minidebuginfo files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo.keep_symbols
  lldb/lit/Breakpoint/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Breakpoint/minidebuginfo-find-symbols.yaml
  lldb/lit/Breakpoint/minidebuginfo-no-lzma.yaml
  lldb/lit/Breakpoint/minidebuginfo.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompressedD

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 219038.
kwk added a comment.

- Fix spelling error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo.keep_symbols
  lldb/lit/Breakpoint/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Breakpoint/minidebuginfo-find-symbols.yaml
  lldb/lit/Breakpoint/minidebuginfo-no-lzma.yaml
  lldb/lit/Breakpoint/minidebuginfo-set-and-hit-breakpoint.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occurred while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompr

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 218930.
kwk added a comment.
Herald added subscribers: wuzish, rnkovacs.

- Fixup
- Test for minidebuginfo image dump symtab
- Fixed test for corrupted xz blob
- Fix test
- Added test that runs when no LZMA is configured


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo.keep_symbols
  lldb/lit/Breakpoint/minidebuginfo-only-gnu_debugdata.corrupt.yaml
  lldb/lit/Breakpoint/minidebuginfo-only-gnu_debugdata.nolzma.yaml
  lldb/lit/Breakpoint/minidebuginfo-only-gnu_debugdata.yaml
  lldb/lit/Breakpoint/minidebuginfo.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 218932.
kwk added a comment.

- Better names for minidebuginfo files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo.keep_symbols
  lldb/lit/Breakpoint/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Breakpoint/minidebuginfo-find-symbols.yaml
  lldb/lit/Breakpoint/minidebuginfo-no-lzma.yaml
  lldb/lit/Breakpoint/minidebuginfo-set-and-hit-breakpoint.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedDat

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-05 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath ah, I've just seen that you did accept the revision already. Will merge 
it then after running tests once more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-05 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 223381.
kwk marked 10 inline comments as done.
kwk added a comment.

- Fix typo: s/a. /a ./
- Fix comment header
- Remove redundant input buffer check
- Remove another redundant input buffer check
- Change variable initialization to assign
- added comment about minidebuginfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/CMakeLists.txt
  lldb/lit/Modules/ELF/Inputs/minidebuginfo-main.c
  lldb/lit/Modules/ELF/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Modules/ELF/minidebuginfo-find-symbols.yaml
  lldb/lit/Modules/ELF/minidebuginfo-no-lzma.yaml
  lldb/lit/Modules/ELF/minidebuginfo-set-and-hit-breakpoint.test
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,70 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = unified_section_list.FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  unified_section_list.ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  unified_section_list.AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(data.GetData(), uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occurred while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompressedData.size()));
+  auto fspec = GetFileSpec().CopyByAppendingPathComponent(
+  llv

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-05 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath I've addressed all you comments. Thank you for answering 
@jankratochvil's question as well. If this patch is good to go now, please give 
a thumbs up.




Comment at: lldb/source/Host/common/LZMA.cpp:84
+  lzma_ret xzerr = lzma_stream_footer_decode(
+  &opts, InputBuffer.data() + InputBuffer.size() - 
LZMA_STREAM_HEADER_SIZE);
+  if (xzerr != LZMA_OK) {

labath wrote:
> Maybe `InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data()` ?
`take_back`:


> Return a copy of *this with only the last \p N elements.

 I mean `LZMA_STREAM_HEADER_SIZE` is only 12 but do we really need it?




Comment at: lldb/source/Host/common/LZMA.cpp:104-105
+  lzma_index_buffer_decode(&xzindex, &memlimit, nullptr,
+   InputBuffer.data() + InputBuffer.size() -
+   LZMA_STREAM_HEADER_SIZE - 
opts.backward_size,
+   &inpos, InputBuffer.size());

labath wrote:
> same here.
Same answer here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-05 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 223382.
kwk added a comment.

Rebased onto current master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/CMakeLists.txt
  lldb/lit/Modules/ELF/Inputs/minidebuginfo-main.c
  lldb/lit/Modules/ELF/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Modules/ELF/minidebuginfo-find-symbols.yaml
  lldb/lit/Modules/ELF/minidebuginfo-no-lzma.yaml
  lldb/lit/Modules/ELF/minidebuginfo-set-and-hit-breakpoint.test
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,70 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = unified_section_list.FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  unified_section_list.ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  unified_section_list.AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(data.GetData(), uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occurred while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompressedData.size()));
+  auto fspec = GetFileSpec().CopyByAppendingPathComponent(
+  llvm::StringRef("gnu_debugdata"));
+  m_gnu_debug_data_object_file.reset(new ObjectFileELF(
+  GetModule(), gdd_data_buf, 0, &fspec, 0, gdd_data_buf->GetByteSize()));
+
+  // This line is essential; otherwise a breakp

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-05 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

@labath as much as I would love to merge this patch I get errors from these 
tests that I didn't see before. They only appear after rebasing onto master:

  Failing Tests (4):
  lldb-Suite :: commands/process/attach/TestProcessAttach.py
  lldb-Suite :: python_api/hello_world/TestHelloWorld.py
  lldb-Suite :: 
tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
  lldb-Suite :: tools/lldb-vscode/attach/TestVSCode_attach.py

I also get the same errors on current master .(revision 
8815be04ec1f333564591d9593735f22efa9bee5 
) without 
my patch applied. But before I merrge my patch I'd like to see master in a 
better shape, no?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-07 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 223482.
kwk added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/CMakeLists.txt
  lldb/lit/Modules/ELF/Inputs/minidebuginfo-main.c
  lldb/lit/Modules/ELF/minidebuginfo-corrupt-xz.yaml
  lldb/lit/Modules/ELF/minidebuginfo-find-symbols.yaml
  lldb/lit/Modules/ELF/minidebuginfo-no-lzma.yaml
  lldb/lit/Modules/ELF/minidebuginfo-set-and-hit-breakpoint.test
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,70 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = unified_section_list.FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  unified_section_list.ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  unified_section_list.AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(data.GetData(), uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occurred while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompressedData.size()));
+  auto fspec = GetFileSpec().CopyByAppendingPathComponent(
+  llvm::StringRef("gnu_debugdata"));
+  m_gnu_debug_data_object_file.reset(new ObjectFileELF(
+  GetModule(), gdd_data_buf, 0, &fspec, 0, gdd_data_buf->GetByteSize()));
+
+  // This line is essential; otherwise a breakpoint can be set but 

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-10-07 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk closed this revision.
kwk added a comment.

Closed by 2c082b48274fcba62bf9b3acb63075aedcc7a976 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68614: [LLDB] Remove standalone build dep on llvm-strip

2019-10-08 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

I think I'm guilty for adding `llvm-strip` to `LLDB_TEST_DEPS` I wasn't aware 
that it might cause problems.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68614



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68638: [lldb] Avoid resource leak

2019-10-08 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
kwk added a reviewer: jankratochvil.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Before the pointer variable `args_dict` was assigned the result of an
allocation with `new` and then `args_dict` is passed to
`GetValueForKeyAsDictionary` which immediatly and unconditionally
assigns `args_dict` to `nullptr`:

  bool GetValueForKeyAsDictionary(llvm::StringRef key,
  Dictionary *&result) const {
result = nullptr;

This caused a memory leak which was found in my coverity scan instance
under CID 224753: https://scan.coverity.com/projects/kwk-llvm-project.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68638

Files:
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp


Index: lldb/source/Breakpoint/BreakpointResolverScripted.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -92,7 +92,7 @@
   depth = (lldb::SearchDepth) depth_as_int;
   
   StructuredDataImpl *args_data_impl = new StructuredDataImpl();
-  StructuredData::Dictionary *args_dict = new StructuredData::Dictionary();
+  StructuredData::Dictionary *args_dict = nullptr;
   success = options_dict.GetValueForKeyAsDictionary(
 GetKey(OptionNames::ScriptArgs), args_dict);
   if (success) {


Index: lldb/source/Breakpoint/BreakpointResolverScripted.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -92,7 +92,7 @@
   depth = (lldb::SearchDepth) depth_as_int;
   
   StructuredDataImpl *args_data_impl = new StructuredDataImpl();
-  StructuredData::Dictionary *args_dict = new StructuredData::Dictionary();
+  StructuredData::Dictionary *args_dict = nullptr;
   success = options_dict.GetValueForKeyAsDictionary(
 GetKey(OptionNames::ScriptArgs), args_dict);
   if (success) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68647: Simplify LZMA decoding by using ArrayRef::take_back

2019-10-08 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
kwk added a reviewer: labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Follow-up for D66791#inline-616303 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68647

Files:
  lldb/source/Host/common/LZMA.cpp


Index: lldb/source/Host/common/LZMA.cpp
===
--- lldb/source/Host/common/LZMA.cpp
+++ lldb/source/Host/common/LZMA.cpp
@@ -76,7 +76,7 @@
 
   // Decode xz footer.
   lzma_ret xzerr = lzma_stream_footer_decode(
-  &opts, InputBuffer.data() + InputBuffer.size() - 
LZMA_STREAM_HEADER_SIZE);
+  &opts, InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_stream_footer_decode()=%s",
@@ -94,11 +94,11 @@
   lzma_index *xzindex;
   uint64_t memlimit(UINT64_MAX);
   size_t inpos = 0;
-  xzerr =
-  lzma_index_buffer_decode(&xzindex, &memlimit, nullptr,
-   InputBuffer.data() + InputBuffer.size() -
-   LZMA_STREAM_HEADER_SIZE - 
opts.backward_size,
-   &inpos, InputBuffer.size());
+  xzerr = lzma_index_buffer_decode(
+  &xzindex, &memlimit, nullptr,
+  InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE - opts.backward_size)
+  .data(),
+  &inpos, InputBuffer.size());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_index_buffer_decode()=%s",


Index: lldb/source/Host/common/LZMA.cpp
===
--- lldb/source/Host/common/LZMA.cpp
+++ lldb/source/Host/common/LZMA.cpp
@@ -76,7 +76,7 @@
 
   // Decode xz footer.
   lzma_ret xzerr = lzma_stream_footer_decode(
-  &opts, InputBuffer.data() + InputBuffer.size() - LZMA_STREAM_HEADER_SIZE);
+  &opts, InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_stream_footer_decode()=%s",
@@ -94,11 +94,11 @@
   lzma_index *xzindex;
   uint64_t memlimit(UINT64_MAX);
   size_t inpos = 0;
-  xzerr =
-  lzma_index_buffer_decode(&xzindex, &memlimit, nullptr,
-   InputBuffer.data() + InputBuffer.size() -
-   LZMA_STREAM_HEADER_SIZE - opts.backward_size,
-   &inpos, InputBuffer.size());
+  xzerr = lzma_index_buffer_decode(
+  &xzindex, &memlimit, nullptr,
+  InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE - opts.backward_size)
+  .data(),
+  &inpos, InputBuffer.size());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_index_buffer_decode()=%s",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68647: Simplify LZMA decoding by using ArrayRef::take_back

2019-10-08 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 223865.
kwk marked an inline comment as done.
kwk added a comment.

Fixup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68647

Files:
  lldb/source/Host/common/LZMA.cpp


Index: lldb/source/Host/common/LZMA.cpp
===
--- lldb/source/Host/common/LZMA.cpp
+++ lldb/source/Host/common/LZMA.cpp
@@ -76,7 +76,7 @@
 
   // Decode xz footer.
   lzma_ret xzerr = lzma_stream_footer_decode(
-  &opts, InputBuffer.data() + InputBuffer.size() - 
LZMA_STREAM_HEADER_SIZE);
+  &opts, InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_stream_footer_decode()=%s",
@@ -94,11 +94,11 @@
   lzma_index *xzindex;
   uint64_t memlimit(UINT64_MAX);
   size_t inpos = 0;
-  xzerr =
-  lzma_index_buffer_decode(&xzindex, &memlimit, nullptr,
-   InputBuffer.data() + InputBuffer.size() -
-   LZMA_STREAM_HEADER_SIZE - 
opts.backward_size,
-   &inpos, InputBuffer.size());
+  xzerr = lzma_index_buffer_decode(
+  &xzindex, &memlimit, nullptr,
+  InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE + opts.backward_size)
+  .data(),
+  &inpos, InputBuffer.size());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_index_buffer_decode()=%s",


Index: lldb/source/Host/common/LZMA.cpp
===
--- lldb/source/Host/common/LZMA.cpp
+++ lldb/source/Host/common/LZMA.cpp
@@ -76,7 +76,7 @@
 
   // Decode xz footer.
   lzma_ret xzerr = lzma_stream_footer_decode(
-  &opts, InputBuffer.data() + InputBuffer.size() - LZMA_STREAM_HEADER_SIZE);
+  &opts, InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_stream_footer_decode()=%s",
@@ -94,11 +94,11 @@
   lzma_index *xzindex;
   uint64_t memlimit(UINT64_MAX);
   size_t inpos = 0;
-  xzerr =
-  lzma_index_buffer_decode(&xzindex, &memlimit, nullptr,
-   InputBuffer.data() + InputBuffer.size() -
-   LZMA_STREAM_HEADER_SIZE - opts.backward_size,
-   &inpos, InputBuffer.size());
+  xzerr = lzma_index_buffer_decode(
+  &xzindex, &memlimit, nullptr,
+  InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE + opts.backward_size)
+  .data(),
+  &inpos, InputBuffer.size());
   if (xzerr != LZMA_OK) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"lzma_index_buffer_decode()=%s",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68647: Simplify LZMA decoding by using ArrayRef::take_back

2019-10-08 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk marked an inline comment as done.
kwk added inline comments.



Comment at: lldb/source/Host/common/LZMA.cpp:99
+  &xzindex, &memlimit, nullptr,
+  InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE - opts.backward_size)
+  .data(),

labath wrote:
> I think this should be + to preserve semantics, though I am not sure why no 
> tests fail because of that. I guess none of the lzma streams we have have 
> non-zero `backward_size`..
Sorry, tests are still running... and you're right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68647



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   3   >