[Lldb-commits] [PATCH] D70764: build: reduce CMake handling for zlib

2019-11-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Please take a look at D70519  for the issues 
with this approach.

Also, while I do agree with you that we should not auto-select dependencies, I 
think this runs contrary to the llvm philosophy that the default built should 
"just work" (I don't know if that's formalized anywhere, but I know it's 
certainly what (some?) people expect).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70764



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


[Lldb-commits] [PATCH] D70745: [LLDB] [PECOFF] Look for the truncated ".eh_fram" section name

2019-11-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I think you should be able to write a test with a yaml2obj + `lldb-test 
object-file`. That's how the equivalent elf functionality is tested (see 
`test/Shell/ObjectFile/ELF/section-types.yaml`). It won't check that the 
section is actually parsed properly, but I don't think that's needed for the 
kind of fix you're making here.

As for the long if-else cascade, the equivalent elf code was recently 
refactored to use llvm::StringSwitch. Doing the same here would be nice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70745



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


[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

There's still one failing test on Windows after the fix attempt: 
http://45.33.8.238/win/3052/step_6.txt

Please take a look and revert if it's not an easy fix. (And please watch bots 
after committing stuff.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[Lldb-commits] [PATCH] D70764: build: reduce CMake handling for zlib

2019-11-26 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd created this revision.
compnerd added reviewers: beanz, smeenai.
Herald added subscribers: lldb-commits, Sanitizers, hiraditya, mgorny.
Herald added projects: clang, Sanitizers, LLDB, LLVM.

Rather than handling zlib handling manually, use `find_package` from CMake to 
find zlib properly.  Use this to normalize the `LLVM_ENABLE_ZLIB`, `HAVE_ZLIB`, 
`HAVE_ZLIB_H`.  Furthermore, require zlib if `LLVM_ENABLE_ZLIB` is set to 
`YES`, which requires the distributor to explicitly select whether zlib is 
enabled or not.  This simplifies the CMake handling and usage in the rest of 
the tooling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70764

Files:
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/test/lit.common.configured.in
  lld/test/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  llvm/cmake/config-ix.cmake
  llvm/include/llvm/Config/config.h.cmake
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CRC.cpp
  llvm/lib/Support/Compression.cpp
  llvm/test/CMakeLists.txt
  llvm/test/lit.site.cfg.py.in
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 
 void TestZlibCompression(StringRef Input, int Level) {
   SmallString<32> Compressed;
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -33,7 +33,7 @@
 config.host_ldflags = '@HOST_LDFLAGS@'
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.have_libxar = @HAVE_LIBXAR@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.enable_ffi = @LLVM_ENABLE_FFI@
Index: llvm/test/CMakeLists.txt
===
--- llvm/test/CMakeLists.txt
+++ llvm/test/CMakeLists.txt
@@ -1,12 +1,12 @@
 llvm_canonicalize_cmake_booleans(
   BUILD_SHARED_LIBS
   HAVE_LIBXAR
-  HAVE_LIBZ
   HAVE_OCAMLOPT
   HAVE_OCAML_OUNIT
   LLVM_ENABLE_DIA_SDK
   LLVM_ENABLE_FFI
   LLVM_ENABLE_THREADS
+  LLVM_ENABLE_ZLIB
   LLVM_INCLUDE_GO_TESTS
   LLVM_LIBXML2_ENABLED
   LLVM_LINK_LLVM_DYLIB
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -17,13 +17,13 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_ZLIB_H
+#if LLVM_ENABLE_ZLIB
 #include 
 #endif
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 static Error createError(StringRef Err) {
   return make_error(Err, inconvertibleErrorCode());
 }
Index: llvm/lib/Support/CRC.cpp
===
--- llvm/lib/Support/CRC.cpp
+++ llvm/lib/Support/CRC.cpp
@@ -25,7 +25,7 @@
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB == 0 || !HAVE_ZLIB_H
+#if !LLVM_ENABLE_ZLIB
 
 static const uint32_t CRCTable[256] = {
 0x, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -1,7 +1,4 @@
-set(system_libs)
-if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
-  set(system_libs ${system_libs} ${ZLIB_LIBRARIES})
-endif()
+set(system_libs ${ZLIB_LIBRARY})
 if( MSVC OR MINGW )
   # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
   # advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
Index: llvm/include/llvm/Config/config.h.cmake
===
--- llvm/include/llvm/Config/config.h.cmake
+++ llvm/include/llvm/Config/config.h.cmake
@@ -109,9 +109,6 @@
 /* Define to 1 if you have the `pthread_setname_np' function. */
 #cmakedefine HAVE_PTHREAD_SETNAME_NP ${HAVE_PTHREAD_SETNAME_NP}
 
-/* Define to 1 if you have the `z' library (-lz). */
-#cmakedefine HAVE_LIBZ ${HAVE_LIBZ}
-
 /* Define to 1 if you have the  header file. */
 #cmakedefine HAVE_LINK_H ${HAVE_LINK_H}
 
@@ -226,9 +223,6 @@
 /* Define to 1 if you have the  header file. */
 #cmakedefine HAVE_VALGRIND_VALGRIND_H ${HAVE_VALGRIND_VALGRIND_H}
 
-/* Define to 1 if you have the  header file. */
-#cmakedefine HAVE_ZLIB_H ${HAVE_ZLIB_H}
-
 /* Have host's _alloca */
 #cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA}
 
Index: 

[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

The ugly path separator pattern `{{(/|)}}` appears in 60+ tests. Can we 
teach clang and other tools to

1. accept both `/` and `\` input
2. but only output `/`

on Windows? We can probably remove 
`llvm::sys::path::Style::{windows,posix,native}` from 
`include/llvm/Support/Path.h` and only keep the posix form.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

Does this work on Windows?

  --- i/clang/test/Preprocessor/file_test.c
  +++ w/clang/test/Preprocessor/file_test.c
  @@ -1,8 +1,7 @@
  -// XFAIL: system-windows
   // RUN: %clang -E -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | 
FileCheck %s
   // RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | 
FileCheck %s
   // RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH=empty -c -o - %s | 
FileCheck %s -check-prefix CHECK-EVIL
  -// RUN: %clang -E -fmacro-prefix-map=%p/= -c -o - %s | FileCheck %s 
--check-prefix CHECK-REMOVE
  +// RUN: %clang -E -fmacro-prefix-map=%/p/= -c -o - %/s | FileCheck %s 
--check-prefix CHECK-REMOVE

`startswith` is not ideal because `/t` will match `/tmp`. However, gcc appears 
to use something similar to `startswith`, see:

  % gcc -c -g -fdebug-prefix-map=/t=x /tmp/c/a.c -o /tmp/c/a.o
  % llvm-dwarfdump /tmp/c/a.o | grep -m 1 DW_AT_name
DW_AT_name("xmp/c/a.c")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay updated this revision to Diff 231142.
MaskRay added a comment.

Minimize diff in Options.td
Properly rebase remapDIPath on top of D69213 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/Driver/debug-prefix-map.S
  clang/test/Driver/debug-prefix-map.c
  clang/test/Preprocessor/file_test.c
  clang/test/Preprocessor/file_test.h
  llvm/include/llvm/Support/Path.h
  llvm/lib/Support/Path.cpp
  llvm/unittests/Support/Path.cpp

Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1230,7 +1230,9 @@
 TEST(Support, ReplacePathPrefix) {
   SmallString<64> Path1("/foo");
   SmallString<64> Path2("/old/foo");
+  SmallString<64> Path3("/oldnew/foo");
   SmallString<64> OldPrefix("/old");
+  SmallString<64> OldPrefixSep("/old/");
   SmallString<64> NewPrefix("/new");
   SmallString<64> NewPrefix2("/longernew");
   SmallString<64> EmptyPrefix("");
@@ -1250,6 +1252,33 @@
   Path = Path2;
   path::replace_path_prefix(Path, OldPrefix, EmptyPrefix);
   EXPECT_EQ(Path, "/foo");
+  Path = Path2;
+  path::replace_path_prefix(Path, OldPrefix, EmptyPrefix, true);
+  EXPECT_EQ(Path, "foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, false);
+  EXPECT_EQ(Path, "/newnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path1;
+  path::replace_path_prefix(Path, EmptyPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/foo");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new");
+  Path = OldPrefixSep;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, false);
+  EXPECT_EQ(Path, "/old");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/new");
 }
 
 TEST_F(FileSystemTest, OpenFileForRead) {
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -496,27 +496,50 @@
   path.append(ext.begin(), ext.end());
 }
 
-void replace_path_prefix(SmallVectorImpl ,
+bool replace_path_prefix(SmallVectorImpl ,
  const StringRef , const StringRef ,
- Style style) {
+ Style style, bool strict) {
   if (OldPrefix.empty() && NewPrefix.empty())
-return;
+return false;
 
   StringRef OrigPath(Path.begin(), Path.size());
-  if (!OrigPath.startswith(OldPrefix))
-return;
+  StringRef OldPrefixDir;
+
+  if (!strict && OldPrefix.size() > OrigPath.size())
+return false;
+
+  // Ensure OldPrefixDir does not have a trailing separator.
+  if (!OldPrefix.empty() && is_separator(OldPrefix.back()))
+OldPrefixDir = parent_path(OldPrefix, style);
+  else
+OldPrefixDir = OldPrefix;
+
+  if (!OrigPath.startswith(OldPrefixDir))
+return false;
+
+  if (OrigPath.size() > OldPrefixDir.size())
+if (!is_separator(OrigPath[OldPrefixDir.size()], style) && strict)
+  return false;
 
   // If prefixes have the same size we can simply copy the new one over.
-  if (OldPrefix.size() == NewPrefix.size()) {
+  if (OldPrefixDir.size() == NewPrefix.size() && !strict) {
 llvm::copy(NewPrefix, Path.begin());
-return;
+return true;
   }
 
-  StringRef RelPath = OrigPath.substr(OldPrefix.size());
+  StringRef RelPath = OrigPath.substr(OldPrefixDir.size());
   SmallString<256> NewPath;
   path::append(NewPath, style, NewPrefix);
-  path::append(NewPath, style, RelPath);
+  if (!RelPath.empty()) {
+if (!is_separator(RelPath[0], style) || !strict)
+  path::append(NewPath, style, RelPath);
+else
+  path::append(NewPath, style, relative_path(RelPath, style));
+  }
+
   Path.swap(NewPath);
+
+  return true;
 }
 
 void native(const Twine , SmallVectorImpl , Style style) {
Index: llvm/include/llvm/Support/Path.h
===
--- llvm/include/llvm/Support/Path.h
+++ llvm/include/llvm/Support/Path.h
@@ -152,18 +152,33 @@
 ///
 /// @code
 ///   

[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay updated this revision to Diff 231140.
MaskRay added a comment.

Add back remapDIPath that was unintentionally deleted by D69213 
, caught by a test.

Small adjustment of the code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/Driver/debug-prefix-map.S
  clang/test/Driver/debug-prefix-map.c
  clang/test/Preprocessor/file_test.c
  clang/test/Preprocessor/file_test.h
  llvm/include/llvm/Support/Path.h
  llvm/lib/Support/Path.cpp
  llvm/unittests/Support/Path.cpp

Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1230,7 +1230,9 @@
 TEST(Support, ReplacePathPrefix) {
   SmallString<64> Path1("/foo");
   SmallString<64> Path2("/old/foo");
+  SmallString<64> Path3("/oldnew/foo");
   SmallString<64> OldPrefix("/old");
+  SmallString<64> OldPrefixSep("/old/");
   SmallString<64> NewPrefix("/new");
   SmallString<64> NewPrefix2("/longernew");
   SmallString<64> EmptyPrefix("");
@@ -1250,6 +1252,33 @@
   Path = Path2;
   path::replace_path_prefix(Path, OldPrefix, EmptyPrefix);
   EXPECT_EQ(Path, "/foo");
+  Path = Path2;
+  path::replace_path_prefix(Path, OldPrefix, EmptyPrefix, true);
+  EXPECT_EQ(Path, "foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, false);
+  EXPECT_EQ(Path, "/newnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path1;
+  path::replace_path_prefix(Path, EmptyPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/foo");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new");
+  Path = OldPrefixSep;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, false);
+  EXPECT_EQ(Path, "/old");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/new");
 }
 
 TEST_F(FileSystemTest, OpenFileForRead) {
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -496,27 +496,50 @@
   path.append(ext.begin(), ext.end());
 }
 
-void replace_path_prefix(SmallVectorImpl ,
+bool replace_path_prefix(SmallVectorImpl ,
  const StringRef , const StringRef ,
- Style style) {
+ Style style, bool strict) {
   if (OldPrefix.empty() && NewPrefix.empty())
-return;
+return false;
 
   StringRef OrigPath(Path.begin(), Path.size());
-  if (!OrigPath.startswith(OldPrefix))
-return;
+  StringRef OldPrefixDir;
+
+  if (!strict && OldPrefix.size() > OrigPath.size())
+return false;
+
+  // Ensure OldPrefixDir does not have a trailing separator.
+  if (!OldPrefix.empty() && is_separator(OldPrefix.back()))
+OldPrefixDir = parent_path(OldPrefix, style);
+  else
+OldPrefixDir = OldPrefix;
+
+  if (!OrigPath.startswith(OldPrefixDir))
+return false;
+
+  if (OrigPath.size() > OldPrefixDir.size())
+if (!is_separator(OrigPath[OldPrefixDir.size()], style) && strict)
+  return false;
 
   // If prefixes have the same size we can simply copy the new one over.
-  if (OldPrefix.size() == NewPrefix.size()) {
+  if (OldPrefixDir.size() == NewPrefix.size() && !strict) {
 llvm::copy(NewPrefix, Path.begin());
-return;
+return true;
   }
 
-  StringRef RelPath = OrigPath.substr(OldPrefix.size());
+  StringRef RelPath = OrigPath.substr(OldPrefixDir.size());
   SmallString<256> NewPath;
   path::append(NewPath, style, NewPrefix);
-  path::append(NewPath, style, RelPath);
+  if (!RelPath.empty()) {
+if (!is_separator(RelPath[0], style) || !strict)
+  path::append(NewPath, style, RelPath);
+else
+  path::append(NewPath, style, relative_path(RelPath, style));
+  }
+
   Path.swap(NewPath);
+
+  return true;
 }
 
 void native(const Twine , SmallVectorImpl , Style style) {
Index: llvm/include/llvm/Support/Path.h
===
--- llvm/include/llvm/Support/Path.h
+++ llvm/include/llvm/Support/Path.h
@@ 

[Lldb-commits] [PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-26 Thread Eric Christopher via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd39b1bb20ce: Revert Revert As a follow-up to my 
initial mail to llvm-dev heres a first… (authored by echristo).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65410?vs=230987=231172#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65410

Files:
  clang/test/CodeGen/2008-07-30-implicit-initialization.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments2.cpp
  clang/test/CodeGen/atomic-ops-libcall.c
  clang/test/CodeGenCXX/atomicinit.cpp
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/discard-name-values.cpp
  clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
  clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenCXX/stack-reuse.cpp
  clang/test/CodeGenCXX/wasm-args-returns.cpp
  clang/test/CodeGenObjCXX/arc-blocks.mm
  clang/test/CodeGenObjCXX/nrvo.mm
  clang/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
  clang/test/PCH/no-escaping-block-tail-calls.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/Makefile
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
  llvm/test/Feature/optnone-opt.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Transforms/MemCpyOpt/lifetime.ll
  llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
  llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll

Index: llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
===
--- llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
+++ llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
@@ -74,7 +74,7 @@
 define i32 @two_shifts_by_sext_with_extra_use(i32 %val, i8 signext %len) {
 ; CHECK-LABEL: @two_shifts_by_sext_with_extra_use(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[LEN:%.*]] to i32
-; CHECK-NEXT:tail call void @use_int32(i32 [[CONV]])
+; CHECK-NEXT:call void @use_int32(i32 [[CONV]])
 ; CHECK-NEXT:[[SHL:%.*]] = shl i32 [[VAL:%.*]], [[CONV]]
 ; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SHL]], [[CONV]]
 ; CHECK-NEXT:ret i32 [[SHR]]
@@ -101,7 +101,7 @@
 define i32 @two_shifts_by_same_sext_with_extra_use(i32 %val, i8 signext %len) {
 ; CHECK-LABEL: @two_shifts_by_same_sext_with_extra_use(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[LEN:%.*]] to i32
-; CHECK-NEXT:tail call void @use_int32(i32 [[CONV]])
+; CHECK-NEXT:call void @use_int32(i32 [[CONV]])
 ; CHECK-NEXT:[[SHL:%.*]] = shl i32 [[VAL:%.*]], [[CONV]]
 ; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SHL]], [[CONV]]
 ; CHECK-NEXT:ret i32 [[SHR]]
Index: llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
===
--- llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
+++ llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
@@ -7,7 +7,7 @@
 
 define i1 @PR33605(i32 %a, i32 %b, i32* %c) {
 ; ALL-LABEL: @PR33605(
-; ALL-NEXT:  for.body:
+; ALL-NEXT:  entry:
 ; ALL-NEXT:[[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
 ; ALL-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
 ; ALL-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
@@ -15,16 +15,16 @@
 ; ALL-NEXT:br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
 ; ALL:   if.then:
 ; ALL-NEXT:store i32 [[OR]], i32* [[ARRAYIDX]], align 4
-; ALL-NEXT:tail call void @foo()
+; ALL-NEXT:call void @foo()
 ; ALL-NEXT:br label [[IF_END]]
 ; ALL:   if.end:
-; ALL-NEXT:[[CHANGED_1_OFF0:%.*]] = 

[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

In D49466#1761044 , @thakis wrote:

> There's still one failing test on Windows after the fix attempt: 
> http://45.33.8.238/win/3052/step_6.txt
>
> Please take a look and revert if it's not an easy fix. (And please watch bots 
> after committing stuff.)


XFAIL'ed `clang/test/Preprocessor/file_test.c`. I didn't receive an email from 
http://45.33.8.238/win/3052/step_6.txt not sure if that was because the author 
email was @dankm's, not mine. If there is a console. please tell me :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Dan McGregor via Phabricator via lldb-commits
dankm added a comment.

In D49466#1760860 , @MaskRay wrote:

> Add back remapDIPath that was unintentionally deleted by D69213 
> , caught by a test.
>
> Small adjustment of the code


Right. Can't believe I missed that. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c92cdff7225: Initial implementation of -fmacro-prefix-map 
and -ffile-prefix-map (authored by dankm, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/Driver/debug-prefix-map.S
  clang/test/Driver/debug-prefix-map.c
  clang/test/Preprocessor/file_test.c
  clang/test/Preprocessor/file_test.h
  llvm/include/llvm/Support/Path.h
  llvm/lib/Support/Path.cpp
  llvm/unittests/Support/Path.cpp

Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1230,7 +1230,9 @@
 TEST(Support, ReplacePathPrefix) {
   SmallString<64> Path1("/foo");
   SmallString<64> Path2("/old/foo");
+  SmallString<64> Path3("/oldnew/foo");
   SmallString<64> OldPrefix("/old");
+  SmallString<64> OldPrefixSep("/old/");
   SmallString<64> NewPrefix("/new");
   SmallString<64> NewPrefix2("/longernew");
   SmallString<64> EmptyPrefix("");
@@ -1250,6 +1252,33 @@
   Path = Path2;
   path::replace_path_prefix(Path, OldPrefix, EmptyPrefix);
   EXPECT_EQ(Path, "/foo");
+  Path = Path2;
+  path::replace_path_prefix(Path, OldPrefix, EmptyPrefix, true);
+  EXPECT_EQ(Path, "foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, false);
+  EXPECT_EQ(Path, "/newnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path1;
+  path::replace_path_prefix(Path, EmptyPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/foo");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new");
+  Path = OldPrefixSep;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, false);
+  EXPECT_EQ(Path, "/old");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/new");
 }
 
 TEST_F(FileSystemTest, OpenFileForRead) {
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -496,27 +496,50 @@
   path.append(ext.begin(), ext.end());
 }
 
-void replace_path_prefix(SmallVectorImpl ,
+bool replace_path_prefix(SmallVectorImpl ,
  const StringRef , const StringRef ,
- Style style) {
+ Style style, bool strict) {
   if (OldPrefix.empty() && NewPrefix.empty())
-return;
+return false;
 
   StringRef OrigPath(Path.begin(), Path.size());
-  if (!OrigPath.startswith(OldPrefix))
-return;
+  StringRef OldPrefixDir;
+
+  if (!strict && OldPrefix.size() > OrigPath.size())
+return false;
+
+  // Ensure OldPrefixDir does not have a trailing separator.
+  if (!OldPrefix.empty() && is_separator(OldPrefix.back()))
+OldPrefixDir = parent_path(OldPrefix, style);
+  else
+OldPrefixDir = OldPrefix;
+
+  if (!OrigPath.startswith(OldPrefixDir))
+return false;
+
+  if (OrigPath.size() > OldPrefixDir.size())
+if (!is_separator(OrigPath[OldPrefixDir.size()], style) && strict)
+  return false;
 
   // If prefixes have the same size we can simply copy the new one over.
-  if (OldPrefix.size() == NewPrefix.size()) {
+  if (OldPrefixDir.size() == NewPrefix.size() && !strict) {
 llvm::copy(NewPrefix, Path.begin());
-return;
+return true;
   }
 
-  StringRef RelPath = OrigPath.substr(OldPrefix.size());
+  StringRef RelPath = OrigPath.substr(OldPrefixDir.size());
   SmallString<256> NewPath;
   path::append(NewPath, style, NewPrefix);
-  path::append(NewPath, style, RelPath);
+  if (!RelPath.empty()) {
+if (!is_separator(RelPath[0], style) || !strict)
+  path::append(NewPath, style, RelPath);
+else
+  path::append(NewPath, style, relative_path(RelPath, style));
+  }
+
   Path.swap(NewPath);
+
+  return true;
 }
 
 void native(const Twine , SmallVectorImpl , Style style) {
Index: llvm/include/llvm/Support/Path.h
===
--- llvm/include/llvm/Support/Path.h
+++ llvm/include/llvm/Support/Path.h
@@ 

[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Dan McGregor via Phabricator via lldb-commits
dankm added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[Lldb-commits] [PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

In D49466#1760765 , @dankm wrote:

> Ping?


The tests need fixing... I can commit it. Now that we've migrated to the llvm 
monorepo, the git commit message can retain the author info properly...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[Lldb-commits] [PATCH] D70745: [LLDB] [PECOFF] Look for the truncated ".eh_fram" section name

2019-11-26 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

Is `.eh_frame` the only one that matters?  Should this be more general and 
compare `const_sect_name` to the full name and the truncated name for any known 
section names?

If the giant cascade of else-if were factored into a separate function, then a 
trivial unit test could verify that it returns the right section_type for a 
variety of full and truncated names (as well as other combinations of section 
headers).

Although not directly relevant to this patch, it seems like a lot this cascade 
could be made more readable and maintainable by replacing the simple 
if-name-set-section_type cases were replaced with a lookup into a table (and 
that lookup could be the one place to check both the full name and the 
truncated name).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70745



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


[Lldb-commits] [PATCH] D70742: [LLDB] [Windows] Avoid using InitializeContext for allocating a CONTEXT. NFC.

2019-11-26 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

That's fair.  LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70742



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


[Lldb-commits] [PATCH] D70742: [LLDB] [Windows] Avoid using InitializeContext for allocating a CONTEXT. NFC.

2019-11-26 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo marked an inline comment as done.
mstorsjo added inline comments.



Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:158
+  memset(_context, 0, sizeof(m_context));
+  m_context.ContextFlags = kWinContextFlags;
   if (::SuspendThread(

amccarth wrote:
> As far as I understand what InitializeContext does, this seems a suitable 
> replacement for how it's used here.
> 
> But if someone were to change the flag to include CONTEXT_XSTATE, then this 
> would no longer work, because the xstate is variable length.
> 
> I would suggest:
> 
> 1.  Eliminate the kWinContextFlags (defined at the top of this file) and just 
> use CONTEXT_ALL here.  The extra name doesn't seem to clarify anything, and 
> the distance between the definition and usage can make it harder for folks to 
> understand this code.
> 
> 2.  Add a comment saying this is a substitute for InitializeContext for Wine, 
> which makes searching the code for `InitializeContext` useful.
Good point re `CONTEXT_XSTATE`; as far as I see the NativeRegisterContext 
classes share that limitation as well.

As for the change suggestions, 1. makes sense to me.

As for 2, while wine was the reason for looking at this originally, it's not a 
place where InitializeContext makes much sense to begin with, IMO. If you read 
the current original code, we just use it for getting a (variably sized) 
CONTEXT pointer in a large zero-initialized buffer, to use for memcpying over a 
fixed sized CONTEXT elsewhere. None of that feels like what InitializeContext 
does.

Or put another way; I wouldn't like to point out wine here, as I wouldn't 
suggest this change if I felt the use of InitializeContext was justified here. 
(In that case I'd probably fix wine instead.) If we'd get rid of the fixed size 
allocation of `m_context`, using InitializeContext for allocating a pointer 
would make sense though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70742



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


[Lldb-commits] [PATCH] D70742: [LLDB] [Windows] Avoid using InitializeContext for allocating a CONTEXT. NFC.

2019-11-26 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

I'm good with the change, but have a couple small requests.  I hope to hear 
from others, too, as this area is outside my wheelhouse.




Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:158
+  memset(_context, 0, sizeof(m_context));
+  m_context.ContextFlags = kWinContextFlags;
   if (::SuspendThread(

As far as I understand what InitializeContext does, this seems a suitable 
replacement for how it's used here.

But if someone were to change the flag to include CONTEXT_XSTATE, then this 
would no longer work, because the xstate is variable length.

I would suggest:

1.  Eliminate the kWinContextFlags (defined at the top of this file) and just 
use CONTEXT_ALL here.  The extra name doesn't seem to clarify anything, and the 
distance between the definition and usage can make it harder for folks to 
understand this code.

2.  Add a comment saying this is a substitute for InitializeContext for Wine, 
which makes searching the code for `InitializeContext` useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70742



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


[Lldb-commits] [PATCH] D70745: [LLDB] [PECOFF] Look for the truncated ".eh_fram" section name

2019-11-26 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth.
Herald added a project: LLDB.

COFF section names can either be stored truncated to 8 chars, in the section 
header, or as a longer section name, stored separately in the string table.

libunwind locates the .eh_frame section by runtime introspection, which only 
works for section names stored in the section header (as the string table isn't 
mapped at runtime). To support this behaviour, lld always truncates the section 
names for sections that will be mapped, like .eh_frame.

The change is simple, but is there any straightforward way of making a test for 
this? I can detect whether the .eh_frame section was picked up by e.g. `image 
show-unwind -n `, but that requires actually executing a process first. 
Is there any simpler form of a test that could run without actually executing a 
process here?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70745

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp


Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -836,6 +836,7 @@
   static ConstString g_sect_name_dwarf_debug_str(".debug_str");
   static ConstString g_sect_name_dwarf_debug_types(".debug_types");
   static ConstString g_sect_name_eh_frame(".eh_frame");
+  static ConstString g_sect_name_eh_frame_trunc(".eh_fram");
   static ConstString g_sect_name_go_symtab(".gosymtab");
   SectionType section_type = eSectionTypeOther;
   if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE &&
@@ -894,6 +895,8 @@
 section_type = eSectionTypeDWARFDebugTypes;
   else if (const_sect_name == g_sect_name_eh_frame)
 section_type = eSectionTypeEHFrame;
+  else if (const_sect_name == g_sect_name_eh_frame_trunc)
+section_type = eSectionTypeEHFrame;
   else if (const_sect_name == g_sect_name_go_symtab)
 section_type = eSectionTypeGoSymtab;
   else if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE) {


Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -836,6 +836,7 @@
   static ConstString g_sect_name_dwarf_debug_str(".debug_str");
   static ConstString g_sect_name_dwarf_debug_types(".debug_types");
   static ConstString g_sect_name_eh_frame(".eh_frame");
+  static ConstString g_sect_name_eh_frame_trunc(".eh_fram");
   static ConstString g_sect_name_go_symtab(".gosymtab");
   SectionType section_type = eSectionTypeOther;
   if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE &&
@@ -894,6 +895,8 @@
 section_type = eSectionTypeDWARFDebugTypes;
   else if (const_sect_name == g_sect_name_eh_frame)
 section_type = eSectionTypeEHFrame;
+  else if (const_sect_name == g_sect_name_eh_frame_trunc)
+section_type = eSectionTypeEHFrame;
   else if (const_sect_name == g_sect_name_go_symtab)
 section_type = eSectionTypeGoSymtab;
   else if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70742: [LLDB] [Windows] Avoid using InitializeContext for allocating a CONTEXT. NFC.

2019-11-26 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth, asmith, aleksandr.urakov.
Herald added a project: LLDB.

InitializeContext is useful for allocating a CONTEXT struct in an unaligned 
byte buffer. In this case, we already have a CONTEXT we want to initialize, and 
we only used this as a very roundabout way of zero initializing it.

Instead just memset the CONTEXT we have, and set the ContextFlags field 
manually.

This matches how it is done in NativeRegisterContextWindows_*.cpp.

This also makes LLDB run successfully in Wine (for a trivial tested case at 
least), as Wine haven't implemented the InitializeContext function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70742

Files:
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp


Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -154,15 +154,8 @@
 return true;
 
   TargetThreadWindows  = static_cast(m_thread);
-  uint8_t buffer[2048];
-  memset(buffer, 0, sizeof(buffer));
-  PCONTEXT tmpContext = NULL;
-  DWORD contextLength = (DWORD)sizeof(buffer);
-  if (!::InitializeContext(buffer, kWinContextFlags, ,
-   )) {
-return false;
-  }
-  memcpy(_context, tmpContext, sizeof(m_context));
+  memset(_context, 0, sizeof(m_context));
+  m_context.ContextFlags = kWinContextFlags;
   if (::SuspendThread(
   wthread.GetHostThread().GetNativeThread().GetSystemHandle()) ==
   (DWORD)-1) {


Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -154,15 +154,8 @@
 return true;
 
   TargetThreadWindows  = static_cast(m_thread);
-  uint8_t buffer[2048];
-  memset(buffer, 0, sizeof(buffer));
-  PCONTEXT tmpContext = NULL;
-  DWORD contextLength = (DWORD)sizeof(buffer);
-  if (!::InitializeContext(buffer, kWinContextFlags, ,
-   )) {
-return false;
-  }
-  memcpy(_context, tmpContext, sizeof(m_context));
+  memset(_context, 0, sizeof(m_context));
+  m_context.ContextFlags = kWinContextFlags;
   if (::SuspendThread(
   wthread.GetHostThread().GetNativeThread().GetSystemHandle()) ==
   (DWORD)-1) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70647: RFC 3/3: Remove DWARFDIE dependency from functions moved by D70646

2019-11-26 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil planned changes to this revision.
jankratochvil marked 2 inline comments as done.
jankratochvil added inline comments.



Comment at: lldb/include/lldb/Symbol/TypeSystem.h:108-110
+  virtual DWARFASTParser *GetDWARFParser(SymbolFileDWARF ) {
+return nullptr;
+  }

labath wrote:
> This part looks pretty dodgy. I'd like to avoid introducing plugin references 
> in non-plugin code. It looks like this class isn't particularly clean already 
> (DWARFDIE forward decl), but this seems to make the problem much worse.
> 
> Since this class already contains a `SymbolFile` pointer, maybe we could 
> create some kind of a ast-parser constructing method on the SymbolFile class 
> to avoid mentioning the SymbolFileDWARF directly.
> 
> If I was doing this, I'd probably try to take this one step further and merge 
> the `GetDWARFParser`/`GetPDBParser` methods (whose only calls are in the 
> relevant symbol file plugins) into a single `GetASTParser` method and do 
> appropriate casts in the plugins themselves.
TBH I did not do the described refactoring, I just used the existing 
`m_sym_file`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70647



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


[Lldb-commits] [PATCH] D70647: RFC 3/3: Remove DWARFDIE dependency from functions moved by D70646

2019-11-26 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 231124.
jankratochvil added a comment.

Remove that dodgy new parameter `SymbolFileDWARF `.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70647

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -48,7 +48,7 @@
 TEST_F(DWARFASTParserClangTests,
EnsureAllDIEsInDeclContextHaveBeenParsedParsesOnlyMatchingEntries) {
   ClangASTContext ast_ctx;
-  DWARFASTParserClangStub ast_parser(ast_ctx);
+  DWARFASTParserClangStub ast_parser(ast_ctx, *(SymbolFileDWARF *)1LL);
 
   DWARFUnit *unit = nullptr;
   std::vector dies = {DWARFDIE(unit, (DWARFDebugInfoEntry *)1LL),
Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -95,6 +95,7 @@
 
 #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
 #include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
 #include "Plugins/SymbolFile/PDB/PDBASTParser.h"
 
 #include 
@@ -9812,8 +9813,11 @@
 }
 
 DWARFASTParser *ClangASTContext::GetDWARFParser() {
-  if (!m_dwarf_ast_parser_up)
-m_dwarf_ast_parser_up.reset(new DWARFASTParserClang(*this));
+  if (!m_dwarf_ast_parser_up) {
+SymbolFileDWARF *dwarf = llvm::dyn_cast(m_sym_file);
+if (dwarf)
+  m_dwarf_ast_parser_up.reset(new DWARFASTParserClang(*this, *dwarf));
+  }
   return m_dwarf_ast_parser_up.get();
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -44,8 +44,7 @@
   llvm::Expected
   GetTypeSystemForLanguage(lldb::LanguageType language) override;
 
-  DWARFDIE
-  GetDIE(const DIERef _ref) override;
+  DWARFUnit *GetUnit(DIERef die_ref) override;
 
   std::unique_ptr
   GetDwoSymbolFileForCompileUnit(DWARFUnit _cu,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -147,9 +147,8 @@
   return GetBaseSymbolFile().GetTypeSystemForLanguage(language);
 }
 
-DWARFDIE
-SymbolFileDWARFDwo::GetDIE(const DIERef _ref) {
+DWARFUnit *SymbolFileDWARFDwo::GetUnit(DIERef die_ref) {
   if (*die_ref.dwo_num() == GetDwoNum())
-return DebugInfo()->GetDIE(die_ref);
-  return GetBaseSymbolFile().GetDIE(die_ref);
+return DebugInfo()->GetUnit(die_ref);
+  return GetBaseSymbolFile().GetUnit(die_ref);
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -275,7 +275,9 @@
   return m_external_type_modules;
   }
 
-  virtual DWARFDIE GetDIE(const DIERef _ref);
+  virtual DWARFUnit *GetUnit(DIERef die_ref);
+
+  DWARFDIE GetDIE(DIERef die_ref);
 
   DWARFDIE GetDIE(lldb::user_id_t uid);
 
@@ -303,9 +305,9 @@
   /// If this is a DWARF object with a single CU, return its DW_AT_dwo_id.
   llvm::Optional GetDWOId();
 
-  static bool
+  bool
   DIEInDeclContext(const lldb_private::CompilerDeclContext *parent_decl_ctx,
-   const DWARFDIE );
+   const DWARFDIE , DIERef die_ref);
 
   std::vector>
   ParseCallEdgesInFunction(UserID func_id) override;
@@ -318,26 +320,29 @@
 
   lldb_private::FileSpec GetFile(DWARFUnit , size_t file_idx);
 
-  static llvm::Expected
-  GetTypeSystem(DWARFUnit );
+  lldb::LanguageType GetLanguage(DIERef die_ref);
+
+  DWARFASTParser *GetDWARFParser(lldb::LanguageType language);
+
+  DWARFASTParser *GetDWARFParser(DIERef die_ref);
 
-  static DWARFASTParser *GetDWARFParser(DWARFUnit );
+  DWARFASTParser *GetDWARFParser(lldb::user_id_t die_uid,
+

[Lldb-commits] [PATCH] D70722: [lldb/IRExecutionUnit] Stop searching based on demangled names

2019-11-26 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, JDevlieghere.
Herald added a project: LLDB.
labath added a parent revision: D70721: [lldb/cpluspluslanguage] Add 
constructor substitutor.

This was causing problems on linux, where we'd end up calling the
deleting destructor instead of a regular one (because they have the same
demangled name), making a lot of mischief in the process.

The only place where this was necessary (according to the test suite, at
least) was to call a base structor instead of a complete one, but this
is now handled in a more targeted fashion.

TestCallOverriddenMethod is now re-enabled as it now passes reliably.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70722

Files:
  
lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
  lldb/source/Expression/IRExecutionUnit.cpp


Index: lldb/source/Expression/IRExecutionUnit.cpp
===
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -728,8 +728,6 @@
 if (best_alternate_mangled_name) {
   CPP_specs.push_back(best_alternate_mangled_name);
 }
-
-CPP_specs.push_back(SearchSpec(demangled, 
lldb::eFunctionNameTypeFull));
   }
 }
 
Index: 
lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
===
--- 
lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
+++ 
lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
@@ -63,7 +63,6 @@
 # a vtable entry that does not exist in the compiled program).
 self.expect("expr d.foo()", substrs=["2"])
 
-@skipIfLinux # Calling constructor causes SIGABRT
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr43707")
 def test_call_on_temporary(self):
 """Test calls to overridden methods in derived classes."""


Index: lldb/source/Expression/IRExecutionUnit.cpp
===
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -728,8 +728,6 @@
 if (best_alternate_mangled_name) {
   CPP_specs.push_back(best_alternate_mangled_name);
 }
-
-CPP_specs.push_back(SearchSpec(demangled, lldb::eFunctionNameTypeFull));
   }
 }
 
Index: lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
===
--- lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
@@ -63,7 +63,6 @@
 # a vtable entry that does not exist in the compiled program).
 self.expect("expr d.foo()", substrs=["2"])
 
-@skipIfLinux # Calling constructor causes SIGABRT
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr43707")
 def test_call_on_temporary(self):
 """Test calls to overridden methods in derived classes."""
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70721: [lldb/cpluspluslanguage] Add constructor substitutor

2019-11-26 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, JDevlieghere.
Herald added a project: LLDB.

This patch adds code which will substitute references to the full object
constructors/destructors with their base object versions.

Like all substitutions in this category, this operation is not really
sound, but doing this in a more precise way allows us to get rid of a
much larger hack -- matching function according to their demangled
names, which effectively does the same thing, but also much more.

This is a (very late) follow-up to D54074 .

Background: clang has an optimization which can eliminate full object
structors completely, if they are found to be equivalent to their base
object versions. It does this because it assumes they can be regenerated
on demand in the compile unit that needs them (e.g., because they are
declared inline). However, this doesn't work for the debugging scenario,
where we don't have the structor bodies available -- we pretend all
constructors are defined out-of-line as far as clang is concerned. This
causes clang to emit references to the (nonexisting) full object
structors during expression evaluation.

Fun fact: This is not a problem on darwin, because the relevant
optimization is disabled to work around a linker bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70721

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Index: lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -191,6 +191,8 @@
   EXPECT_THAT(FindAlternate("_ZN1A1fEx"), Contains("_ZN1A1fEl"));
   EXPECT_THAT(FindAlternate("_ZN1A1fEy"), Contains("_ZN1A1fEm"));
   EXPECT_THAT(FindAlternate("_ZN1A1fEai"), Contains("_ZN1A1fEci"));
+  EXPECT_THAT(FindAlternate("_ZN1AC1Ev"), Contains("_ZN1AC2Ev"));
+  EXPECT_THAT(FindAlternate("_ZN1AD1Ev"), Contains("_ZN1AD2Ev"));
   EXPECT_THAT(FindAlternate("_bogus"), IsEmpty());
 }
 
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -284,46 +284,34 @@
   }
 };
 
-/// Given a mangled function `Mangled`, replace all the primitive function type
-/// arguments of `Search` with type `Replace`.
-class TypeSubstitutor
-: public llvm::itanium_demangle::AbstractManglingParser
+class ManglingSubstitutor
+: public llvm::itanium_demangle::AbstractManglingParser {
-  /// Input character until which we have constructed the respective output
-  /// already
-  const char *Written;
+  using Base =
+  llvm::itanium_demangle::AbstractManglingParser;
 
-  llvm::StringRef Search;
-  llvm::StringRef Replace;
-  llvm::SmallString<128> Result;
+public:
+  ManglingSubstitutor() : Base(nullptr, nullptr) {}
 
-  /// Whether we have performed any substitutions.
-  bool Substituted;
+  template
+  ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) {
+this->getDerived().reset(Mangled, std::forward(Vals)...);
+return substituteImpl(Mangled);
+  }
 
-  void reset(llvm::StringRef Mangled, llvm::StringRef Search,
- llvm::StringRef Replace) {
-AbstractManglingParser::reset(Mangled.begin(), Mangled.end());
+
+protected:
+  void reset(llvm::StringRef Mangled) {
+Base::reset(Mangled.begin(), Mangled.end());
 Written = Mangled.begin();
-this->Search = Search;
-this->Replace = Replace;
 Result.clear();
 Substituted = false;
   }
 
-  void appendUnchangedInput() {
-Result += llvm::StringRef(Written, First - Written);
-Written = First;
-  }
-
-public:
-  TypeSubstitutor() : AbstractManglingParser(nullptr, nullptr) {}
-
-  ConstString substitute(llvm::StringRef Mangled, llvm::StringRef From,
- llvm::StringRef To) {
+  ConstString substituteImpl(llvm::StringRef Mangled) {
 Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
-
-reset(Mangled, From, To);
-if (parse() == nullptr) {
+if (this->parse() == nullptr) {
   LLDB_LOG(log, "Failed to substitute mangling in {0}", Mangled);
   return ConstString();
 }
@@ -336,20 +324,67 @@
 return ConstString(Result);
   }
 
+  bool trySubstitute(llvm::StringRef From, llvm::StringRef To) {
+if (!llvm::StringRef(this->First, this->numLeft()).startswith(From))
+  return false;
+
+// We found a match. Append unmodified input up to this point.
+appendUnchangedInput();
+
+// And then perform the replacement.
+Result += To;
+Written += From.size();
+Substituted = true;
+return true;
+  }
+
+private:
+  /// Input character until which we have 

[Lldb-commits] [lldb] 5871cba - [lldb] Avoid snprintf in PlatformRemoteDarwinDevice

2019-11-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-26T15:16:26+01:00
New Revision: 5871cba86172c5bd947952a9441acf80332455ea

URL: 
https://github.com/llvm/llvm-project/commit/5871cba86172c5bd947952a9441acf80332455ea
DIFF: 
https://github.com/llvm/llvm-project/commit/5871cba86172c5bd947952a9441acf80332455ea.diff

LOG: [lldb] Avoid snprintf in PlatformRemoteDarwinDevice

This quashes a -Wformat-truncation warning.

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
index e9bb29293189..0aa129c808d4 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
@@ -449,12 +449,10 @@ Status PlatformRemoteDarwinDevice::GetSymbolFile(const 
FileSpec _file,
   Status error;
   char platform_file_path[PATH_MAX];
   if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
-char resolved_path[PATH_MAX];
-
 const char *os_version_dir = GetDeviceSupportDirectoryForOSVersion();
 if (os_version_dir) {
-  ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", os_version_dir,
- platform_file_path);
+  std::string resolved_path =
+  (llvm::Twine(os_version_dir) + "/" + platform_file_path).str();
 
   local_file.SetFile(resolved_path, FileSpec::Style::native);
   FileSystem::Instance().Resolve(local_file);
@@ -466,31 +464,28 @@ Status PlatformRemoteDarwinDevice::GetSymbolFile(const 
FileSpec _file,
 return error;
   }
 
-  ::snprintf(resolved_path, sizeof(resolved_path), 
"%s/Symbols.Internal/%s",
- os_version_dir, platform_file_path);
+  resolved_path = (llvm::Twine(os_version_dir) + "/Symbols.Internal/" +
+   platform_file_path)
+  .str();
 
   local_file.SetFile(resolved_path, FileSpec::Style::native);
   FileSystem::Instance().Resolve(local_file);
   if (FileSystem::Instance().Exists(local_file)) {
-if (log) {
-  LLDB_LOGF(
-  log,
-  "Found a copy of %s in the DeviceSupport dir 
%s/Symbols.Internal",
-  platform_file_path, os_version_dir);
-}
+LLDB_LOGF(
+log,
+"Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal",
+platform_file_path, os_version_dir);
 return error;
   }
-  ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols/%s",
- os_version_dir, platform_file_path);
+  resolved_path =
+  (llvm::Twine(os_version_dir) + "/Symbols/" + platform_file_path)
+  .str();
 
   local_file.SetFile(resolved_path, FileSpec::Style::native);
   FileSystem::Instance().Resolve(local_file);
   if (FileSystem::Instance().Exists(local_file)) {
-if (log) {
-  LLDB_LOGF(log,
-"Found a copy of %s in the DeviceSupport dir %s/Symbols",
-platform_file_path, os_version_dir);
-}
+LLDB_LOGF(log, "Found a copy of %s in the DeviceSupport dir 
%s/Symbols",
+  platform_file_path, os_version_dir);
 return error;
   }
 }



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


[Lldb-commits] [lldb] 16144d2 - [lldb][NFC] Modernize string handling in DWARFASTParserClang::ParseTypeModifier

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T15:04:54+01:00
New Revision: 16144d2b21d90a0515be2fc9158cbaf828abd980

URL: 
https://github.com/llvm/llvm-project/commit/16144d2b21d90a0515be2fc9158cbaf828abd980
DIFF: 
https://github.com/llvm/llvm-project/commit/16144d2b21d90a0515be2fc9158cbaf828abd980.diff

LOG: [lldb][NFC] Modernize string handling in 
DWARFASTParserClang::ParseTypeModifier

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 89331f7aca6c..fe6ab3064447 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -662,11 +662,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext 
,
 if (cu_language == eLanguageTypeObjC ||
 cu_language == eLanguageTypeObjC_plus_plus) {
   if (attrs.name) {
-static ConstString g_objc_type_name_id("id");
-static ConstString g_objc_type_name_Class("Class");
-static ConstString g_objc_type_name_selector("SEL");
-
-if (attrs.name == g_objc_type_name_id) {
+if (attrs.name == "id") {
   if (log)
 dwarf->GetObjectFile()->GetModule()->LogMessage(
 log,
@@ -677,8 +673,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext 
,
   encoding_data_type = Type::eEncodingIsUID;
   attrs.type.Clear();
   resolve_state = Type::ResolveState::Full;
-
-} else if (attrs.name == g_objc_type_name_Class) {
+} else if (attrs.name == "Class") {
   if (log)
 dwarf->GetObjectFile()->GetModule()->LogMessage(
 log,
@@ -689,7 +684,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext 
,
   encoding_data_type = Type::eEncodingIsUID;
   attrs.type.Clear();
   resolve_state = Type::ResolveState::Full;
-} else if (attrs.name == g_objc_type_name_selector) {
+} else if (attrs.name == "SEL") {
   if (log)
 dwarf->GetObjectFile()->GetModule()->LogMessage(
 log,
@@ -709,20 +704,19 @@ DWARFASTParserClang::ParseTypeModifier(const 
SymbolContext ,
 const DWARFDIE encoding_die = attrs.type.Reference();
 
 if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type) {
-  if (const char *struct_name = encoding_die.GetName()) {
-if (!strcmp(struct_name, "objc_object")) {
-  if (log)
-dwarf->GetObjectFile()->GetModule()->LogMessage(
-log,
-"SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
-"'%s' is 'objc_object*', which we overrode to "
-"'id'.",
-die.GetOffset(), die.GetTagAsCString(), die.GetName());
-  clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
-  encoding_data_type = Type::eEncodingIsUID;
-  attrs.type.Clear();
-  resolve_state = Type::ResolveState::Full;
-}
+  llvm::StringRef struct_name = encoding_die.GetName();
+  if (struct_name == "objc_object") {
+if (log)
+  dwarf->GetObjectFile()->GetModule()->LogMessage(
+  log,
+  "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
+  "'%s' is 'objc_object*', which we overrode to "
+  "'id'.",
+  die.GetOffset(), die.GetTagAsCString(), die.GetName());
+clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
+encoding_data_type = Type::eEncodingIsUID;
+attrs.type.Clear();
+resolve_state = Type::ResolveState::Full;
   }
 }
   }



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


[Lldb-commits] [lldb] 290e43d - [lldb] Use llvm::format in AppleObjCRuntimeV2.cpp

2019-11-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-26T15:04:13+01:00
New Revision: 290e43ddb660db2e9b294e1e963222c08965d211

URL: 
https://github.com/llvm/llvm-project/commit/290e43ddb660db2e9b294e1e963222c08965d211
DIFF: 
https://github.com/llvm/llvm-project/commit/290e43ddb660db2e9b294e1e963222c08965d211.diff

LOG: [lldb] Use llvm::format in AppleObjCRuntimeV2.cpp

Crushing a "sprintf" buffer is null warning.

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 9bdbef393e39..750b6ce6b0c6 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1625,19 +1625,13 @@ 
AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
 // Substitute in the correct class_getName / class_getNameRaw function 
name,
 // concatenate the two parts of our expression text.  The format string
 // has two %s's, so provide the name twice.
-int prefix_string_size = snprintf (nullptr, 0, 
+std::string shared_class_expression;
+llvm::raw_string_ostream(shared_class_expression) << llvm::format(
g_shared_cache_class_name_funcptr,
class_name_getter_function_name.AsCString(),
class_name_getter_function_name.AsCString());
 
-char *class_name_func_ptr_expr = (char*) malloc (prefix_string_size + 1);
-snprintf (class_name_func_ptr_expr, prefix_string_size + 1,
-  g_shared_cache_class_name_funcptr,
-  class_name_getter_function_name.AsCString(),
-  class_name_getter_function_name.AsCString());
-std::string shared_class_expression = class_name_func_ptr_expr;
 shared_class_expression += g_get_shared_cache_class_info_body;
-free (class_name_func_ptr_expr);
 
 m_get_shared_cache_class_info_code.reset(
 GetTargetRef().GetUtilityFunctionForLanguage(



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


[Lldb-commits] [lldb] 12284e5 - [lldb] fix a -Wcast-qual warning

2019-11-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-26T14:49:16+01:00
New Revision: 12284e54b483c2541eb09cd7c575f438970b66c1

URL: 
https://github.com/llvm/llvm-project/commit/12284e54b483c2541eb09cd7c575f438970b66c1
DIFF: 
https://github.com/llvm/llvm-project/commit/12284e54b483c2541eb09cd7c575f438970b66c1.diff

LOG: [lldb] fix a -Wcast-qual warning

Added: 


Modified: 
lldb/tools/driver/Driver.cpp

Removed: 




diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index fe4a17762f8b..e13507be22da 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -854,7 +854,7 @@ int main(int argc, char const *argv[]) {
   }
 
   // Register the reproducer signal handler.
-  llvm::sys::AddSignalHandler(reproducer_handler, (void *)(argv[0]));
+  llvm::sys::AddSignalHandler(reproducer_handler, const_cast(argv[0]));
 
   SBError error = SBDebugger::InitializeWithErrorHandling();
   if (error.Fail()) {



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


[Lldb-commits] [lldb] 6612fab - [lldb] remove a superfluous semicolon

2019-11-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-26T14:49:16+01:00
New Revision: 6612fabc47f16d265d169b5b73dc8070dde436a8

URL: 
https://github.com/llvm/llvm-project/commit/6612fabc47f16d265d169b5b73dc8070dde436a8
DIFF: 
https://github.com/llvm/llvm-project/commit/6612fabc47f16d265d169b5b73dc8070dde436a8.diff

LOG: [lldb] remove a superfluous semicolon

Added: 


Modified: 
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index b4d8ba2218a1..d556aae1c458 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -62,7 +62,7 @@ bool CPPLanguageRuntime::GetObjectDescription(
 
 bool contains_lambda_identifier(llvm::StringRef _ref) {
   return str_ref.contains("$_") || str_ref.contains("'lambda'");
-};
+}
 
 CPPLanguageRuntime::LibCppStdFunctionCallableInfo
 line_entry_helper(Target , const SymbolContext , Symbol *symbol,



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


[Lldb-commits] [PATCH] D70241: [lldb] remove unsigned Stream::operator<< overloads

2019-11-26 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG957d9a0335b8: [lldb] remove unsigned 
Stream::operator overloads (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70241

Files:
  lldb/include/lldb/Utility/Stream.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Symbol/Type.cpp
  lldb/source/Symbol/Variable.cpp
  lldb/source/Utility/Stream.cpp
  lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
  lldb/unittests/Utility/StreamTest.cpp

Index: lldb/unittests/Utility/StreamTest.cpp
===
--- lldb/unittests/Utility/StreamTest.cpp
+++ lldb/unittests/Utility/StreamTest.cpp
@@ -304,15 +304,6 @@
   EXPECT_EQ("127 32767 2147483647 9223372036854775807", TakeValue());
 }
 
-TEST_F(StreamTest, ShiftOperatorUInts) {
-  s << std::numeric_limits::max() << " ";
-  s << std::numeric_limits::max() << " ";
-  s << std::numeric_limits::max() << " ";
-  s << std::numeric_limits::max();
-  EXPECT_EQ(33U, s.GetWrittenBytes());
-  EXPECT_EQ("ff   ", TakeValue());
-}
-
 TEST_F(StreamTest, ShiftOperatorPtr) {
   // This test is a bit tricky because pretty much everything related to
   // pointer printing seems to lead to UB or IB. So let's make the most basic
Index: lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
===
--- lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
+++ lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
@@ -10,7 +10,7 @@
 # RUN: lldb-test symbols %t | FileCheck %s
 
 # CHECK: Variable{0x7fff001e}, name = "X"
-# CHECK-SAME: type = {7fff0033} 0x{{[0-9a-f]*}} (char [56])
+# CHECK-SAME: type = {7fff0033} 0x{{[0-9A-F]*}} (char [56])
 
 
 # Generated from "char X[47];"
Index: lldb/source/Utility/Stream.cpp
===
--- lldb/source/Utility/Stream.cpp
+++ lldb/source/Utility/Stream.cpp
@@ -160,30 +160,6 @@
   return *this;
 }
 
-// Stream a uint8_t "uval" out to this stream.
-Stream ::operator<<(uint8_t uval) {
-  PutHex8(uval);
-  return *this;
-}
-
-// Stream a uint16_t "uval" out to this stream.
-Stream ::operator<<(uint16_t uval) {
-  PutHex16(uval, m_byte_order);
-  return *this;
-}
-
-// Stream a uint32_t "uval" out to this stream.
-Stream ::operator<<(uint32_t uval) {
-  PutHex32(uval, m_byte_order);
-  return *this;
-}
-
-// Stream a uint64_t "uval" out to this stream.
-Stream ::operator<<(uint64_t uval) {
-  PutHex64(uval, m_byte_order);
-  return *this;
-}
-
 // Stream a int8_t "sval" out to this stream.
 Stream ::operator<<(int8_t sval) {
   Printf("%i", static_cast(sval));
Index: lldb/source/Symbol/Variable.cpp
===
--- lldb/source/Symbol/Variable.cpp
+++ lldb/source/Symbol/Variable.cpp
@@ -112,7 +112,7 @@
   if (m_symfile_type_sp) {
 Type *type = m_symfile_type_sp->GetType();
 if (type) {
-  *s << ", type = {" << type->GetID() << "} " << (void *)type << " (";
+  s->Format(", type = {{{0:x-16}} {1} (", type->GetID(), type);
   type->DumpTypeName(s);
   s->PutChar(')');
 }
Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -255,7 +255,7 @@
 *s << ", compiler_type = " << m_compiler_type.GetOpaqueQualType() << ' ';
 GetForwardCompilerType().DumpTypeDescription(s);
   } else if (m_encoding_uid != LLDB_INVALID_UID) {
-*s << ", type_data = " << (uint64_t)m_encoding_uid;
+s->Format(", type_data = {0:x-16}", m_encoding_uid);
 switch (m_encoding_uid_type) {
 case eEncodingInvalid:
   break;
Index: lldb/source/Symbol/SymbolContext.cpp
===
--- lldb/source/Symbol/SymbolContext.cpp
+++ lldb/source/Symbol/SymbolContext.cpp
@@ -315,14 +315,14 @@
   s->Indent();
   *s << "CompileUnit  = " << comp_unit;
   if (comp_unit != nullptr)
-*s << " {0x" << comp_unit->GetID() << "} "
-   << *(static_cast(comp_unit));
+s->Format(" {{{0:x-16}} {1}", comp_unit->GetID(),
+  *static_cast(comp_unit));
   s->EOL();
   s->Indent();
   *s << "Function = " << function;
   if (function != nullptr) {
-*s << " {0x" << function->GetID() << "} " << function->GetType()->GetName()
-   << ", address-range = ";
+s->Format(" {{{0:x-16}} {1}, address-range = ", function->GetID(),
+  function->GetType()->GetName());
 function->GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress,
  Address::DumpStyleModuleWithFileAddress);
 s->EOL();
@@ -337,10 +337,7 @@
   s->Indent();
   *s << "Block= " << block;
   if (block != nullptr)
-

[Lldb-commits] [lldb] 957d9a0 - [lldb] remove unsigned Stream::operator<< overloads

2019-11-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-26T14:24:28+01:00
New Revision: 957d9a0335b8199b01caec56574e72154c3a1226

URL: 
https://github.com/llvm/llvm-project/commit/957d9a0335b8199b01caec56574e72154c3a1226
DIFF: 
https://github.com/llvm/llvm-project/commit/957d9a0335b8199b01caec56574e72154c3a1226.diff

LOG: [lldb] remove unsigned Stream::operator<< overloads

Summary:
I recently re-discovered that the unsinged stream operators of the
lldb_private::Stream class have a surprising behavior in that they print
the number in hex. This is all the more confusing because the "signed"
versions of those operators behave normally.

Now that, thanks to Raphael, each Stream class has a llvm::raw_ostream
wrapper, I think we should delete most of our formatting capabilities
and just delegate to that. This patch tests the water by just deleting
the operators with the most surprising behavior.

Most of the code using these operators was printing user_id_t values. It
wasn't fully consistent about prefixing them with "0x", but I've tried
to consistenly print it without that prefix, to make it more obviously
different from pointer values.

Reviewers: teemperor, JDevlieghere, jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70241

Added: 


Modified: 
lldb/include/lldb/Utility/Stream.h
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Symbol/SymbolContext.cpp
lldb/source/Symbol/Type.cpp
lldb/source/Symbol/Variable.cpp
lldb/source/Utility/Stream.cpp
lldb/test/Shell/SymbolFile/DWARF/array-sizes.s
lldb/unittests/Utility/StreamTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Stream.h 
b/lldb/include/lldb/Utility/Stream.h
index 414f92177303..88cdb88d77ad 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -213,45 +213,10 @@ class Stream {
   /// in one statement.
   Stream <<(char ch);
 
-  /// Output a uint8_t \a uval to the stream \a s.
-  ///
-  /// \param[in] uval
-  /// A uint8_t value.
-  ///
-  /// \return
-  /// A reference to this class so multiple things can be streamed
-  /// in one statement.
-  Stream <<(uint8_t uval);
-
-  /// Output a uint16_t \a uval to the stream \a s.
-  ///
-  /// \param[in] uval
-  /// A uint16_t value.
-  ///
-  /// \return
-  /// A reference to this class so multiple things can be streamed
-  /// in one statement.
-  Stream <<(uint16_t uval);
-
-  /// Output a uint32_t \a uval to the stream \a s.
-  ///
-  /// \param[in] uval
-  /// A uint32_t value.
-  ///
-  /// \return
-  /// A reference to this class so multiple things can be streamed
-  /// in one statement.
-  Stream <<(uint32_t uval);
-
-  /// Output a uint64_t \a uval to the stream \a s.
-  ///
-  /// \param[in] uval
-  /// A uint64_t value.
-  ///
-  /// \return
-  /// A reference to this class so multiple things can be streamed
-  /// in one statement.
-  Stream <<(uint64_t uval);
+  Stream <<(uint8_t uval) = delete;
+  Stream <<(uint16_t uval) = delete;
+  Stream <<(uint32_t uval) = delete;
+  Stream <<(uint64_t uval) = delete;
 
   /// Output a int8_t \a sval to the stream \a s.
   ///

diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index a063da0f4e40..8947500959cb 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -146,7 +146,7 @@ void DWARFExpression::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   // We have a new base address
   if (count > 0)
 s->PutCString(", ");
-  *s << "base_addr = " << end_addr_offset;
+  s->Format("base_addr = {0:x}", end_addr_offset);
 }
   }
 

diff  --git a/lldb/source/Symbol/SymbolContext.cpp 
b/lldb/source/Symbol/SymbolContext.cpp
index 7828ca613359..c5d8547b08c8 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -315,14 +315,14 @@ void SymbolContext::Dump(Stream *s, Target *target) const 
{
   s->Indent();
   *s << "CompileUnit  = " << comp_unit;
   if (comp_unit != nullptr)
-*s << " {0x" << comp_unit->GetID() << "} "
-   << *(static_cast(comp_unit));
+s->Format(" {{{0:x-16}} {1}", comp_unit->GetID(),
+  *static_cast(comp_unit));
   s->EOL();
   s->Indent();
   *s << "Function = " << function;
   if (function != nullptr) {
-*s << " {0x" << function->GetID() << "} " << function->GetType()->GetName()
-   << ", address-range = ";
+s->Format(" {{{0:x-16}} {1}, address-range = ", function->GetID(),
+  function->GetType()->GetName());
 function->GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress,
  Address::DumpStyleModuleWithFileAddress);
 s->EOL();
@@ -337,10 +337,7 @@ void SymbolContext::Dump(Stream 

[Lldb-commits] [lldb] 9b06897 - [lldb/symbolvendorelf] Copy more sections from separate debug files

2019-11-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-26T14:19:46+01:00
New Revision: 9b06897009dc32313354559c969d6cf0a564ec06

URL: 
https://github.com/llvm/llvm-project/commit/9b06897009dc32313354559c969d6cf0a564ec06
DIFF: 
https://github.com/llvm/llvm-project/commit/9b06897009dc32313354559c969d6cf0a564ec06.diff

LOG: [lldb/symbolvendorelf] Copy more sections from separate debug files

Include the fancier DWARF5 sections too.

Added: 


Modified: 
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
lldb/test/Shell/ObjectFile/ELF/build-id-case.yaml

Removed: 




diff  --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp 
b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index e61e5763fabb..d4d7a8937c12 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -119,14 +119,17 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP 
_sp,
   SectionList *objfile_section_list = dsym_objfile_sp->GetSectionList();
 
   static const SectionType g_sections[] = {
-  eSectionTypeDWARFDebugAbbrev,   eSectionTypeDWARFDebugAddr,
-  eSectionTypeDWARFDebugAranges,  eSectionTypeDWARFDebugCuIndex,
-  eSectionTypeDWARFDebugFrame,eSectionTypeDWARFDebugInfo,
-  eSectionTypeDWARFDebugLine, eSectionTypeDWARFDebugLoc,
-  eSectionTypeDWARFDebugMacInfo,  eSectionTypeDWARFDebugPubNames,
-  eSectionTypeDWARFDebugPubTypes, eSectionTypeDWARFDebugRanges,
-  eSectionTypeDWARFDebugStr,  eSectionTypeDWARFDebugStrOffsets,
-  eSectionTypeELFSymbolTable, eSectionTypeDWARFGNUDebugAltLink,
+  eSectionTypeDWARFDebugAbbrev, eSectionTypeDWARFDebugAddr,
+  eSectionTypeDWARFDebugAranges,eSectionTypeDWARFDebugCuIndex,
+  eSectionTypeDWARFDebugFrame,  eSectionTypeDWARFDebugInfo,
+  eSectionTypeDWARFDebugLine,   eSectionTypeDWARFDebugLineStr,
+  eSectionTypeDWARFDebugLoc,eSectionTypeDWARFDebugLocLists,
+  eSectionTypeDWARFDebugMacInfo,eSectionTypeDWARFDebugMacro,
+  eSectionTypeDWARFDebugNames,  eSectionTypeDWARFDebugPubNames,
+  eSectionTypeDWARFDebugPubTypes,   eSectionTypeDWARFDebugRanges,
+  eSectionTypeDWARFDebugRngLists,   eSectionTypeDWARFDebugStr,
+  eSectionTypeDWARFDebugStrOffsets, eSectionTypeDWARFDebugTypes,
+  eSectionTypeELFSymbolTable,   eSectionTypeDWARFGNUDebugAltLink,
   };
   for (SectionType section_type : g_sections) {
 if (SectionSP section_sp =

diff  --git a/lldb/test/Shell/ObjectFile/ELF/build-id-case.yaml 
b/lldb/test/Shell/ObjectFile/ELF/build-id-case.yaml
index f9786b3754f8..08366056947b 100644
--- a/lldb/test/Shell/ObjectFile/ELF/build-id-case.yaml
+++ b/lldb/test/Shell/ObjectFile/ELF/build-id-case.yaml
@@ -4,8 +4,25 @@
 # RUN: llvm-objcopy --strip-all 
%t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out
 # RUN: lldb-test object-file %t/stripped.out | FileCheck %s
 
+# CHECK: Name: .debug_abbrev
+# CHECK: Name: .debug_addr
+# CHECK: Name: .debug_aranges
 # CHECK: Name: .debug_frame
-# CHECK-NEXT: Type: dwarf-frame
+# CHECK: Name: .debug_info
+# CHECK: Name: .debug_line
+# CHECK: Name: .debug_line_str
+# CHECK: Name: .debug_loc
+# CHECK: Name: .debug_loclists
+# CHECK: Name: .debug_macinfo
+# CHECK: Name: .debug_macro
+# CHECK: Name: .debug_names
+# CHECK: Name: .debug_pubnames
+# CHECK: Name: .debug_pubtypes
+# CHECK: Name: .debug_ranges
+# CHECK: Name: .debug_rnglists
+# CHECK: Name: .debug_str
+# CHECK: Name: .debug_str_offsets
+# CHECK: Name: .debug_types
 
 --- !ELF
 FileHeader:
@@ -27,9 +44,62 @@ Sections:
 Address: 0x004003D0
 AddressAlign:0x0010
 Content: DEADBEEFBAADF00D
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
+  - Name:.debug_addr
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
+  - Name:.debug_aranges
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
   - Name:.debug_frame
 Type:SHT_PROGBITS
-AddressAlign:0x0008
+Content: DEADBEEFBAADF00D
+  - Name:.debug_info
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
+  - Name:.debug_line
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
+  - Name:.debug_line_str
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
+  - Name:.debug_loc
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
+  - Name:.debug_loclists
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
+  - Name:.debug_macinfo
+Type:SHT_PROGBITS
+Content: DEADBEEFBAADF00D
+  - Name:.debug_macro
+

[Lldb-commits] [lldb] cdfecb8 - [lldb][NFC] Remove no longer unused variable in DWARFASTParserClang::ParseTypeFromDWARF

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T14:17:06+01:00
New Revision: cdfecb82ee27fabf927102a356acd298ddca8703

URL: 
https://github.com/llvm/llvm-project/commit/cdfecb82ee27fabf927102a356acd298ddca8703
DIFF: 
https://github.com/llvm/llvm-project/commit/cdfecb82ee27fabf927102a356acd298ddca8703.diff

LOG: [lldb][NFC] Remove no longer unused variable in 
DWARFASTParserClang::ParseTypeFromDWARF

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 78c5af482191..89331f7aca6c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -463,7 +463,6 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
 
   const dw_tag_t tag = die.Tag();
 
-  CompilerType clang_type;
   TypeSP type_sp;
 
   switch (tag) {



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


[Lldb-commits] [lldb] 0181338 - [lldb][NFC] Simplify structure parsing code in DWARFASTParserClang::ParseTypeFromDWARF

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T14:01:12+01:00
New Revision: 0181338ddae26230d4067fdc00c2f7218f1d64d7

URL: 
https://github.com/llvm/llvm-project/commit/0181338ddae26230d4067fdc00c2f7218f1d64d7
DIFF: 
https://github.com/llvm/llvm-project/commit/0181338ddae26230d4067fdc00c2f7218f1d64d7.diff

LOG: [lldb][NFC] Simplify structure parsing code in 
DWARFASTParserClang::ParseTypeFromDWARF

This way it looks more like the code around it. The assert is also gone as it 
just
checks that the variables we declare directly above were not initialized by 
anyone.
That made more sense when this was one large function.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 8ead4ea4f519..78c5af482191 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -483,10 +483,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
   case DW_TAG_structure_type:
   case DW_TAG_union_type:
   case DW_TAG_class_type: {
-assert((!type_sp && !clang_type) &&
-   "Did not expect partially computed structure-like type");
-TypeSP struct_like_type_sp = ParseStructureLikeDIE(sc, die, attrs);
-return UpdateSymbolContextScopeForType(sc, die, struct_like_type_sp);
+type_sp = ParseStructureLikeDIE(sc, die, attrs);
+break;
   }
 
   case DW_TAG_enumeration_type: {



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


[Lldb-commits] [lldb] 4023bd0 - [lldb] Add boilerplate to recognize the .debug_rnglists.dwo section

2019-11-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-26T13:58:26+01:00
New Revision: 4023bd05fcb4f75c6a11d661f407f8e0896176e2

URL: 
https://github.com/llvm/llvm-project/commit/4023bd05fcb4f75c6a11d661f407f8e0896176e2
DIFF: 
https://github.com/llvm/llvm-project/commit/4023bd05fcb4f75c6a11d661f407f8e0896176e2.diff

LOG: [lldb] Add boilerplate to recognize the .debug_rnglists.dwo section

Added: 


Modified: 
lldb/include/lldb/lldb-enumerations.h
lldb/source/Core/Section.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
lldb/source/Symbol/ObjectFile.cpp
lldb/test/Shell/ObjectFile/ELF/section-types.yaml

Removed: 




diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 3c80bcffec20..0a92365544f9 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -690,6 +690,7 @@ enum SectionType {
   eSectionTypeDWARFDebugStrDwo,
   eSectionTypeDWARFDebugStrOffsetsDwo,
   eSectionTypeDWARFDebugTypesDwo,
+  eSectionTypeDWARFDebugRngListsDwo,
 };
 
 FLAGS_ENUM(EmulateInstructionOptions){

diff  --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 7615dc1d65c7..e8fcca4603df 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -94,6 +94,8 @@ const char *Section::GetTypeAsCString() const {
 return "dwarf-ranges";
   case eSectionTypeDWARFDebugRngLists:
 return "dwarf-rnglists";
+  case eSectionTypeDWARFDebugRngListsDwo:
+return "dwarf-rnglists-dwo";
   case eSectionTypeDWARFDebugStr:
 return "dwarf-str";
   case eSectionTypeDWARFDebugStrDwo:

diff  --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 3f8502548fc2..8eadaf1323d5 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1581,6 +1581,7 @@ static SectionType GetSectionTypeFromName(llvm::StringRef 
Name) {
 .Case("pubtypes", eSectionTypeDWARFDebugPubTypes)
 .Case("ranges", eSectionTypeDWARFDebugRanges)
 .Case("rnglists", eSectionTypeDWARFDebugRngLists)
+.Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo)
 .Case("str", eSectionTypeDWARFDebugStr)
 .Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
 .Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index aff1d1e87bb6..57c43de0c945 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1140,6 +1140,7 @@ AddressClass 
ObjectFileMachO::GetAddressClass(lldb::addr_t file_addr) {
 case eSectionTypeDWARFDebugPubTypes:
 case eSectionTypeDWARFDebugRanges:
 case eSectionTypeDWARFDebugRngLists:
+case eSectionTypeDWARFDebugRngListsDwo:
 case eSectionTypeDWARFDebugStr:
 case eSectionTypeDWARFDebugStrDwo:
 case eSectionTypeDWARFDebugStrOffsets:

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
index eb307ce1cce1..db8d7b3747ec 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -81,7 +81,8 @@ const DWARFDataExtractor ::getOrLoadRangesData() 
{
 }
 
 const DWARFDataExtractor ::getOrLoadRngListsData() {
-  return LoadOrGetSection(eSectionTypeDWARFDebugRngLists, llvm::None,
+  return LoadOrGetSection(eSectionTypeDWARFDebugRngLists,
+  eSectionTypeDWARFDebugRngListsDwo,
   m_data_debug_rnglists);
 }
 

diff  --git a/lldb/source/Symbol/ObjectFile.cpp 
b/lldb/source/Symbol/ObjectFile.cpp
index 38bc7722d0d0..4f6d74bbc757 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -360,6 +360,7 @@ AddressClass ObjectFile::GetAddressClass(addr_t file_addr) {
   case eSectionTypeDWARFDebugPubTypes:
   case eSectionTypeDWARFDebugRanges:
   case eSectionTypeDWARFDebugRngLists:
+  case eSectionTypeDWARFDebugRngListsDwo:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrDwo:
   case eSectionTypeDWARFDebugStrOffsets:

diff  --git a/lldb/test/Shell/ObjectFile/ELF/section-types.yaml 
b/lldb/test/Shell/ObjectFile/ELF/section-types.yaml
index 9f6b4c0533b9..caac76a789ce 100644
--- a/lldb/test/Shell/ObjectFile/ELF/section-types.yaml
+++ b/lldb/test/Shell/ObjectFile/ELF/section-types.yaml
@@ -13,6 +13,12 @@
 # CHECK-LABEL: Name: .debug_types.dwo
 # CHECK-NEXT: Type: dwarf-types-dwo
 
+# CHECK-LABEL: Name: .debug_rnglists

[Lldb-commits] [lldb] 30fc94b - [lldb][NFC] Extract type modifier parsing from DWARFASTParserClang::ParseTypeFromDWARF

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T13:53:06+01:00
New Revision: 30fc94be237f26d3127d8bbc872d9e3b82f03590

URL: 
https://github.com/llvm/llvm-project/commit/30fc94be237f26d3127d8bbc872d9e3b82f03590
DIFF: 
https://github.com/llvm/llvm-project/commit/30fc94be237f26d3127d8bbc872d9e3b82f03590.diff

LOG: [lldb][NFC] Extract type modifier parsing from 
DWARFASTParserClang::ParseTypeFromDWARF

Part of the work to split up this monolithic parsing function.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 17e0924e3e58..8ead4ea4f519 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -463,13 +463,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
 
   const dw_tag_t tag = die.Tag();
 
-  Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
-
-  Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
   CompilerType clang_type;
-
   TypeSP type_sp;
-  LanguageType cu_language = die.GetLanguage();
+
   switch (tag) {
   case DW_TAG_typedef:
   case DW_TAG_base_type:
@@ -480,209 +476,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
   case DW_TAG_restrict_type:
   case DW_TAG_volatile_type:
   case DW_TAG_unspecified_type: {
-if (tag == DW_TAG_typedef && attrs.type.IsValid()) {
-  // Try to parse a typedef from the (DWARF embedded in the) Clang
-  // module file first as modules can contain typedef'ed
-  // structures that have no names like:
-  //
-  //  typedef struct { int a; } Foo;
-  //
-  // In this case we will have a structure with no name and a
-  // typedef named "Foo" that points to this unnamed
-  // structure. The name in the typedef is the only identifier for
-  // the struct, so always try to get typedefs from Clang modules
-  // if possible.
-  //
-  // The type_sp returned will be empty if the typedef doesn't
-  // exist in a module file, so it is cheap to call this function
-  // just to check.
-  //
-  // If we don't do this we end up creating a TypeSP that says
-  // this is a typedef to type 0x123 (the DW_AT_type value would
-  // be 0x123 in the DW_TAG_typedef), and this is the unnamed
-  // structure type. We will have a hard time tracking down an
-  // unnammed structure type in the module debug info, so we make
-  // sure we don't get into this situation by always resolving
-  // typedefs from the module.
-  const DWARFDIE encoding_die = attrs.type.Reference();
-
-  // First make sure that the die that this is typedef'ed to _is_
-  // just a declaration (DW_AT_declaration == 1), not a full
-  // definition since template types can't be represented in
-  // modules since only concrete instances of templates are ever
-  // emitted and modules won't contain those
-  if (encoding_die &&
-  encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) 
{
-type_sp = ParseTypeFromClangModule(sc, die, log);
-if (type_sp)
-  return type_sp;
-  }
-}
-
-DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n",
- die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr,
- encoding_uid.Reference());
-
-switch (tag) {
-default:
-  break;
-
-case DW_TAG_unspecified_type:
-  if (attrs.name == "nullptr_t" || attrs.name == "decltype(nullptr)") {
-resolve_state = Type::ResolveState::Full;
-clang_type = m_ast.GetBasicType(eBasicTypeNullPtr);
-break;
-  }
-  // Fall through to base type below in case we can handle the type
-  // there...
-  LLVM_FALLTHROUGH;
-
-case DW_TAG_base_type:
-  resolve_state = Type::ResolveState::Full;
-  clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
-  attrs.name.GetCString(), attrs.encoding,
-  attrs.byte_size.getValueOr(0) * 8);
-  break;
-
-case DW_TAG_pointer_type:
-  encoding_data_type = Type::eEncodingIsPointerUID;
-  break;
-case DW_TAG_reference_type:
-  encoding_data_type = Type::eEncodingIsLValueReferenceUID;
-  break;
-case DW_TAG_rvalue_reference_type:
-  encoding_data_type = Type::eEncodingIsRValueReferenceUID;
-  break;
-case DW_TAG_typedef:
-  encoding_data_type = Type::eEncodingIsTypedefUID;
-  break;
-case DW_TAG_const_type:
-  encoding_data_type = Type::eEncodingIsConstUID;
-  break;
-case DW_TAG_restrict_type:
-  encoding_data_type = Type::eEncodingIsRestrictUID;
-  break;
- 

[Lldb-commits] [PATCH] D70532: [lldb] Improve/fix base address selection in location lists

2019-11-26 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 231041.
labath added a comment.

Rename to {cu,func}_{file,load}_addr as appropriate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70532

Files:
  lldb/include/lldb/Expression/DWARFExpression.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/Inputs/debug_loc-aslr.yaml
  lldb/test/Shell/SymbolFile/DWARF/debug_loc-aslr.s

Index: lldb/test/Shell/SymbolFile/DWARF/debug_loc-aslr.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/debug_loc-aslr.s
@@ -0,0 +1,129 @@
+# This test checks the handling of location lists in the case when the module is
+# not loaded at the address at which it was linked (as happens with ASLR for
+# instance).
+
+# REQUIRES: x86
+
+# RUN: yaml2obj %S/Inputs/debug_loc-aslr.yaml >%t.dmp
+# RUN: llvm-mc --triple=x86_64-pc-linux --filetype=obj %s >%t.o
+# RUN: %lldb -c %t.dmp -o "image add %t.o" \
+# RUN:   -o "image load --file %t.o --slide 0x47" \
+# RUN:   -o "thread info" -o "frame variable" -o exit | FileCheck %s
+
+# CHECK: thread #1: tid = 16001, 0x00470001 {{.*}}`_start
+# CHECK: (int) x = 47
+# CHECK: (int) y = 74
+
+.text
+.globl _start
+_start:
+nop
+retq
+.Lstart_end:
+
+.section.debug_loc,"",@progbits
+# This location list implicitly uses the base address of the compile unit.
+.Ldebug_loc0:
+.quad   _start-_start
+.quad   .Lstart_end-_start
+.short  3   # Loc expr size
+.byte   8   # DW_OP_const1u
+.byte   47
+.byte   159 # DW_OP_stack_value
+.quad   0
+.quad   0
+
+# This is an equivalent location list to the first one, but here the base
+# address is set explicitly.
+.Ldebug_loc1:
+.quad   -1
+.quad   _start
+.quad   _start-_start
+.quad   .Lstart_end-_start
+.short  3   # Loc expr size
+.byte   8   # DW_OP_const1u
+.byte   74
+.byte   159 # DW_OP_stack_value
+.quad   0
+.quad   0
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   19  # DW_AT_language
+.byte   5   # DW_FORM_data2
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46  # DW_TAG_subprogram
+.byte   1   # DW_CHILDREN_yes
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   4   # Abbreviation Code
+.byte   52  # DW_TAG_variable
+.byte   0   # DW_CHILDREN_no
+.byte   2   # DW_AT_location
+.byte   23  # DW_FORM_sec_offset
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   6   # Abbreviation Code
+.byte   36  # DW_TAG_base_type
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   62  # DW_AT_encoding
+.byte   11  # DW_FORM_data1
+.byte   11  # DW_AT_byte_size
+.byte   11  # DW_FORM_data1
+.byte   0 

[Lldb-commits] [PATCH] D70532: [lldb] Improve/fix base address selection in location lists

2019-11-26 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 4 inline comments as done.
labath added inline comments.



Comment at: lldb/include/lldb/Expression/DWARFExpression.h:88-89
   ///
-  /// \param[in] process
-  /// The process to use when resolving the load address
+  /// \param[in] load_function_start
+  /// The actual address of the function containing this location list.
   ///

clayborg wrote:
> Is this a "file address"? Maybe clarify here in the comment, or rename 
> variable appropriately?
No, this is an actual load address. The file address is only used in 
`SetLocationListSlide`/`SetLocationListAddresses` which then stores it in the 
object itself. All other functions take a load address, since that is 
intentionally not stored anywhere.

(Technically this doesn't have to be a load address -- it can be whatever the 
type of address you want. If you pass in a file address here (like some dumping 
code does), then it will still work, just the addresses coming out of the 
location list will be file addresses...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70532



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


[Lldb-commits] [lldb] 8f2b57d - [lldb][NFC] Extract enum parsing from DWARFASTParserClang::ParseTypeFromDWARF

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T12:30:06+01:00
New Revision: 8f2b57d257e87b0244f9883cd8075898005ba757

URL: 
https://github.com/llvm/llvm-project/commit/8f2b57d257e87b0244f9883cd8075898005ba757
DIFF: 
https://github.com/llvm/llvm-project/commit/8f2b57d257e87b0244f9883cd8075898005ba757.diff

LOG: [lldb][NFC] Extract enum parsing from 
DWARFASTParserClang::ParseTypeFromDWARF

Part of the work to split up this monolithic parsing function.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index aca87b3a5b1c..17e0924e3e58 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -694,106 +694,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
   }
 
   case DW_TAG_enumeration_type: {
-if (attrs.is_forward_declaration) {
-  type_sp = ParseTypeFromClangModule(sc, die, log);
-  if (type_sp)
-return type_sp;
-
-  DWARFDeclContext die_decl_ctx;
-  die.GetDWARFDeclContext(die_decl_ctx);
-
-  type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
-
-  if (!type_sp) {
-SymbolFileDWARFDebugMap *debug_map_symfile =
-dwarf->GetDebugMapSymfile();
-if (debug_map_symfile) {
-  // We weren't able to find a full declaration in this DWARF,
-  // see if we have a declaration anywhere else...
-  type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
-}
-  }
-
-  if (type_sp) {
-if (log) {
-  dwarf->GetObjectFile()->GetModule()->LogMessage(
-  log,
-  "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
-  "forward declaration, complete type is 0x%8.8" PRIx64,
-  static_cast(this), die.GetOffset(),
-  DW_TAG_value_to_name(tag), attrs.name.GetCString(),
-  type_sp->GetID());
-}
-
-// We found a real definition for this type elsewhere so lets use
-// it and cache the fact that we found a complete type for this
-// die
-dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-clang::DeclContext *defn_decl_ctx =
-GetCachedClangDeclContextForDIE(dwarf->GetDIE(type_sp->GetID()));
-if (defn_decl_ctx)
-  LinkDeclContextToDIE(defn_decl_ctx, die);
-return type_sp;
-  }
-}
-DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
- DW_TAG_value_to_name(tag), type_name_cstr);
-
-CompilerType enumerator_clang_type;
-clang_type.SetCompilerType(
-_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
-if (!clang_type) {
-  if (attrs.type.IsValid()) {
-Type *enumerator_type =
-dwarf->ResolveTypeUID(attrs.type.Reference(), true);
-if (enumerator_type)
-  enumerator_clang_type = enumerator_type->GetFullCompilerType();
-  }
-
-  if (!enumerator_clang_type) {
-if (attrs.byte_size) {
-  enumerator_clang_type =
-  m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
-  NULL, DW_ATE_signed, *attrs.byte_size * 8);
-} else {
-  enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
-}
-  }
-
-  clang_type = m_ast.CreateEnumerationType(
-  attrs.name.GetCString(),
-  GetClangDeclContextContainingDIE(die, nullptr), attrs.decl,
-  enumerator_clang_type, attrs.is_scoped_enum);
-} else {
-  enumerator_clang_type =
-  m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType());
-}
-
-LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type),
- die);
-
-type_sp = std::make_shared(
-die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
-dwarf->GetUID(attrs.type.Reference()), Type::eEncodingIsUID,
-, clang_type, Type::ResolveState::Forward);
-
-if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
-  if (die.HasChildren()) {
-bool is_signed = false;
-enumerator_clang_type.IsIntegerType(is_signed);
-ParseChildEnumerators(clang_type, is_signed,
-  type_sp->GetByteSize().getValueOr(0), die);
-  }
-  ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
-} else {
-  dwarf->GetObjectFile()->GetModule()->ReportError(
-  "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
-  "definition.\nPlease file a bug and attach the file at the "
-  "start of this error 

[Lldb-commits] [lldb] 9493965 - [lldb][NFCI] Extract subroutine parsing from DWARFASTParserClang::ParseTypeFromDWARF

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T12:14:40+01:00
New Revision: 94939650b632cd44e518a9adeb16ab829375

URL: 
https://github.com/llvm/llvm-project/commit/94939650b632cd44e518a9adeb16ab829375
DIFF: 
https://github.com/llvm/llvm-project/commit/94939650b632cd44e518a9adeb16ab829375.diff

LOG: [lldb][NFCI] Extract subroutine parsing from 
DWARFASTParserClang::ParseTypeFromDWARF

Part of the work to split up this monolithic parsing function.

Should be NFC but due to the kafkaesque control flow in this case statement 
this might
have some unintended side effects.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index ea0f02778941..aca87b3a5b1c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -798,428 +798,436 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
   case DW_TAG_inlined_subroutine:
   case DW_TAG_subprogram:
   case DW_TAG_subroutine_type: {
-bool is_variadic = false;
-bool is_static = false;
-bool has_template_params = false;
+type_sp = ParseSubroutine(die, attrs);
+break;
+  }
+  case DW_TAG_array_type: {
+type_sp = ParseArrayType(die, attrs);
+break;
+  }
+  case DW_TAG_ptr_to_member_type: {
+type_sp = ParsePointerToMemberType(die, attrs);
+break;
+  }
+  default:
+dwarf->GetObjectFile()->GetModule()->ReportError(
+"{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and "
+"attach the file at the start of this error message",
+die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+break;
+  }
 
-unsigned type_quals = 0;
+  // TODO: We should consider making the switch above exhaustive to simplify
+  // control flow in ParseTypeFromDWARF. Then, we could simply replace this
+  // return statement with a call to llvm_unreachable.
+  return UpdateSymbolContextScopeForType(sc, die, type_sp);
+}
 
-std::string object_pointer_name;
-if (attrs.object_pointer) {
-  const char *object_pointer_name_cstr = attrs.object_pointer.GetName();
-  if (object_pointer_name_cstr)
-object_pointer_name = object_pointer_name_cstr;
-}
+TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE ,
+   ParsedDWARFTypeAttributes ) {
+  Log *log(LogChannelDWARF::GetLogIfAny(DWARF_LOG_TYPE_COMPLETION |
+DWARF_LOG_LOOKUPS));
 
-DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
- DW_TAG_value_to_name(tag), type_name_cstr);
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  const dw_tag_t tag = die.Tag();
 
-CompilerType return_clang_type;
-Type *func_type = NULL;
-
-if (attrs.type.IsValid())
-  func_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
-
-if (func_type)
-  return_clang_type = func_type->GetForwardCompilerType();
-else
-  return_clang_type = m_ast.GetBasicType(eBasicTypeVoid);
-
-std::vector function_param_types;
-std::vector function_param_decls;
-
-// Parse the function children for the parameters
-
-DWARFDIE decl_ctx_die;
-clang::DeclContext *containing_decl_ctx =
-GetClangDeclContextContainingDIE(die, _ctx_die);
-const clang::Decl::Kind containing_decl_kind =
-containing_decl_ctx->getDeclKind();
-
-bool is_cxx_method = DeclKindIsCXXClass(containing_decl_kind);
-// Start off static. This will be set to false in
-// ParseChildParameters(...) if we find a "this" parameters as the
-// first parameter
-if (is_cxx_method) {
-  is_static = true;
-}
-
-if (die.HasChildren()) {
-  bool skip_artificial = true;
-  ParseChildParameters(containing_decl_ctx, die, skip_artificial, 
is_static,
-   is_variadic, has_template_params,
-   function_param_types, function_param_decls,
-   type_quals);
-}
-
-bool ignore_containing_context = false;
-// Check for templatized class member functions. If we had any
-// DW_TAG_template_type_parameter or DW_TAG_template_value_parameter
-// the DW_TAG_subprogram DIE, then we can't let this become a method in
-// a class. Why? Because templatized functions are only emitted if one
-// of the templatized methods is used in the current compile unit and
-// we will end up with classes that may or may not include these member
-// functions and this means one class won't match another class
-// definition and it affects our ability to use a class in the clang
-// expression parser. So for the greater good, 

[Lldb-commits] [lldb] e8013ef - [lldb][NFC] Extract array type parsing from DWARFASTParserClang::ParseTypeFromDWARF

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T11:46:25+01:00
New Revision: e8013ef53ac0cd82f9c921abd0b2fa1aa8b2f20c

URL: 
https://github.com/llvm/llvm-project/commit/e8013ef53ac0cd82f9c921abd0b2fa1aa8b2f20c
DIFF: 
https://github.com/llvm/llvm-project/commit/e8013ef53ac0cd82f9c921abd0b2fa1aa8b2f20c.diff

LOG: [lldb][NFC] Extract array type parsing from 
DWARFASTParserClang::ParseTypeFromDWARF

Part of the work to split up this monolithic parsing function.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 6d02f1b5ee83..ea0f02778941 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1201,90 +1201,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
   } break;
 
   case DW_TAG_array_type: {
-DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
- DW_TAG_value_to_name(tag), type_name_cstr);
-
-DWARFDIE type_die = attrs.type.Reference();
-Type *element_type = dwarf->ResolveTypeUID(type_die, true);
-
-if (element_type) {
-  auto array_info = ParseChildArrayInfo(die);
-  if (array_info) {
-attrs.byte_stride = array_info->byte_stride;
-attrs.bit_stride = array_info->bit_stride;
-  }
-  if (attrs.byte_stride == 0 && attrs.bit_stride == 0)
-attrs.byte_stride = element_type->GetByteSize().getValueOr(0);
-  CompilerType array_element_type = element_type->GetForwardCompilerType();
-
-  if (ClangASTContext::IsCXXClassType(array_element_type) &&
-  !array_element_type.GetCompleteType()) {
-ModuleSP module_sp = die.GetModule();
-if (module_sp) {
-  if (die.GetCU()->GetProducer() == eProducerClang)
-module_sp->ReportError(
-"DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
-"class/union/struct element type DIE 0x%8.8x that is a "
-"forward declaration, not a complete definition.\nTry "
-"compiling the source file with -fstandalone-debug or "
-"disable -gmodules",
-die.GetOffset(), type_die.GetOffset());
-  else
-module_sp->ReportError(
-"DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
-"class/union/struct element type DIE 0x%8.8x that is a "
-"forward declaration, not a complete definition.\nPlease "
-"file a bug against the compiler and include the "
-"preprocessed output for %s",
-die.GetOffset(), type_die.GetOffset(),
-GetUnitName(die).c_str());
-}
-
-// We have no choice other than to pretend that the element class
-// type is complete. If we don't do this, clang will crash when
-// trying to layout the class. Since we provide layout
-// assistance, all ivars in this class and other classes will be
-// fine, this is the best we can do short of crashing.
-if (ClangASTContext::StartTagDeclarationDefinition(
-array_element_type)) {
-  
ClangASTContext::CompleteTagDeclarationDefinition(array_element_type);
-} else {
-  module_sp->ReportError("DWARF DIE at 0x%8.8x was not able to "
- "start its definition.\nPlease file a "
- "bug and attach the file at the start "
- "of this error message",
- type_die.GetOffset());
-}
-  }
-
-  uint64_t array_element_bit_stride =
-  attrs.byte_stride * 8 + attrs.bit_stride;
-  if (array_info && array_info->element_orders.size() > 0) {
-uint64_t num_elements = 0;
-auto end = array_info->element_orders.rend();
-for (auto pos = array_info->element_orders.rbegin(); pos != end;
- ++pos) {
-  num_elements = *pos;
-  clang_type = m_ast.CreateArrayType(array_element_type, num_elements,
- attrs.is_vector);
-  array_element_type = clang_type;
-  array_element_bit_stride =
-  num_elements ? array_element_bit_stride * num_elements
-   : array_element_bit_stride;
-}
-  } else {
-clang_type = m_ast.CreateArrayType(array_element_type, 0, 
attrs.is_vector);
-  }
-  ConstString empty_name;
-  type_sp = std::make_shared(
-  die.GetID(), dwarf, empty_name, array_element_bit_stride / 8, 
nullptr,
-  dwarf->GetUID(type_die), Type::eEncodingIsUID, ,
-  

[Lldb-commits] [lldb] 7047a3a - [lldb][NFC] Extract pointer to member type parsing from DWARFASTParserClang::ParseTypeFromDWARF

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T11:07:59+01:00
New Revision: 7047a3a729c6b2779b512269ff3eba88d8976d63

URL: 
https://github.com/llvm/llvm-project/commit/7047a3a729c6b2779b512269ff3eba88d8976d63
DIFF: 
https://github.com/llvm/llvm-project/commit/7047a3a729c6b2779b512269ff3eba88d8976d63.diff

LOG: [lldb][NFC] Extract pointer to member type parsing from 
DWARFASTParserClang::ParseTypeFromDWARF

Part of the work to split up this monolithic parsing function.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 3a712fc7e76b..6d02f1b5ee83 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1286,24 +1286,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
   } break;
 
   case DW_TAG_ptr_to_member_type: {
-Type *pointee_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
-Type *class_type =
-dwarf->ResolveTypeUID(attrs.containing_type.Reference(), true);
-
-CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType();
-CompilerType class_clang_type = class_type->GetLayoutCompilerType();
-
-clang_type = ClangASTContext::CreateMemberPointerType(class_clang_type,
-  pointee_clang_type);
-
-if (llvm::Optional clang_type_size =
-clang_type.GetByteSize(nullptr)) {
-  type_sp = std::make_shared(
-  die.GetID(), dwarf, attrs.name, *clang_type_size, nullptr,
-  LLDB_INVALID_UID, Type::eEncodingIsUID, nullptr, clang_type,
-  Type::ResolveState::Forward);
-}
-
+type_sp = ParsePointerToMemberType(die, attrs);
 break;
   }
   default:
@@ -1320,6 +1303,29 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const 
SymbolContext ,
   return UpdateSymbolContextScopeForType(sc, die, type_sp);
 }
 
+TypeSP DWARFASTParserClang::ParsePointerToMemberType(
+const DWARFDIE , const ParsedDWARFTypeAttributes ) {
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  Type *pointee_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
+  Type *class_type =
+  dwarf->ResolveTypeUID(attrs.containing_type.Reference(), true);
+
+  CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType();
+  CompilerType class_clang_type = class_type->GetLayoutCompilerType();
+
+  CompilerType clang_type = ClangASTContext::CreateMemberPointerType(
+  class_clang_type, pointee_clang_type);
+
+  if (llvm::Optional clang_type_size =
+  clang_type.GetByteSize(nullptr)) {
+return std::make_shared(die.GetID(), dwarf, attrs.name,
+  *clang_type_size, nullptr, LLDB_INVALID_UID,
+  Type::eEncodingIsUID, nullptr, clang_type,
+  Type::ResolveState::Forward);
+  }
+  return nullptr;
+}
+
 TypeSP DWARFASTParserClang::UpdateSymbolContextScopeForType(
 const SymbolContext , const DWARFDIE , TypeSP type_sp) {
   if (!type_sp)

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 982a089981d4..b92c39739454 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -168,6 +168,10 @@ class DWARFASTParserClang : public DWARFASTParser {
   // Return true if this type is a declaration to a type in an external
   // module.
   lldb::ModuleSP GetModuleForType(const DWARFDIE );
+
+private:
+  lldb::TypeSP ParsePointerToMemberType(const DWARFDIE ,
+const ParsedDWARFTypeAttributes 
);
 };
 
 /// Parsed form of all attributes that are relevant for type reconstruction.



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


[Lldb-commits] [lldb] cfd9d39 - [lldb][NFC] NULL -> nullptr in DWARFASTParserClang::UpdateSymbolContextScopeForType

2019-11-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-26T10:35:30+01:00
New Revision: cfd9d395674030d549de286d26c0f52020de26e6

URL: 
https://github.com/llvm/llvm-project/commit/cfd9d395674030d549de286d26c0f52020de26e6
DIFF: 
https://github.com/llvm/llvm-project/commit/cfd9d395674030d549de286d26c0f52020de26e6.diff

LOG: [lldb][NFC] NULL -> nullptr in 
DWARFASTParserClang::UpdateSymbolContextScopeForType

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 01655f04c422..3a712fc7e76b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1330,20 +1330,20 @@ TypeSP 
DWARFASTParserClang::UpdateSymbolContextScopeForType(
   DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
   dw_tag_t sc_parent_tag = sc_parent_die.Tag();
 
-  SymbolContextScope *symbol_context_scope = NULL;
+  SymbolContextScope *symbol_context_scope = nullptr;
   if (sc_parent_tag == DW_TAG_compile_unit ||
   sc_parent_tag == DW_TAG_partial_unit) {
 symbol_context_scope = sc.comp_unit;
-  } else if (sc.function != NULL && sc_parent_die) {
+  } else if (sc.function != nullptr && sc_parent_die) {
 symbol_context_scope =
 sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
-if (symbol_context_scope == NULL)
+if (symbol_context_scope == nullptr)
   symbol_context_scope = sc.function;
   } else {
 symbol_context_scope = sc.module_sp.get();
   }
 
-  if (symbol_context_scope != NULL)
+  if (symbol_context_scope != nullptr)
 type_sp->SetSymbolContextScope(symbol_context_scope);
 
   // We are ready to put this type into the uniqued list up at the module



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


[Lldb-commits] [PATCH] D70644: [DebugInfo] Support for DW_OP_implicit_pointer (llvm.dbg_derefval)

2019-11-26 Thread Alok Kumar Sharma via Phabricator via lldb-commits
alok created this revision.
alok added reviewers: aprantl, probinson, dblaikie, jmorse, jini.susan.george, 
SouraVX, awpandey.
alok added projects: LLVM, debug-info.
Herald added a reviewer: bollu.
Herald added subscribers: llvm-commits, lldb-commits, jdoerfert, asbirlea, 
george.burgess.iv, hiraditya.
Herald added a project: LLDB.
alok added a child revision: D6: [DebugInfo] Support for 
DW_OP_implicit_pointer (IR Verifier and Bitcode).
alok added a parent revision: D70643: [DebugInfo] Support for 
DW_OP_implicit_pointer (DW_OP_LLVM_implicit_pointer).

This patch (3/N) stems from D69787 as suggested by
This is suggested by @jmorse.
  
New intrinsic llvm.dbg.derefval is introduced.
  
  Summary:
Since dbg.value currently represents (VAR=VALUE), the new intrinsic 
dbg.derefval will represent de-referenced value (*VAR = VAL)
  - Below represents ptr=null
call void @llvm.dbg.value(metadata i32* null, metadata !21, metadata 
!DIExpression())
  - And below represents *ptr=var
call void @llvm.dbg.derefval(metadata !16, metadata !21, metadata 
!DIExpression(DW_OP_LLVM_implicit_pointer, DW_OP_LLVM_arg0, 0))
  - And below represents *ptr=arr[1]
call void @llvm.dbg.derefval(metadata !16, metadata !21, metadata 
!DIExpression(DW_OP_LLVM_implicit_pointer, DW_OP_LLVM_arg0, 4))
  - We should be able to represent the case when a variable points to 
temporary (initialized by constant) and temporary is optimized out.
tmp=[CONST]; ptr=
call void @llvm.dbg.derefval(metadata [CONST], metadata !21, metadata 
!DIExpression(DW_OP_LLVM_arg0))


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70644

Files:
  lldb/source/Expression/IRInterpreter.cpp
  llvm/docs/SourceLevelDebugging.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
  llvm/include/llvm/CodeGen/MachineInstrBuilder.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/InstVisitor.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/MemorySSA.cpp
  llvm/lib/Analysis/ObjCARCInstKind.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  polly/lib/Support/ScopHelper.cpp

Index: polly/lib/Support/ScopHelper.cpp
===
--- polly/lib/Support/ScopHelper.cpp
+++ polly/lib/Support/ScopHelper.cpp
@@ -624,6 +624,7 @@
 case llvm::Intrinsic::assume:
 // Some debug info intrinsics are supported/ignored.
 case llvm::Intrinsic::dbg_value:
+case llvm::Intrinsic::dbg_derefval:
 case llvm::Intrinsic::dbg_declare:
   return true;
 default:
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4010,6 +4010,7 @@
 switch (IntrinsicID) {
 case Intrinsic::dbg_declare:
 case Intrinsic::dbg_value:
+case Intrinsic::dbg_derefval:
 case Intrinsic::dbg_label:
 case Intrinsic::lifetime_end:
   break;
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -385,6 +385,11 @@
   return false;
 return true;
   }
+  if (DbgDerefValueInst *DVI = dyn_cast(I)) {
+if (DVI->getDerefVariable())
+  return false;
+return true;
+  }
   if (DbgLabelInst *DLI = dyn_cast(I)) {
 if (DLI->getLabel())
   return false;
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4314,6 +4314,9 @@
   case Intrinsic::dbg_value: // llvm.dbg.value
 visitDbgIntrinsic("value", cast(Call));
 break;
+  case Intrinsic::dbg_derefval: // llvm.dbg.derefval
+visitDbgIntrinsic("derefval", cast(Call));
+break;
   case Intrinsic::dbg_label: // llvm.dbg.label
 visitDbgLabelIntrinsic("label", cast(Call));
 break;
@@ -4836,8 +4839,9 @@
 void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic ) {
   auto *MD = cast(DII.getArgOperand(0))->getMetadata();
   AssertDI(isa(MD) ||
- (isa(MD) && !cast(MD)->getNumOperands()),
- "invalid llvm.dbg." + Kind + " intrinsic address/value", , MD);
+   (isa(MD) && !cast(MD)->getNumOperands()) ||
+