[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

This looks fine to me. I don't know much about frameworks, but I think it makes 
things cleaner by grouping all the framework-related code together.

It's not introduced in this patch, but the part that struck me as a hack has 
the force-overwriting of LLVM_CODESIGNING_IDENTITY. Is there any way that could 
be removed?


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

https://reviews.llvm.org/D55328



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


[Lldb-commits] [PATCH] D55383: Implement basic DidAttach for DynamicLoaderWindowsDYLD for use with ds2

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I am afraid I know know much about windows, or ds2. The thing I noticed is that 
this only seems to set the address of the main executable. Don't you also need 
to set the load address of loaded shared libraries (if any)?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55383



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


[Lldb-commits] [PATCH] D55318: [Expressions] Add support of expressions evaluation in some object's context

2018-12-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov marked 6 inline comments as done.
aleksandr.urakov added inline comments.



Comment at: include/lldb/Expression/UserExpression.h:296
+   lldb::ModuleSP *jit_module_sp_ptr = nullptr,
+   const lldb::ValueObjectSP &ctx_obj = lldb::ValueObjectSP());
 

zturner wrote:
> A reference to a `shared_ptr` seems odd.  Why don't we just say `const 
> ValueObject* ctx_obj = nullptr`?
Yes, I agree. I wasn't sure about the lifetime of the context object, that's 
why I've used a shared pointer here. But now it is obvious that there should be 
no problems with the lifetime - an expression evaluation with a context object 
is called from `SBValue` only, so it is guaranteed that the required value 
exists during the evaluation.

The only thing is that the pointer points to a non-const value object - 
non-const methods are used.


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

https://reviews.llvm.org/D55318



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


[Lldb-commits] [PATCH] D55318: [Expressions] Add support of expressions evaluation in some object's context

2018-12-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 177139.
aleksandr.urakov marked an inline comment as done.
aleksandr.urakov added a comment.

Thanks for the comments, I've updated the patch.


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

https://reviews.llvm.org/D55318

Files:
  include/lldb/API/SBValue.h
  include/lldb/Expression/ExpressionSourceCode.h
  include/lldb/Expression/UserExpression.h
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Target/Target.h
  packages/Python/lldbsuite/test/expression_command/context-object/Makefile
  
packages/Python/lldbsuite/test/expression_command/context-object/TestContextObject.py
  packages/Python/lldbsuite/test/expression_command/context-object/main.cpp
  scripts/interface/SBValue.i
  source/API/SBValue.cpp
  source/Breakpoint/BreakpointLocation.cpp
  source/Breakpoint/Watchpoint.cpp
  source/Commands/CommandObjectExpression.cpp
  source/Expression/ExpressionSourceCode.cpp
  source/Expression/UserExpression.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  source/Symbol/ClangASTContext.cpp
  source/Target/Target.cpp

Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -2198,7 +2198,8 @@
 UserExpression *Target::GetUserExpressionForLanguage(
 llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
 Expression::ResultType desired_type,
-const EvaluateExpressionOptions &options, Status &error) {
+const EvaluateExpressionOptions &options,
+ValueObject *ctx_obj, Status &error) {
   Status type_system_error;
 
   TypeSystem *type_system =
@@ -2214,7 +2215,7 @@
   }
 
   user_expr = type_system->GetUserExpression(expr, prefix, language,
- desired_type, options);
+ desired_type, options, ctx_obj);
   if (!user_expr)
 error.SetErrorStringWithFormat(
 "Could not create an expression for language %s",
@@ -2355,7 +2356,8 @@
 ExpressionResults Target::EvaluateExpression(
 llvm::StringRef expr, ExecutionContextScope *exe_scope,
 lldb::ValueObjectSP &result_valobj_sp,
-const EvaluateExpressionOptions &options, std::string *fixed_expression) {
+const EvaluateExpressionOptions &options, std::string *fixed_expression,
+ValueObject *ctx_obj) {
   result_valobj_sp.reset();
 
   ExpressionResults execution_results = eExpressionSetupError;
@@ -2396,7 +2398,9 @@
 execution_results = UserExpression::Evaluate(exe_ctx, options, expr, prefix,
  result_valobj_sp, error,
  0, // Line Number
- fixed_expression);
+ fixed_expression,
+ nullptr, // Module
+ ctx_obj);
   }
 
   m_suppress_stop_hooks = old_suppress_value;
Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -10294,13 +10294,14 @@
 UserExpression *ClangASTContextForExpressions::GetUserExpression(
 llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
 Expression::ResultType desired_type,
-const EvaluateExpressionOptions &options) {
+const EvaluateExpressionOptions &options,
+ValueObject *ctx_obj) {
   TargetSP target_sp = m_target_wp.lock();
   if (!target_sp)
 return nullptr;
 
   return new ClangUserExpression(*target_sp.get(), expr, prefix, language,
- desired_type, options);
+ desired_type, options, ctx_obj);
 }
 
 FunctionCaller *ClangASTContextForExpressions::GetFunctionCaller(
Index: source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -157,5 +157,6 @@
 void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(
 ExecutionContext &exe_ctx, bool keep_result_in_memory) {
   m_expr_decl_map_up.reset(
-  new ClangExpressionDeclMap(keep_result_in_memory, nullptr, exe_ctx));
+  new ClangExpressionDeclMap(keep_result_in_memory, nullptr, exe_ctx,
+ nullptr));
 }
Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
=

[Lldb-commits] [PATCH] D55316: [CMake] Add support for NO_INSTALL_RPATH argument in llvm_add_library()

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 177142.
sgraenitz added a comment.

Add short comment for NO_INSTALL_RPATH parameter to function description


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55316

Files:
  cmake/modules/AddLLVM.cmake


Index: cmake/modules/AddLLVM.cmake
===
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -372,12 +372,14 @@
 # May specify header files for IDE generators.
 #   SONAME
 # Should set SONAME link flags and create symlinks
+#   NO_INSTALL_RPATH
+# Suppress default RPATH settings in shared libraries.
 #   PLUGIN_TOOL
 # The tool (i.e. cmake target) that this plugin will link against
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
+
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH"
 "OUTPUT_NAME;PLUGIN_TOOL"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -448,17 +450,19 @@
 
   if(ARG_MODULE)
 add_library(${name} MODULE ${ALL_FILES})
-llvm_setup_rpath(${name})
   elseif(ARG_SHARED)
 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
 add_library(${name} SHARED ${ALL_FILES})
-
-llvm_setup_rpath(${name})
-
   else()
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(NOT ARG_NO_INSTALL_RPATH)
+if(ARG_MODULE OR ARG_SHARED)
+  llvm_setup_rpath(${name})
+endif()
+  endif()
+
   setup_dependency_debugging(${name} ${LLVM_COMMON_DEPENDS})
 
   if(DEFINED windows_resource_file)


Index: cmake/modules/AddLLVM.cmake
===
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -372,12 +372,14 @@
 # May specify header files for IDE generators.
 #   SONAME
 # Should set SONAME link flags and create symlinks
+#   NO_INSTALL_RPATH
+# Suppress default RPATH settings in shared libraries.
 #   PLUGIN_TOOL
 # The tool (i.e. cmake target) that this plugin will link against
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
+"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH"
 "OUTPUT_NAME;PLUGIN_TOOL"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -448,17 +450,19 @@
 
   if(ARG_MODULE)
 add_library(${name} MODULE ${ALL_FILES})
-llvm_setup_rpath(${name})
   elseif(ARG_SHARED)
 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
 add_library(${name} SHARED ${ALL_FILES})
-
-llvm_setup_rpath(${name})
-
   else()
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(NOT ARG_NO_INSTALL_RPATH)
+if(ARG_MODULE OR ARG_SHARED)
+  llvm_setup_rpath(${name})
+endif()
+  endif()
+
   setup_dependency_debugging(${name} ${LLVM_COMMON_DEPENDS})
 
   if(DEFINED windows_resource_file)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55316: [CMake] Add support for NO_INSTALL_RPATH argument in llvm_add_library()

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked 2 inline comments as done.
sgraenitz added inline comments.



Comment at: cmake/modules/AddLLVM.cmake:458
 
+  if(NOT ARG_NO_INSTALL_RPATH)
+if(ARG_MODULE OR ARG_SHARED)

aprantl wrote:
> Any kind of comment that we could add here that explains why this is 
> happening? This looks quite mysterious to the casual reader otherwise :-)
Good point, thanks. Added short comment to the function description.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55316



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


[Lldb-commits] [PATCH] D55316: [CMake] Add support for NO_INSTALL_RPATH argument in llvm_add_library()

2018-12-07 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348573: [CMake] Add support for NO_INSTALL_RPATH argument in 
llvm_add_library() (authored by stefan.graenitz, committed by ).

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55316

Files:
  llvm/trunk/cmake/modules/AddLLVM.cmake


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -372,12 +372,14 @@
 # May specify header files for IDE generators.
 #   SONAME
 # Should set SONAME link flags and create symlinks
+#   NO_INSTALL_RPATH
+# Suppress default RPATH settings in shared libraries.
 #   PLUGIN_TOOL
 # The tool (i.e. cmake target) that this plugin will link against
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
+
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH"
 "OUTPUT_NAME;PLUGIN_TOOL"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -448,17 +450,19 @@
 
   if(ARG_MODULE)
 add_library(${name} MODULE ${ALL_FILES})
-llvm_setup_rpath(${name})
   elseif(ARG_SHARED)
 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
 add_library(${name} SHARED ${ALL_FILES})
-
-llvm_setup_rpath(${name})
-
   else()
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(NOT ARG_NO_INSTALL_RPATH)
+if(ARG_MODULE OR ARG_SHARED)
+  llvm_setup_rpath(${name})
+endif()
+  endif()
+
   setup_dependency_debugging(${name} ${LLVM_COMMON_DEPENDS})
 
   if(DEFINED windows_resource_file)


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -372,12 +372,14 @@
 # May specify header files for IDE generators.
 #   SONAME
 # Should set SONAME link flags and create symlinks
+#   NO_INSTALL_RPATH
+# Suppress default RPATH settings in shared libraries.
 #   PLUGIN_TOOL
 # The tool (i.e. cmake target) that this plugin will link against
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
+"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH"
 "OUTPUT_NAME;PLUGIN_TOOL"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -448,17 +450,19 @@
 
   if(ARG_MODULE)
 add_library(${name} MODULE ${ALL_FILES})
-llvm_setup_rpath(${name})
   elseif(ARG_SHARED)
 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
 add_library(${name} SHARED ${ALL_FILES})
-
-llvm_setup_rpath(${name})
-
   else()
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(NOT ARG_NO_INSTALL_RPATH)
+if(ARG_MODULE OR ARG_SHARED)
+  llvm_setup_rpath(${name})
+endif()
+  endif()
+
   setup_dependency_debugging(${name} ${LLVM_COMMON_DEPENDS})
 
   if(DEFINED windows_resource_file)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55384: [NativePDB] Reconstruct FunctionDecl AST nodes from PDB debug info

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D55384#1321970 , @zturner wrote:

> Clang-cl emits `S_LOCAL` symbols while MSVC emits `S_REGREL32` and 
> `S_REGISTER` symbols.  So, to get more test coverage, I added an MSVC test as 
> well.


I don't want to block this patch, but my thoughts after reading this is that 
this is repeating the same mistakes that we did with dwarf. The reason we need 
so much to run our tests in so many configurations is that we haven't found a 
way way to handle the fact that some things can be expressed in multiple ways 
in the debug info other than compiling the source code with the compiler which 
happens to use that dialect. Then, if a later e.g. clang chooses to do the same 
thing that msvc does, we lose coverage here without anyone noticing. For 
low-level details like these, I believe a test where the type of the symbol is 
explicit would be more appropriate (for dwarf that might be a .s file, I don't 
know if that would work for pdbs).


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

https://reviews.llvm.org/D55384



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


[Lldb-commits] [PATCH] D55422: Rename ObjectFile::GetHeaderAddress to GetBaseAddress

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: clayborg, jasonmolenda, amccarth, lemo, 
stella.stamenova.

This function was named such because in the case of MachO files, the
mach header is located at this address. However all (most?) usages of
this function were not interested in that fact, but the fact that this
address is used as the base address for expressing various relative
addresses in the object file.

For other object file formats, this name is not appropriate (and it's
probably the reason why this function was not implemented in these
classes). In the ELF case the ELF header will usually end up at this
address, but this is a result of the linker optimizing the file layout
and not a requirement of the spec. For COFF files, I believe the is no
header located at this address either.


https://reviews.llvm.org/D55422

Files:
  include/lldb/Symbol/ObjectFile.h
  source/API/SBModule.cpp
  source/Commands/CommandObjectTarget.cpp
  source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  source/Symbol/CompactUnwindInfo.cpp

Index: source/Symbol/CompactUnwindInfo.cpp
===
--- source/Symbol/CompactUnwindInfo.cpp
+++ source/Symbol/CompactUnwindInfo.cpp
@@ -204,7 +204,7 @@
 if (sl) {
   addr_t func_range_start_file_addr =
   function_info.valid_range_offset_start +
-  m_objfile.GetHeaderAddress().GetFileAddress();
+  m_objfile.GetBaseAddress().GetFileAddress();
   AddressRange func_range(func_range_start_file_addr,
   function_info.valid_range_offset_end -
   function_info.valid_range_offset_start,
@@ -513,7 +513,7 @@
 return false;
 
   addr_t function_offset =
-  address.GetFileAddress() - m_objfile.GetHeaderAddress().GetFileAddress();
+  address.GetFileAddress() - m_objfile.GetBaseAddress().GetFileAddress();
 
   UnwindIndex key;
   key.function_offset = function_offset;
@@ -578,10 +578,10 @@
   if (sl) {
 uint32_t lsda_offset = GetLSDAForFunctionOffset(
 lsda_array_start, lsda_array_count, function_offset);
-addr_t objfile_header_file_address =
-m_objfile.GetHeaderAddress().GetFileAddress();
+addr_t objfile_base_address =
+m_objfile.GetBaseAddress().GetFileAddress();
 unwind_info.lsda_address.ResolveAddressUsingFileSections(
-objfile_header_file_address + lsda_offset, sl);
+objfile_base_address + lsda_offset, sl);
   }
 }
 if (unwind_info.encoding & UNWIND_PERSONALITY_MASK) {
@@ -596,10 +596,10 @@
   SectionList *sl = m_objfile.GetSectionList();
   if (sl) {
 uint32_t personality_offset = m_unwindinfo_data.GetU32(&offset);
-addr_t objfile_header_file_address =
-m_objfile.GetHeaderAddress().GetFileAddress();
+addr_t objfile_base_address =
+m_objfile.GetBaseAddress().GetFileAddress();
 unwind_info.personality_ptr_address.ResolveAddressUsingFileSections(
-objfile_header_file_address + personality_offset, sl);
+objfile_base_address + personality_offset, sl);
   }
 }
   }
@@ -662,10 +662,10 @@
   if (sl) {
 uint32_t lsda_offset = GetLSDAForFunctionOffset(
 lsda_array_start, lsda_array_count, function_offset);
-addr_t objfile_header_file_address =
-m_objfile.GetHeaderAddress().GetFileAddress();
+addr_t objfile_base_address =
+m_objfile.GetBaseAddress().GetFileAddress();
 unwind_info.lsda_address.ResolveAddressUsingFileSections(
-objfile_header_file_address + lsda_offset, sl);
+objfile_base_address + lsda_offset, sl);
   }
 }
 if (unwind_info.encoding & UNWIND_PERSONALITY_MASK) {
@@ -680,10 +680,10 @@
   SectionList *sl = m_objfile.GetSectionList();
   if (sl) {
 uint32_t personality_offset = m_unwindinfo_data.GetU32(&offset);
-addr_t objfile_header_file_address =
-m_objfile.GetHeaderAddress().GetFileAddress();
+addr_t objfile_base_address =
+m_objfile.GetBaseAddress().GetFileAddress();
 unwind_info.personality_ptr_address.ResolveAddressUsingFileSections(
-objfile_header_file_address + personality_offset, sl);
+objfile_base_address + personality_offset, sl);
   }
 }
   }
Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
===
--- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ source/Plugins/ObjectFile/Mac

[Lldb-commits] [PATCH] D55422: Rename ObjectFile::GetHeaderAddress to GetBaseAddress

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added a comment.

Adding a bunch of people to make sure this makes sense for all object formats 
(I am particularly oblivious to how COFF works). If this makes sense, I'll 
implement this function in ObjectFilePECOFF and ELF to return the "image base" 
and "base address" respectively.




Comment at: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:1676-1677
 if (is_dsym && unified_section_sp->GetFileAddress() != load_cmd.vmaddr) {
   // Check to see if the module was read from memory?
-  if (module_sp->GetObjectFile()->GetHeaderAddress().IsValid()) {
+  if (module_sp->GetObjectFile()->GetBaseAddress().IsValid()) {
 // We have a module that is in memory and needs to have its file

This is the most dodgy usage I believe. It looks like this piece of code is 
expecting to use the base ObjectFile implementation of this function, which 
returns the `m_memory_addr` member. However, this will in reality call the 
MachO implementation which does something completely different (and independent 
of being in memory). It might be better to change this to 
`GetObjectFile()->IsInMemory()`, but I have no idea how to verify that.


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

https://reviews.llvm.org/D55422



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


[Lldb-commits] [PATCH] D55356: Add a method to get the "base" file address of an object file

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath planned changes to this revision.
labath added a comment.

In D55356#1321863 , @clayborg wrote:

> This is already available with:
>
>   virtual lldb_private::Address ObjectFile::GetHeaderAddress(); 
>
>
> It return a lldb_private::Address which is section offset, but nothing 
> stopping us from returning a lldb_private::Address with no section and just 
> the file address. For mach-o the mach header is in the __TEXT segment, but 
> not true for other file formats. I am ok if we need to rename 
> "GetHeaderAddress()" to something else.


Thanks for pointing that out. I was very surprised that this functionality is 
not available already. It looks like all/most uses of `GetHeaderAddress` don't 
really care that there is a header located at that address, but are rather 
interested in it's property of being a base address for various calculations 
(the same thing that I am). So I've created D55422 
 to rename it to something more appropriate.


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

https://reviews.llvm.org/D55356



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


[Lldb-commits] [PATCH] D55320: [CMake] Move debugserver options to separate debugserverConfig.cmake

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 177193.
sgraenitz marked 2 inline comments as done.
sgraenitz added a comment.

Remove LLDB_VERSION as it's not currently used by debugserver


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

https://reviews.llvm.org/D55320

Files:
  cmake/modules/debugserverConfig.cmake
  tools/debugserver/CMakeLists.txt
  utils/lldb-dotest/CMakeLists.txt


Index: utils/lldb-dotest/CMakeLists.txt
===
--- utils/lldb-dotest/CMakeLists.txt
+++ utils/lldb-dotest/CMakeLists.txt
@@ -9,12 +9,14 @@
   foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS 
"${LLDB_DOTEST_ARGS}")
+message("Generate wrapper for each build mode: LLDB_DOTEST_DIR for 
LLVM_BUILD_MODE == ${LLDB_DOTEST_DIR}")
 configure_file(
   lldb-dotest.in
   ${LLDB_DOTEST_DIR}/lldb-dotest
   )
   endforeach()
 else()
+  message("Generate wrapper for each build mode: LLDB_DOTEST_DIR == 
${LLVM_RUNTIME_OUTPUT_INTDIR}")
   configure_file(
 lldb-dotest.in
 ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-dotest
Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -10,19 +10,12 @@
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
-  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
-  "Identity for code signing debugserver (Darwin only)")
-
-  if(LLDB_CODESIGN_IDENTITY)
-set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" 
FORCE)
-  endif()
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)
Index: cmake/modules/debugserverConfig.cmake
===
--- /dev/null
+++ cmake/modules/debugserverConfig.cmake
@@ -0,0 +1,9 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver 
Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
+set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+"Identity for code signing debugserver (Darwin only)")
+
+if(LLDB_CODESIGN_IDENTITY)
+  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" 
FORCE)
+endif()


Index: utils/lldb-dotest/CMakeLists.txt
===
--- utils/lldb-dotest/CMakeLists.txt
+++ utils/lldb-dotest/CMakeLists.txt
@@ -9,12 +9,14 @@
   foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
+message("Generate wrapper for each build mode: LLDB_DOTEST_DIR for LLVM_BUILD_MODE == ${LLDB_DOTEST_DIR}")
 configure_file(
   lldb-dotest.in
   ${LLDB_DOTEST_DIR}/lldb-dotest
   )
   endforeach()
 else()
+  message("Generate wrapper for each build mode: LLDB_DOTEST_DIR == ${LLVM_RUNTIME_OUTPUT_INTDIR}")
   configure_file(
 lldb-dotest.in
 ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-dotest
Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -10,19 +10,12 @@
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
-  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
-  "Identity for code signing debugserver (Darwin only)")
-
-  if(LLDB_CODESIGN_IDENTITY)
-set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" FORCE)
-  endif()
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)
Index: cmake/modules/debugserverConfig.cmake
===
--- /dev/null
+++ cmake/modules/debugserverConfig.cmake
@@ -0,0 +1,9 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
+set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+"Identity for co

[Lldb-commits] [PATCH] D55320: [CMake] Move debugserver options to separate debugserverConfig.cmake

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 177194.
sgraenitz added a comment.

Revert accidental change utils/lldb-dotest/CMakeLists.txt


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

https://reviews.llvm.org/D55320

Files:
  cmake/modules/debugserverConfig.cmake
  tools/debugserver/CMakeLists.txt


Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -10,19 +10,12 @@
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
-  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
-  "Identity for code signing debugserver (Darwin only)")
-
-  if(LLDB_CODESIGN_IDENTITY)
-set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" 
FORCE)
-  endif()
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)
Index: cmake/modules/debugserverConfig.cmake
===
--- /dev/null
+++ cmake/modules/debugserverConfig.cmake
@@ -0,0 +1,9 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver 
Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
+set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+"Identity for code signing debugserver (Darwin only)")
+
+if(LLDB_CODESIGN_IDENTITY)
+  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" 
FORCE)
+endif()


Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -10,19 +10,12 @@
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
-  set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
-  "Identity for code signing debugserver (Darwin only)")
-
-  if(LLDB_CODESIGN_IDENTITY)
-set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" FORCE)
-  endif()
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)
Index: cmake/modules/debugserverConfig.cmake
===
--- /dev/null
+++ cmake/modules/debugserverConfig.cmake
@@ -0,0 +1,9 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
+set(LLDB_CODESIGN_IDENTITY lldb_codesign CACHE STRING
+"Identity for code signing debugserver (Darwin only)")
+
+if(LLDB_CODESIGN_IDENTITY)
+  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY} CACHE STRING "" FORCE)
+endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55320: [CMake] Move debugserver options to separate debugserverConfig.cmake

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked an inline comment as done.
sgraenitz added inline comments.



Comment at: cmake/modules/debugserverConfig.cmake:2
+# Duplicate options from LLDBConfig that are relevant for debugserver 
Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)

aprantl wrote:
> I don't know CMake enough, but would it be feasible to have both file 
> #include a fragment with the shared code?
Yes I think this makes sense as soon as the number of duplicates grows.

BTW I double-checked and we don't use LLDB_VERSION in debugserver standalone 
yet, so for now I won't add it. Updated the review accordingly.


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

https://reviews.llvm.org/D55320



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


[Lldb-commits] [PATCH] D55430: build.py: Implement "gcc" builder

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added a reviewer: zturner.
Herald added subscribers: dexonsmith, mehdi_amini.

This implements the gcc builder in build.py script to allow it to
compile host executables when running on a non-windows host. Where it
made sense, I tried to share code with the msvc builder by moving stuff
to the base class.

I did not implement the lto part because I don't know how that works,
(and it's likely things will differ between platforms there).


https://reviews.llvm.org/D55430

Files:
  lit/Breakpoint/case-sensitive.test
  lit/BuildScript/toolchain-clang.test
  lit/helper/build.py

Index: lit/helper/build.py
===
--- lit/helper/build.py
+++ lit/helper/build.py
@@ -1,3 +1,5 @@
+#! /usr/bin/env python
+
 from __future__ import print_function
 
 import argparse
@@ -207,7 +209,7 @@
 return 'unknown'
 
 class Builder(object):
-def __init__(self, toolchain_type, args):
+def __init__(self, toolchain_type, args, obj_ext):
 self.toolchain_type = toolchain_type
 self.inputs = args.inputs
 self.arch = args.arch
@@ -219,10 +221,50 @@
 self.mode = args.mode
 self.nodefaultlib = args.nodefaultlib
 self.verbose = args.verbose
+self.obj_ext = obj_ext
+
+def _exe_file_name(self):
+assert self.mode != 'compile'
+return self.output
+
+def _output_name(self, input, extension, with_executable=False):
+basename = os.path.splitext(os.path.basename(input))[0] + extension
+if with_executable:
+exe_basename = os.path.basename(self._exe_file_name())
+basename = exe_basename + '-' + basename
+
+output = os.path.join(self.outdir, basename)
+return os.path.normpath(output)
+
+def _obj_file_names(self):
+if self.mode == 'link':
+return self.inputs
+
+if self.mode == 'compile-and-link':
+# Object file names should factor in both the input file (source)
+# name and output file (executable) name, to ensure that two tests
+# which share a common source file don't race to write the same
+# object file.
+return [self._output_name(x, self.obj_ext, True) for x in self.inputs]
+
+if self.mode == 'compile' and self.output:
+return [self.output]
+
+return [self._output_name(x, self.obj_ext) for x in self.inputs]
+
+def build_commands(self):
+commands = []
+if self.mode == 'compile' or self.mode == 'compile-and-link':
+for input, output in zip(self.inputs, self._obj_file_names()):
+commands.append(self._get_compilation_command(input, output))
+if self.mode == 'link' or self.mode == 'compile-and-link':
+commands.append(self._get_link_command())
+return commands
+
 
 class MsvcBuilder(Builder):
 def __init__(self, toolchain_type, args):
-Builder.__init__(self, toolchain_type, args)
+Builder.__init__(self, toolchain_type, args, '.obj')
 
 self.msvc_arch_str = 'x86' if self.arch == '32' else 'x64'
 
@@ -486,47 +528,17 @@
 linkenv.update(defaultenv)
 return (compileenv, linkenv)
 
-def _output_name(self, input, extension, with_executable=False):
-basename = os.path.splitext(os.path.basename(input))[0] + extension
-if with_executable:
-exe_basename = os.path.basename(self._exe_file_name())
-basename = exe_basename + '-' + basename
-
-output = os.path.join(self.outdir, basename)
-return os.path.normpath(output)
-
 def _ilk_file_names(self):
 if self.mode == 'link':
 return []
 
 return [self._output_name(x, '.ilk') for x in self.inputs]
 
-def _obj_file_names(self):
-if self.mode == 'link':
-return self.inputs
-
-if self.mode == 'compile-and-link':
-# Object file names should factor in both the input file (source)
-# name and output file (executable) name, to ensure that two tests
-# which share a common source file don't race to write the same
-# object file.
-return [self._output_name(x, '.obj', True) for x in self.inputs]
-
-if self.mode == 'compile' and self.output:
-return [self.output]
-
-return [self._output_name(x, '.obj') for x in self.inputs]
-
 def _pdb_file_name(self):
 if self.mode == 'compile':
 return None
 return os.path.splitext(self.output)[0] + '.pdb'
 
-def _exe_file_name(self):
-if self.mode == 'compile':
-return None
-return self.output
-
 def _get_compilation_command(self, source, obj):
 args = []
 
@@ -586,10 +598,6 @@
 return commands
 
 def output_files(self):
-outdir = os.path.dirname(self.output)
-file = os.path.basename(self.output)
-n

[Lldb-commits] [PATCH] D55214: Introduce ObjectFileBreakpad

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rL348592: Introduce ObjectFileBreakpad (authored by labath, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55214?vs=176781&id=177200#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55214

Files:
  lldb/trunk/include/lldb/Symbol/ObjectFile.h
  lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
  lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
  lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
  lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms
  lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms
  lldb/trunk/lit/Modules/Breakpad/Inputs/identification-windows.syms
  lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
  lldb/trunk/lit/Modules/Breakpad/lit.local.cfg
  lldb/trunk/source/API/SystemInitializerFull.cpp
  lldb/trunk/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
  lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
  lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
  lldb/trunk/source/Plugins/ObjectFile/CMakeLists.txt
  lldb/trunk/source/Symbol/ObjectFile.cpp
  lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
  lldb/trunk/tools/lldb-test/lldb-test.cpp

Index: lldb/trunk/tools/lldb-test/lldb-test.cpp
===
--- lldb/trunk/tools/lldb-test/lldb-test.cpp
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp
@@ -726,6 +726,14 @@
 ModuleSpec Spec{FileSpec(File)};
 
 auto ModulePtr = std::make_shared(Spec);
+
+ObjectFile *ObjectPtr = ModulePtr->GetObjectFile();
+if (!ObjectPtr) {
+  WithColor::error() << File << " not recognised as an object file\n";
+  HadErrors = 1;
+  continue;
+}
+
 // Fetch symbol vendor before we get the section list to give the symbol
 // vendor a chance to populate it.
 ModulePtr->GetSymbolVendor();
@@ -736,9 +744,14 @@
   continue;
 }
 
+Printer.formatLine("Plugin name: {0}", ObjectPtr->GetPluginName());
 Printer.formatLine("Architecture: {0}",
ModulePtr->GetArchitecture().GetTriple().getTriple());
 Printer.formatLine("UUID: {0}", ModulePtr->GetUUID().GetAsString());
+Printer.formatLine("Executable: {0}", ObjectPtr->IsExecutable());
+Printer.formatLine("Stripped: {0}", ObjectPtr->IsStripped());
+Printer.formatLine("Type: {0}", ObjectPtr->GetType());
+Printer.formatLine("Strata: {0}", ObjectPtr->GetStrata());
 
 size_t Count = Sections->GetNumSections(0);
 Printer.formatLine("Showing {0} sections", Count);
Index: lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
@@ -52,6 +52,7 @@
 #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
 #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
 #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
+#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
@@ -116,6 +117,7 @@
   if (auto e = SystemInitializerCommon::Initialize(options))
 return e;
 
+  breakpad::ObjectFileBreakpad::Initialize();
   ObjectFileELF::Initialize();
   ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
@@ -331,6 +333,7 @@
   PlatformDarwinKernel::Terminate();
 #endif
 
+  breakpad::ObjectFileBreakpad::Terminate();
   ObjectFileELF::Terminate();
   ObjectFileMachO::Terminate();
   ObjectFilePECOFF::Terminate();
Index: lldb/trunk/source/API/SystemInitializerFull.cpp
===
--- lldb/trunk/source/API/SystemInitializerFull.cpp
+++ lldb/trunk/source/API/SystemInitializerFull.cpp
@@ -62,6 +62,7 @@
 #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
 #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
 #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
+#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
@@ -268,6 +269,7 @@
   if (auto e = SystemInitializerCommon::Initialize(options))
 return e;
 
+  breakpad::ObjectFileBreakpad::Initialize();
   ObjectFileELF::Initialize();
   ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
@@ -525,6 +527,7 @@
   PlatformDarwinKernel::Terminate();
 #en

[Lldb-commits] [lldb] r348592 - Introduce ObjectFileBreakpad

2018-12-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec  7 06:20:27 2018
New Revision: 348592

URL: http://llvm.org/viewvc/llvm-project?rev=348592&view=rev
Log:
Introduce ObjectFileBreakpad

Summary:
This patch adds the scaffolding necessary for lldb to recognise symbol
files generated by breakpad. These (textual) files contain just enough
information to be able to produce a backtrace from a crash
dump. This information includes:
- UUID, architecture and name of the module
- line tables
- list of symbols
- unwind information

A minimal breakpad file could look like this:
MODULE Linux x86_64 24B5D199F0F766FF5DC30 a.out
INFO CODE_ID B52499D1F0F766FF5DC3
FILE 0 /tmp/a.c
FUNC 1010 10 0 _start
1010 4 4 0
1014 5 5 0
1019 5 6 0
101e 2 7 0
PUBLIC 1010 0 _start
STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
STACK CFI 1014 .cfa: $rbp 16 +

Even though this data would normally be considered "symbol" information,
in the current lldb infrastructure it is assumed every SymbolFile object
is backed by an ObjectFile instance. So, in order to better interoperate
with the rest of the code (particularly symbol vendors).

In this patch I just parse the breakpad header, which is enough to
populate the UUID and architecture fields of the ObjectFile interface.
The rough plan for followup patches is to expose the individual parts of
the breakpad file as ObjectFile "sections", which can then be used by
other parts of the codebase (SymbolFileBreakpad ?) to vend the necessary
information.

Reviewers: clayborg, zturner, lemo, amccarth

Subscribers: mgorny, fedor.sergeev, markmentovai, lldb-commits

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

Added:
lldb/trunk/lit/Modules/Breakpad/
lldb/trunk/lit/Modules/Breakpad/Inputs/
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-windows.syms
lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
lldb/trunk/lit/Modules/Breakpad/lit.local.cfg
lldb/trunk/source/Plugins/ObjectFile/Breakpad/
lldb/trunk/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
Modified:
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Plugins/ObjectFile/CMakeLists.txt
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=348592&r1=348591&r2=348592&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Dec  7 06:20:27 2018
@@ -817,4 +817,16 @@ private:
 
 } // namespace lldb_private
 
+namespace llvm {
+template <> struct format_provider {
+  static void format(const lldb_private::ObjectFile::Type &type,
+ raw_ostream &OS, StringRef Style);
+};
+
+template <> struct format_provider {
+  static void format(const lldb_private::ObjectFile::Strata &strata,
+ raw_ostream &OS, StringRef Style);
+};
+} // namespace llvm
+
 #endif // liblldb_ObjectFile_h_

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms?rev=348592&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms Fri Dec  7 
06:20:27 2018
@@ -0,0 +1,2 @@
+MODULE Linux x86_64 E5894855+C35D+0 linux.out
+PUBLIC 1000 0 _start

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms?rev=348592&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms Fri Dec  7 
06:20:27 2018
@@ -0,0 +1,2 @@
+MODULE Linux x86_64 E5894855C35DC linux.out
+PUBLIC 1000 0 _start

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms?rev=348592

[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

Thanks for taking a look!

> It's not introduced in this patch, but the part that struck me as a hack has 
> the force-overwriting of LLVM_CODESIGNING_IDENTITY. Is there any way that 
> could be removed?

I agree, this is unfortunate. The problem is that we only have a single global 
setting for the identity in LLVM and we want `lldb_codesign` as the default for 
LLDB. We can only change this default if we use a cache script or pass it to 
CMake explicitly, but at the time we arrive in LLDBConfig it's set already. So 
to make it work out-of-the-box we need the force-overwrite.

Actually, I considered changing the `llvm_codesign` function to accept an 
override value for the identity and pass it through 
`lldb_add_executable`/`llvm_add_executable` per target. In the end the use-case 
didn't really seem worth the amount of change. Also, overriding a global 
`LLVM_CODESIGNING_IDENTITY` with a default value might be very confusing. I 
considered a LLDB-specific version as well (D54352 
), but with the amount of code duplication 
@beanz was definitely right that this is not a good way either.


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

https://reviews.llvm.org/D55328



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


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

>> It's not introduced in this patch, but the part that struck me as a hack has 
>> the force-overwriting of LLVM_CODESIGNING_IDENTITY. Is there any way that 
>> could be removed?
> 
> I agree, this is unfortunate. The problem is that we only have a single 
> global setting for the identity in LLVM and we want `lldb_codesign` as the 
> default for LLDB.

Now that I think about it again, I could at least print a warning if 
`LLVM_CODESIGNING_IDENTITY ` is not empty when force-overwriting. What do you 
think?


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

https://reviews.llvm.org/D55328



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


[Lldb-commits] [PATCH] D55434: ObjectFileBreakpad: Implement sections

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: clayborg, zturner, lemo, markmentovai, amccarth.

This patch allows ObjectFileBreakpad to parse the contents of Breakpad
files into sections. This sounds slightly odd at first, but in essence
its not too different from how other object files handle things. For
example in elf files, the symtab section consists of a number of
"records", where each record represents a single symbol. The same is
true for breakpad's PUBLIC section, except in this case, the records will be
textual instead of binary.

To keep sections contiguous, I create a new section every time record
type changes. Normally, the breakpad processor will group all records of
the same type in one block, but the format allows them to be intermixed,
so in general, the "object file" may contain multiple sections with the
same record type.


https://reviews.llvm.org/D55434

Files:
  include/lldb/Utility/DataExtractor.h
  lit/Modules/Breakpad/Inputs/discontiguous-sections.syms
  lit/Modules/Breakpad/Inputs/sections-trailing-func.syms
  lit/Modules/Breakpad/Inputs/sections.syms
  lit/Modules/Breakpad/discontiguous-sections.test
  lit/Modules/Breakpad/sections-trailing-func.test
  lit/Modules/Breakpad/sections.test
  source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp

Index: source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
===
--- source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
+++ source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
@@ -10,6 +10,7 @@
 #include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "llvm/ADT/StringExtras.h"
 
@@ -23,8 +24,41 @@
   UUID uuid;
   static llvm::Optional parse(llvm::StringRef text);
 };
+
+enum class Token { Unknown, Module, Info, File, Func, Public, Stack };
 } // namespace
 
+static Token toToken(llvm::StringRef str) {
+  return llvm::StringSwitch(str)
+  .Case("MODULE", Token::Module)
+  .Case("INFO", Token::Info)
+  .Case("FILE", Token::File)
+  .Case("FUNC", Token::Func)
+  .Case("PUBLIC", Token::Public)
+  .Case("STACK", Token::Stack)
+  .Default(Token::Unknown);
+}
+
+static llvm::StringRef toString(Token t) {
+  switch (t) {
+  case Token::Unknown:
+return "";
+  case Token::Module:
+return "MODULE";
+  case Token::Info:
+return "INFO";
+  case Token::File:
+return "FILE";
+  case Token::Func:
+return "FUNC";
+  case Token::Public:
+return "PUBLIC";
+  case Token::Stack:
+return "STACK";
+  }
+  llvm_unreachable("Unknown token!");
+}
+
 static llvm::Triple::OSType toOS(llvm::StringRef str) {
   using llvm::Triple;
   return llvm::StringSwitch(str)
@@ -103,7 +137,7 @@
   llvm::StringRef token, line;
   std::tie(line, text) = text.split('\n');
   std::tie(token, line) = getToken(line);
-  if (token != "MODULE")
+  if (toToken(token) != Token::Module)
 return llvm::None;
 
   std::tie(token, line) = getToken(line);
@@ -235,5 +269,46 @@
 }
 
 void ObjectFileBreakpad::CreateSections(SectionList &unified_section_list) {
-  // TODO
+  if (m_sections_ap)
+return;
+  m_sections_ap = llvm::make_unique();
+
+  Token current_section = Token::Unknown;
+  offset_t section_start;
+  llvm::StringRef text = toStringRef(m_data.GetData());
+  uint32_t next_section_id = 0;
+  auto maybe_add_section = [&](const uint8_t *end_ptr) {
+if (current_section == Token::Unknown)
+  return; // We have been called before parsing the first line.
+
+offset_t end_offset = end_ptr - m_data.GetDataStart();
+auto section_sp = std::make_shared(
+GetModule(), this, next_section_id++,
+ConstString(toString(current_section)), eSectionTypeOther,
+/*file_vm_addr*/ 0, /*vm_size*/ 0, section_start,
+end_offset - section_start, /*log2align*/ 0, /*flags*/ 0);
+m_sections_ap->AddSection(section_sp);
+unified_section_list.AddSection(section_sp);
+  };
+  while (!text.empty()) {
+llvm::StringRef line;
+std::tie(line, text) = text.split('\n');
+
+Token token = toToken(getToken(line).first);
+if (token == Token::Unknown) {
+  // We assume this is a line record, which logically belongs to the Func
+  // section. Errors will be handled when parsing the Func section.
+  token = Token::Func;
+}
+if (token == current_section)
+  continue;
+
+// Changing sections, finish off the previous one, if there was any.
+maybe_add_section(line.bytes_begin());
+// And start a new one.
+current_section = token;
+section_start = line.bytes_begin() - m_data.GetDataStart();
+  }
+  // Finally, add the last section.
+  maybe_add_section(m_data.GetDataEnd());
 }
Index: lit/Modules/Breakpad/sections.test
===
--- /dev/null
+++ lit/Modules/Breakpa

[Lldb-commits] [PATCH] D55361: Move Broadcaster+Listener+Event combo from Core into Utility

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 177212.
labath marked 3 inline comments as done.
labath added a comment.

Thanks for the review.

Yes the changes were done by clang-format, which even in the diff-only mode
doesn't know the difference between a moved file and a newly created one. I hope
this version successfully reverts those.

I'll keep this open a bit more to see if anyone else wants to say something. If
not I'll commit some time next week.


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

https://reviews.llvm.org/D55361

Files:
  include/lldb/Breakpoint/Breakpoint.h
  include/lldb/Breakpoint/BreakpointName.h
  include/lldb/Core/Broadcaster.h
  include/lldb/Core/Communication.h
  include/lldb/Core/Debugger.h
  include/lldb/Core/Event.h
  include/lldb/Core/Listener.h
  include/lldb/Core/StructuredDataImpl.h
  include/lldb/Interpreter/CommandInterpreter.h
  include/lldb/Interpreter/ScriptInterpreter.h
  include/lldb/Target/Process.h
  include/lldb/Target/Target.h
  include/lldb/Target/TargetList.h
  include/lldb/Target/Thread.h
  include/lldb/Utility/Broadcaster.h
  include/lldb/Utility/Event.h
  include/lldb/Utility/Listener.h
  source/API/SBBroadcaster.cpp
  source/API/SBCommandInterpreter.cpp
  source/API/SBEvent.cpp
  source/API/SBListener.cpp
  source/API/SBStructuredData.cpp
  source/Core/Broadcaster.cpp
  source/Core/CMakeLists.txt
  source/Core/Communication.cpp
  source/Core/Debugger.cpp
  source/Core/Event.cpp
  source/Core/Listener.cpp
  source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
  source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
  source/Plugins/Process/Utility/HistoryThread.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  source/Target/Process.cpp
  source/Target/Target.cpp
  source/Target/TargetList.cpp
  source/Utility/Broadcaster.cpp
  source/Utility/CMakeLists.txt
  source/Utility/Event.cpp
  source/Utility/Listener.cpp
  unittests/Core/BroadcasterTest.cpp
  unittests/Core/CMakeLists.txt
  unittests/Core/EventTest.cpp
  unittests/Core/ListenerTest.cpp
  unittests/Utility/BroadcasterTest.cpp
  unittests/Utility/CMakeLists.txt
  unittests/Utility/EventTest.cpp
  unittests/Utility/ListenerTest.cpp

Index: unittests/Utility/ListenerTest.cpp
===
--- unittests/Utility/ListenerTest.cpp
+++ unittests/Utility/ListenerTest.cpp
@@ -9,8 +9,8 @@
 
 #include "gtest/gtest.h"
 
-#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/Listener.h"
+#include "lldb/Utility/Broadcaster.h"
+#include "lldb/Utility/Listener.h"
 #include 
 #include 
 
Index: unittests/Utility/EventTest.cpp
===
--- unittests/Utility/EventTest.cpp
+++ unittests/Utility/EventTest.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "lldb/Core/Event.h"
+#include "lldb/Utility/Event.h"
 #include "lldb/Utility/StreamString.h"
 #include "gtest/gtest.h"
 
Index: unittests/Utility/CMakeLists.txt
===
--- unittests/Utility/CMakeLists.txt
+++ unittests/Utility/CMakeLists.txt
@@ -3,14 +3,17 @@
   ArgsTest.cpp
   OptionsWithRawTest.cpp
   ArchSpecTest.cpp
+  BroadcasterTest.cpp
   CleanUpTest.cpp
   ConstStringTest.cpp
   CompletionRequestTest.cpp
   DataExtractorTest.cpp
   EnvironmentTest.cpp
+  EventTest.cpp
   FileSpecTest.cpp
   FlagsTest.cpp
   JSONTest.cpp
+  ListenerTest.cpp
   LogTest.cpp
   NameMatchesTest.cpp
   PredicateTest.cpp
Index: unittests/Utility/BroadcasterTest.cpp
===
--- unittests/Utility/BroadcasterTest.cpp
+++ unittests/Utility/BroadcasterTest.cpp
@@ -9,9 +9,9 @@
 
 #include "gtest/gtest.h"
 
-#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/Event.h"
-#include "lldb/Core/Listener.h"
+#include "lldb/Utility/Broadcaster.h"
+#include "lldb/Utility/Event.h"
+#include "lldb/Utility/Listener.h"
 #include "lldb/Utility/Predicate.h"
 
 #include 
Index: unittests/Core/CMakeLists.txt
===
--- unittests/Core/CMakeLists.txt
+++ unittests/Core/CMakeLists.txt
@@ -1,7 +1,4 @@
 add_lldb_unittest(LLDBCoreTests
-  BroadcasterTest.cpp
-  EventTest.cpp
-  ListenerTest.cpp
   MangledTest.cpp
   RangeTest.cpp
   RichManglingContextTest.cpp
Index: source/Utility/Listener.cpp
===
--- source/Utility/Listener.cpp
+++ source/Utility/Listener.cpp
@@ -7,11 +7,11 @@
 //
 //===--===//
 
-#include "lldb/Core/Listener.h"
+#include "lldb/Utility/Listener.h"
 
-#include "lldb/Core/Broadcaster

[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Printing the warning would definitely be nice.

Making the identity overridable via llvm_codesign arguments also sounds 
reasonable if we want to have the flexibility of signing things with different 
identities.

If we don't need that flexibility, can't we just have the users set the LLVM 
variable instead of the LLDB one?


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

https://reviews.llvm.org/D55328



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


[Lldb-commits] [PATCH] D55332: [CMake] Python bindings generation polishing

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

Thanks for taking a look!

> It would be good to make sure that this works on mac, linux and windows all 
> before you commit.

Shortly tested an in-tree lldb with clang, compiler-rt and lld on Windows using 
the below config and successfully built the `BUILD_ALL` project (Release), but 
I didn't manage to run `check-lldb` as Visual Studio failed to find the 
executable. How do you run the test suite on Windows?

  cmake -G "Visual Studio 15 2017 Win64" -DLLVM_TARGETS_TO_BUILD=host 
-DPYTHON_HOME="%PYTHON_HOME%" ../llvm


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

https://reviews.llvm.org/D55332



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


[Lldb-commits] [PATCH] D55422: Rename ObjectFile::GetHeaderAddress to GetBaseAddress

2018-12-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Looks fine. Just one clarification in the header documentation and this is good 
to go.




Comment at: include/lldb/Symbol/ObjectFile.h:561
+  /// will have this section set. Otherwise, the address will just have the
+  /// offset member filled in.
   //--

```
/// offset member filled in indicating the resulting Address object represents 
a file address.
```



Comment at: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:1677
   // Check to see if the module was read from memory?
-  if (module_sp->GetObjectFile()->GetHeaderAddress().IsValid()) {
+  if (module_sp->GetObjectFile()->GetBaseAddress().IsValid()) {
 // We have a module that is in memory and needs to have its file

Switching to IsInMemory will work. This code probably predates the existence of 
IsInMemory().


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

https://reviews.llvm.org/D55422



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


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

Working on it..

> .. if we want to have the flexibility of signing things with different 
> identities.

Not sure if it's a good idea to sign with different identities within one 
build. Could become confusing?

> If we don't need that flexibility, can't we just have the users set the LLVM 
> variable instead of the LLDB one?

Well, then we always had to pass the LLVM variable explicitly in order to 
achieve the default behavior. For the LLDB one we can control the default value.


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

https://reviews.llvm.org/D55328



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


[Lldb-commits] [PATCH] D55434: ObjectFileBreakpad: Implement sections

2018-12-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

So sections should correspond to different kinds of sections, like .text, 
.data, etc. If we have the following breakpad file:

  MODULE Linux x86_64 24B5D199F0F766FF5DC30 linux.out
  INFO CODE_ID B52499D1F0F766FF5DC3
  FILE 0 /tmp/a.c
  FUNC 1010 10 0 _start
  1010 4 4 0
  1014 5 5 0
  1019 5 6 0
  101e 2 7 0
  FUNC 2010 10 0 main
  2010 4 4 0
  2014 5 5 0
  2019 5 6 0
  201e 2 7 0
  PUBLIC 1010 0 _start
  PUBLIC 2010 0 main
  PUBLIC 3010 0 nodebuginfo1
  PUBLIC 3020 0 nodebuginfo2

I would expect to have just 1 section named ".text" with read and execute 
permissions. This section would have its m_file_addr set to 0x1010 (from FUNC 
or PUBLIC with lowest address ("FUNC 1010 10 0 _start" in this case)). The size 
of the section would be set to the max code address + size minus the lowest 
code address (0x3020 - 0x1010 in this case). The file offset and file size 
should be set to zero since section contents are typically the bytes for the 
disassembly.

One other way to do this would be to create a section for each FUNC whose 
m_file_addr it set to the FUNC start address, and whose size is set to the last 
line entry - FUNC start address. Then name of the section can be set to the 
function name in this case. I am not a huge fan of this since it just creates 
extra sections for no reason and the debug info will have this info anyway so 
it will be duplicated.

I see no reason to create sections for MODULE, INFO, FILE, or STACK records. 
Was there a reason you wanted to create sections for all these? Might be better 
to create symbols for any of these you need to reference later.

Once you start parsing the debug info, the lldb::user_id_t for any items, like 
FUNC, can just be the line number or character offset for the FUNC source line 
within the file.


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

https://reviews.llvm.org/D55434



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


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 177229.
sgraenitz added a comment.

Improve handling of LLDB_CODESIGN_IDENTITY vs. LLVM_CODESIGNING_IDENTITY


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

https://reviews.llvm.org/D55328

Files:
  CMakeLists.txt
  cmake/modules/AddLLDB.cmake
  cmake/modules/LLDBConfig.cmake
  cmake/modules/LLDBFramework.cmake
  resources/LLDB-Info.plist.in
  source/API/CMakeLists.txt
  test/CMakeLists.txt
  tools/argdumper/CMakeLists.txt
  tools/darwin-debug/CMakeLists.txt
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  tools/driver/CMakeLists.txt
  tools/lldb-server/CMakeLists.txt

Index: tools/lldb-server/CMakeLists.txt
===
--- tools/lldb-server/CMakeLists.txt
+++ tools/lldb-server/CMakeLists.txt
@@ -42,7 +42,7 @@
   list(APPEND LLDB_PLUGINS lldbPluginObjectFileELF)
 endif()
 
-add_lldb_tool(lldb-server INCLUDE_IN_SUITE
+add_lldb_tool(lldb-server
 Acceptor.cpp
 lldb-gdbserver.cpp
 lldb-platform.cpp
Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -19,7 +19,6 @@
 endif()
 
 add_dependencies(lldb
-  ${LLDB_SUITE_TARGET}
   LLDBOptionsTableGen
   ${tablegen_deps}
 )
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -240,7 +240,7 @@
  COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
   endif()
   set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
-  add_lldb_tool(debugserver INCLUDE_IN_SUITE
+  add_lldb_tool(debugserver
 debugserver.cpp
 
 LINK_LIBS
Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -15,11 +15,6 @@
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
-
-  # lldb-suite is a dummy target that encompasses all the necessary tools and
-  # libraries for building a fully-functioning liblldb.
-  add_custom_target(lldb-suite)
-  set(LLDB_SUITE_TARGET lldb-suite)
 endif()
 
 add_subdirectory(source)
Index: tools/darwin-debug/CMakeLists.txt
===
--- tools/darwin-debug/CMakeLists.txt
+++ tools/darwin-debug/CMakeLists.txt
@@ -1,3 +1,3 @@
-add_lldb_tool(darwin-debug INCLUDE_IN_SUITE
+add_lldb_tool(darwin-debug
   darwin-debug.cpp
   )
Index: tools/argdumper/CMakeLists.txt
===
--- tools/argdumper/CMakeLists.txt
+++ tools/argdumper/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_lldb_tool(lldb-argdumper INCLUDE_IN_SUITE
+add_lldb_tool(lldb-argdumper
   argdumper.cpp
 
   LINK_LIBS
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -79,7 +79,13 @@
 endif()
 
 if(LLDB_BUILD_FRAMEWORK)
-  list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLDB_FRAMEWORK_DIR}/LLDB.framework)
+  # The $ generator expression
+  # provides this value, but LLDB_DOTEST_ARGS needs it at configuration-time.
+  get_filename_component(
+framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
+BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}
+  )
+  list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_target_dir}/LLDB.framework)
 endif()
 
 if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
Index: source/API/CMakeLists.txt
===
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -92,24 +92,25 @@
 Support
   )
 
-add_dependencies(lldb-suite liblldb)
+if(LLDB_WRAP_PYTHON)
+  add_dependencies(liblldb swig_wrapper)
 
-if (MSVC)
-  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
-else()
-  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
-endif()
+  if (MSVC)
+set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
+  else()
+set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
+  endif()
 
-set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
-if (CLANG_CL)
-  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
-PROPERTY COMPILE_FLAGS " -Wno-unused-function")
+  if (CLANG_CL)
+set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+  PROPERTY COMPILE_FLAGS " -Wno-unused-function")
+  endif()
+  if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
+  NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
+set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+  PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
+  endif ()
 endif()
-if (LLVM_COMPI

[Lldb-commits] [PATCH] D55332: [CMake] Python bindings generation polishing

2018-12-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

This LGTM if it works on Windows.




Comment at: CMakeLists.txt:134
--srcRoot=${LLDB_SOURCE_DIR}
-   --targetDir=${LLDB_PYTHON_TARGET_DIR}
-   --cfgBldDir=${LLDB_PYTHON_TARGET_DIR}
+   --targetDir=$
+   --cfgBldDir=$

stella.stamenova wrote:
> I have a vague recollection that using TARGET_PROPERTY didn't work for some 
> changes I was working on a few months ago, but I don't remember the details. 
> It would be good to make sure that this works on mac, linux and windows all 
> before you commit.
IIRC and if we’re talking about the same thing, the generator expressions 
didn’t work because we were using them in a configured file (the lldb-dotest 
wrapper). Anyway, still worth double checking here.


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

https://reviews.llvm.org/D55332



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


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 177231.
sgraenitz added a comment.

Finally fix that typo


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

https://reviews.llvm.org/D55328

Files:
  CMakeLists.txt
  cmake/modules/AddLLDB.cmake
  cmake/modules/LLDBConfig.cmake
  cmake/modules/LLDBFramework.cmake
  resources/LLDB-Info.plist.in
  source/API/CMakeLists.txt
  test/CMakeLists.txt
  tools/argdumper/CMakeLists.txt
  tools/darwin-debug/CMakeLists.txt
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  tools/driver/CMakeLists.txt
  tools/lldb-server/CMakeLists.txt

Index: tools/lldb-server/CMakeLists.txt
===
--- tools/lldb-server/CMakeLists.txt
+++ tools/lldb-server/CMakeLists.txt
@@ -42,7 +42,7 @@
   list(APPEND LLDB_PLUGINS lldbPluginObjectFileELF)
 endif()
 
-add_lldb_tool(lldb-server INCLUDE_IN_SUITE
+add_lldb_tool(lldb-server
 Acceptor.cpp
 lldb-gdbserver.cpp
 lldb-platform.cpp
Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -19,7 +19,6 @@
 endif()
 
 add_dependencies(lldb
-  ${LLDB_SUITE_TARGET}
   LLDBOptionsTableGen
   ${tablegen_deps}
 )
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -240,7 +240,7 @@
  COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
   endif()
   set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
-  add_lldb_tool(debugserver INCLUDE_IN_SUITE
+  add_lldb_tool(debugserver
 debugserver.cpp
 
 LINK_LIBS
Index: tools/debugserver/CMakeLists.txt
===
--- tools/debugserver/CMakeLists.txt
+++ tools/debugserver/CMakeLists.txt
@@ -15,11 +15,6 @@
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
-
-  # lldb-suite is a dummy target that encompasses all the necessary tools and
-  # libraries for building a fully-functioning liblldb.
-  add_custom_target(lldb-suite)
-  set(LLDB_SUITE_TARGET lldb-suite)
 endif()
 
 add_subdirectory(source)
Index: tools/darwin-debug/CMakeLists.txt
===
--- tools/darwin-debug/CMakeLists.txt
+++ tools/darwin-debug/CMakeLists.txt
@@ -1,3 +1,3 @@
-add_lldb_tool(darwin-debug INCLUDE_IN_SUITE
+add_lldb_tool(darwin-debug
   darwin-debug.cpp
   )
Index: tools/argdumper/CMakeLists.txt
===
--- tools/argdumper/CMakeLists.txt
+++ tools/argdumper/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_lldb_tool(lldb-argdumper INCLUDE_IN_SUITE
+add_lldb_tool(lldb-argdumper
   argdumper.cpp
 
   LINK_LIBS
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -79,7 +79,13 @@
 endif()
 
 if(LLDB_BUILD_FRAMEWORK)
-  list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLDB_FRAMEWORK_DIR}/LLDB.framework)
+  # The $ generator expression
+  # provides this value, but LLDB_DOTEST_ARGS needs it at configuration-time.
+  get_filename_component(
+framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
+BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}
+  )
+  list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_target_dir}/LLDB.framework)
 endif()
 
 if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
Index: source/API/CMakeLists.txt
===
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -92,24 +92,25 @@
 Support
   )
 
-add_dependencies(lldb-suite liblldb)
+if(LLDB_WRAP_PYTHON)
+  add_dependencies(liblldb swig_wrapper)
 
-if (MSVC)
-  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
-else()
-  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
-endif()
+  if (MSVC)
+set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
+  else()
+set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
+  endif()
 
-set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
-if (CLANG_CL)
-  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
-PROPERTY COMPILE_FLAGS " -Wno-unused-function")
+  if (CLANG_CL)
+set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+  PROPERTY COMPILE_FLAGS " -Wno-unused-function")
+  endif()
+  if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
+  NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
+set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+  PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
+  endif ()
 endif()
-if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
-NOT "${CMAKE_SYSTEM_

[Lldb-commits] [PATCH] D55330: [CMake] Revised RPATH handling

2018-12-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM with the question answered/addressed. Thanks Stefan, these patches are 
really great work!




Comment at: tools/driver/CMakeLists.txt:27
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_setup_rpaths_framework(lldb)
+endif()

Would it make sense/work to do the check inside this function?


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

https://reviews.llvm.org/D55330



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


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked an inline comment as done.
sgraenitz added inline comments.



Comment at: cmake/modules/LLDBConfig.cmake:64
+  set(LLVM_CODESIGNING_IDENTITY lldb_codesign CACHE STRING "" FORCE)
+endif()
+

@labath Could this be a way to phase out LLDB_CODESIGN_IDENTITY and move to the 
LLVM one?

* An **explicitly set** LLDB value takes precedence
* Warn if a non-empty LLVM value is overwritten
* Default to lldb_codesign if none is set explicitly


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

https://reviews.llvm.org/D55328



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


[Lldb-commits] [PATCH] D55434: ObjectFileBreakpad: Implement sections

2018-12-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Another point of clarification is that sections exist in order to lookup 
addresses and resolve addresses to a section within a file. The section should 
be something that can easily be slid around when loaded by LLDB when we are 
debugging or symbolicating. So any sections we create should be able to be have 
the section load address set in the target with code like:

  if (target.GetSectionLoadList().SetSectionLoadAddress(section_sp, 
section_sp->GetFileAddress() + slide))

All of the sections you added, except the FUNC section, wouldn't end up ever 
being loaded. All items besides FUNC might be better represented as symbols.


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

https://reviews.llvm.org/D55434



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


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked an inline comment as done.
sgraenitz added inline comments.



Comment at: cmake/modules/LLDBConfig.cmake:64
+  set(LLVM_CODESIGNING_IDENTITY lldb_codesign CACHE STRING "" FORCE)
+endif()
+

sgraenitz wrote:
> @labath Could this be a way to phase out LLDB_CODESIGN_IDENTITY and move to 
> the LLVM one?
> 
> * An **explicitly set** LLDB value takes precedence
> * Warn if a non-empty LLVM value is overwritten
> * Default to lldb_codesign if none is set explicitly
Not sure if it is too intrusive.


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

https://reviews.llvm.org/D55328



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


[Lldb-commits] [PATCH] D55384: [NativePDB] Reconstruct FunctionDecl AST nodes from PDB debug info

2018-12-07 Thread Zachary Turner via Phabricator via lldb-commits
zturner updated this revision to Diff 177243.
zturner added a comment.

Add some comments regarding fixing `DeclContext` reconstruction.


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

https://reviews.llvm.org/D55384

Files:
  lldb/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit
  lldb/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit
  lldb/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
  lldb/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp
  lldb/lit/SymbolFile/NativePDB/ast-functions.cpp
  lldb/lit/SymbolFile/NativePDB/ast-reconstruction.cpp
  lldb/lit/SymbolFile/NativePDB/ast-types.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
  llvm/include/llvm/Support/BinaryStreamArray.h
  llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp

Index: llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
===
--- llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
+++ llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
@@ -50,4 +50,15 @@
 assert(false && "Unknown record type");
 return 0;
   }
-}
\ No newline at end of file
+}
+
+CVSymbolArray
+llvm::codeview::limitSymbolArrayToScope(const CVSymbolArray &Symbols,
+uint32_t ScopeBegin) {
+  CVSymbol Opener = *Symbols.at(ScopeBegin);
+  assert(symbolOpensScope(Opener.kind()));
+  uint32_t EndOffset = getScopeEndOffset(Opener);
+  CVSymbol Closer = *Symbols.at(EndOffset);
+  EndOffset += Closer.RecordData.size();
+  return Symbols.substream(ScopeBegin, EndOffset);
+}
Index: llvm/include/llvm/Support/BinaryStreamArray.h
===
--- llvm/include/llvm/Support/BinaryStreamArray.h
+++ llvm/include/llvm/Support/BinaryStreamArray.h
@@ -113,6 +113,15 @@
 
   bool empty() const { return Stream.getLength() == 0; }
 
+  VarStreamArray substream(uint32_t Begin,
+ uint32_t End) const {
+assert(Begin >= Skew);
+// We should never cut off the beginning of the stream since it might be
+// skewed, meaning the initial bytes are important.
+BinaryStreamRef NewStream = Stream.slice(0, End);
+return {NewStream, E, Begin};
+  }
+
   /// given an offset into the array's underlying stream, return an
   /// iterator to the record at that offset.  This is considered unsafe
   /// since the behavior is undefined if \p Offset does not refer to the
Index: llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
===
--- llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
+++ llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
@@ -50,7 +50,11 @@
 
 /// Given a symbol P for which symbolOpensScope(P) == true, return the
 /// corresponding end offset.
-uint32_t getScopeEndOffset(const CVSymbol &symbol);
+uint32_t getScopeEndOffset(const CVSymbol &Symbol);
+
+CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols,
+  uint32_t ScopeBegin);
+
 } // namespace codeview
 } // namespace llvm
 
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
===
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -112,6 +112,8 @@
   size_t ParseVariablesForContext(const SymbolContext &sc) override {
 return 0;
   }
+
+  CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override;
   Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
   llvm::Optional GetDynamicArrayInfoForUID(
   lldb::user_id_t type_uid,
@@ -217,7 +219,7 @@
 
   llvm::DenseMap m_decl_to_status;
 
-  llvm::DenseMap m_uid_to_decl;
+  llvm::DenseMap m_uid_to_decl;
   llvm::DenseMap
   m_parent_types;
 
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -37,6 +37,7 @@
 #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
 #include "llvm/DebugInfo/CodeView/RecordName.h"
 #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
 #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
@@ -538,16 +539,114 @@
   if (!func_range.GetBaseAddress().IsValid())
 return nullptr;
 
-  Type *func_type = nullptr;
+  ProcSym proc(static_cast(sym_record.kind()));
+  cantFail(SymbolDeserializer::deserializeAs(sym_record, proc));
+  TypeSP f

[Lldb-commits] [PATCH] D55384: [NativePDB] Reconstruct FunctionDecl AST nodes from PDB debug info

2018-12-07 Thread Zachary Turner via Phabricator via lldb-commits
zturner marked 2 inline comments as done.
zturner added a comment.

In D55384#1322702 , @labath wrote:

> In D55384#1321970 , @zturner wrote:
>
> > Clang-cl emits `S_LOCAL` symbols while MSVC emits `S_REGREL32` and 
> > `S_REGISTER` symbols.  So, to get more test coverage, I added an MSVC test 
> > as well.
>
>
> I don't want to block this patch, but my thoughts after reading this is that 
> this is repeating the same mistakes that we did with dwarf. The reason we 
> need so much to run our tests in so many configurations is that we haven't 
> found a way way to handle the fact that some things can be expressed in 
> multiple ways in the debug info other than compiling the source code with the 
> compiler which happens to use that dialect. Then, if a later e.g. clang 
> chooses to do the same thing that msvc does, we lose coverage here without 
> anyone noticing. For low-level details like these, I believe a test where the 
> type of the symbol is explicit would be more appropriate (for dwarf that 
> might be a .s file, I don't know if that would work for pdbs).


I considered this, and we actually have a test that does (see `s_constant.s`).  
The reason I didn't do it here because my experience writing `s_constant.s` 
taught me just how difficult it is to write these assembly files.

However, now I have a new idea.  We can teach `llvm-pdbutil` to dump its output 
exactly in llvm assembly format, so the output can just be copy-pasted into a 
.s file.  Then, we can build something with MSVC, dump it to .s format, and 
paste individual records into a test and mix and match them as necessary to 
create all the interesting cases.

For the purposes of this test, we don't even need to run the program, so it 
actually doesn't even matter if the addresses in the debug info records are 
correct.  All we care about is that the AST is reconstructed correctly.  I'll 
add this to my todo list because I think it would be a really useful feature.




Comment at: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp:577
+
+  clang::DeclContext *decl_context = m_clang->GetTranslationUnitDecl();
+  clang::FunctionDecl *function_decl = m_clang->CreateFunctionDeclaration(

aleksandr.urakov wrote:
> May be it would be worth to leave a TODO here (about searching a correct 
> declaration context in the future)?
Let me know how the new diff looks.


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

https://reviews.llvm.org/D55384



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


[Lldb-commits] [PATCH] D55384: [NativePDB] Reconstruct FunctionDecl AST nodes from PDB debug info

2018-12-07 Thread Zachary Turner via Phabricator via lldb-commits
zturner updated this revision to Diff 177244.
zturner marked an inline comment as done.
zturner added a comment.

Removed accidentally added function.


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

https://reviews.llvm.org/D55384

Files:
  lldb/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit
  lldb/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit
  lldb/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
  lldb/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp
  lldb/lit/SymbolFile/NativePDB/ast-functions.cpp
  lldb/lit/SymbolFile/NativePDB/ast-reconstruction.cpp
  lldb/lit/SymbolFile/NativePDB/ast-types.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
  llvm/include/llvm/Support/BinaryStreamArray.h
  llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp

Index: llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
===
--- llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
+++ llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
@@ -50,4 +50,15 @@
 assert(false && "Unknown record type");
 return 0;
   }
-}
\ No newline at end of file
+}
+
+CVSymbolArray
+llvm::codeview::limitSymbolArrayToScope(const CVSymbolArray &Symbols,
+uint32_t ScopeBegin) {
+  CVSymbol Opener = *Symbols.at(ScopeBegin);
+  assert(symbolOpensScope(Opener.kind()));
+  uint32_t EndOffset = getScopeEndOffset(Opener);
+  CVSymbol Closer = *Symbols.at(EndOffset);
+  EndOffset += Closer.RecordData.size();
+  return Symbols.substream(ScopeBegin, EndOffset);
+}
Index: llvm/include/llvm/Support/BinaryStreamArray.h
===
--- llvm/include/llvm/Support/BinaryStreamArray.h
+++ llvm/include/llvm/Support/BinaryStreamArray.h
@@ -113,6 +113,15 @@
 
   bool empty() const { return Stream.getLength() == 0; }
 
+  VarStreamArray substream(uint32_t Begin,
+ uint32_t End) const {
+assert(Begin >= Skew);
+// We should never cut off the beginning of the stream since it might be
+// skewed, meaning the initial bytes are important.
+BinaryStreamRef NewStream = Stream.slice(0, End);
+return {NewStream, E, Begin};
+  }
+
   /// given an offset into the array's underlying stream, return an
   /// iterator to the record at that offset.  This is considered unsafe
   /// since the behavior is undefined if \p Offset does not refer to the
Index: llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
===
--- llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
+++ llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
@@ -50,7 +50,11 @@
 
 /// Given a symbol P for which symbolOpensScope(P) == true, return the
 /// corresponding end offset.
-uint32_t getScopeEndOffset(const CVSymbol &symbol);
+uint32_t getScopeEndOffset(const CVSymbol &Symbol);
+
+CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols,
+  uint32_t ScopeBegin);
+
 } // namespace codeview
 } // namespace llvm
 
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
===
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -112,6 +112,8 @@
   size_t ParseVariablesForContext(const SymbolContext &sc) override {
 return 0;
   }
+
+  CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override;
   Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
   llvm::Optional GetDynamicArrayInfoForUID(
   lldb::user_id_t type_uid,
@@ -217,7 +219,7 @@
 
   llvm::DenseMap m_decl_to_status;
 
-  llvm::DenseMap m_uid_to_decl;
+  llvm::DenseMap m_uid_to_decl;
   llvm::DenseMap
   m_parent_types;
 
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -37,6 +37,7 @@
 #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
 #include "llvm/DebugInfo/CodeView/RecordName.h"
 #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
 #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
@@ -538,16 +539,114 @@
   if (!func_range.GetBaseAddress().IsValid())
 return nullptr;
 
-  Type *func_type = nullptr;
+  ProcSym proc(static_cast(sym_record.kind()));
+  cantFail(SymbolDeserializer::deserializeAs(sym_record, proc)

[Lldb-commits] [PATCH] D55434: ObjectFileBreakpad: Implement sections

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I guess I should elaborate more on the direction where I am going with this. I 
am trying to model these breakpad files as a debug-info-only object file, like 
something you would get by running say `strip --only-keep-debug`. This object 
file will contain a bunch of sections, but none of them will be real loadable 
sections. They will basically just be containers for data (DWARF, most likely). 
Like the `.debug_***` sections, my sections also have vm_size set to 0, so 
there no notion of them being in memory or being slid around. The idea is that 
this file will never be used as the **main** object file for a module (*), but 
rather an object file that a symbol vendor uses to add symbol information to 
the module.

I have a follow-up patch to this (not yet ready for upload), where I create a 
SymbolFileBreakpad, which takes the "PUBLIC" and "FUNC" sections and uses them 
to add symbols into the symtab of the main object file using the interface we 
added for SymbolFilePDB (while doing that, I lookup these addresses in the main 
object file and resolve them to real sections (.text, etc.).  Then, another 
part of that plugin would take the line information from the "FUNC" section, 
and convert that into a `lldb_private::LineTable` structure. So, basically the 
real action will happen in the SymbolFile plugin, and this ObjectFile is there 
just as a fancy container for the data.

(*) I am deliberately not handling the scenario where we have the main 
ObjectFile missing. We need to be able to handle the case when we cannot find 
the main object file regardless of whether we have the breakpad file around or 
not (and ProcessMinidump kind of does that right now, but I believe that should 
be generalized), so I am planning to have breakpad  just piggy-back on that. 
Then if we have a real object file, we can get accurate section information 
from there. If not, then all of our symbols will resolve to some fake section 
encompassing the whole module.

Does this approach make sense?


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

https://reviews.llvm.org/D55434



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


[Lldb-commits] [PATCH] D55384: [NativePDB] Reconstruct FunctionDecl AST nodes from PDB debug info

2018-12-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov accepted this revision.
aleksandr.urakov added a comment.

Now it looks more clear, thanks!


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

https://reviews.llvm.org/D55384



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


[Lldb-commits] [PATCH] D55317: [CMake] Aggregate options for LLDB in LLDBConfig.cmake

2018-12-07 Thread Alex Langford via Phabricator via lldb-commits
xiaobai accepted this revision.
xiaobai added a comment.

Definitely much easier to read. Thanks for taking care of this! :)


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

https://reviews.llvm.org/D55317



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


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2018-12-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: cmake/modules/LLDBConfig.cmake:64
+  set(LLVM_CODESIGNING_IDENTITY lldb_codesign CACHE STRING "" FORCE)
+endif()
+

sgraenitz wrote:
> sgraenitz wrote:
> > @labath Could this be a way to phase out LLDB_CODESIGN_IDENTITY and move to 
> > the LLVM one?
> > 
> > * An **explicitly set** LLDB value takes precedence
> > * Warn if a non-empty LLVM value is overwritten
> > * Default to lldb_codesign if none is set explicitly
> Not sure if it is too intrusive.
You say "phase out", but it's not clear to me how would that happen. What would 
be the next step here? I don't think llvm will ever get `lldb_codesign` as the 
default value for LLVM_CODESIGN_IDENTITY.

Given that we seem to have two parts of the project with different default 
policies on code signing, I think the cleanest approach would be to have code 
signing identity overridable on a per-call basis.

You might not even need to modify `add_llvm_executable` for this to work. I 
think you might be able to just locally do `set(LLVM_CODESIGN_IDENTITY 
${LLDB_CODESIGN_IDENTITY})` in the scope of `add_lldb_executable` and the 
signing code should pick that up instead of the cache variable (the cmake scope 
rules always confuse me, but I think this how it works).


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

https://reviews.llvm.org/D55328



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


Re: [Lldb-commits] [lldb] r348592 - Introduce ObjectFileBreakpad

2018-12-07 Thread Davide Italiano via lldb-commits
Pavel, this broke the MacOS lldb cmake bot.

In particular, this test started failing.
lldb-Suite.macosx/function-starts.TestFunctionStarts.py
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/

May I ask you to take a look?

--
Davide
On Fri, Dec 7, 2018 at 6:23 AM Pavel Labath via lldb-commits
 wrote:
>
> Author: labath
> Date: Fri Dec  7 06:20:27 2018
> New Revision: 348592
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348592&view=rev
> Log:
> Introduce ObjectFileBreakpad
>
> Summary:
> This patch adds the scaffolding necessary for lldb to recognise symbol
> files generated by breakpad. These (textual) files contain just enough
> information to be able to produce a backtrace from a crash
> dump. This information includes:
> - UUID, architecture and name of the module
> - line tables
> - list of symbols
> - unwind information
>
> A minimal breakpad file could look like this:
> MODULE Linux x86_64 24B5D199F0F766FF5DC30 a.out
> INFO CODE_ID B52499D1F0F766FF5DC3
> FILE 0 /tmp/a.c
> FUNC 1010 10 0 _start
> 1010 4 4 0
> 1014 5 5 0
> 1019 5 6 0
> 101e 2 7 0
> PUBLIC 1010 0 _start
> STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
> STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
> STACK CFI 1014 .cfa: $rbp 16 +
>
> Even though this data would normally be considered "symbol" information,
> in the current lldb infrastructure it is assumed every SymbolFile object
> is backed by an ObjectFile instance. So, in order to better interoperate
> with the rest of the code (particularly symbol vendors).
>
> In this patch I just parse the breakpad header, which is enough to
> populate the UUID and architecture fields of the ObjectFile interface.
> The rough plan for followup patches is to expose the individual parts of
> the breakpad file as ObjectFile "sections", which can then be used by
> other parts of the codebase (SymbolFileBreakpad ?) to vend the necessary
> information.
>
> Reviewers: clayborg, zturner, lemo, amccarth
>
> Subscribers: mgorny, fedor.sergeev, markmentovai, lldb-commits
>
> Differential Revision: https://reviews.llvm.org/D55214
>
> Added:
> lldb/trunk/lit/Modules/Breakpad/
> lldb/trunk/lit/Modules/Breakpad/Inputs/
> lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
> lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
> lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
> lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms
> lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms
> lldb/trunk/lit/Modules/Breakpad/Inputs/identification-windows.syms
> lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
> lldb/trunk/lit/Modules/Breakpad/lit.local.cfg
> lldb/trunk/source/Plugins/ObjectFile/Breakpad/
> lldb/trunk/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
> lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
> lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
> Modified:
> lldb/trunk/include/lldb/Symbol/ObjectFile.h
> lldb/trunk/source/API/SystemInitializerFull.cpp
> lldb/trunk/source/Plugins/ObjectFile/CMakeLists.txt
> lldb/trunk/source/Symbol/ObjectFile.cpp
> lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
> lldb/trunk/tools/lldb-test/lldb-test.cpp
>
> Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=348592&r1=348591&r2=348592&view=diff
> ==
> --- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
> +++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Dec  7 06:20:27 2018
> @@ -817,4 +817,16 @@ private:
>
>  } // namespace lldb_private
>
> +namespace llvm {
> +template <> struct format_provider {
> +  static void format(const lldb_private::ObjectFile::Type &type,
> + raw_ostream &OS, StringRef Style);
> +};
> +
> +template <> struct format_provider {
> +  static void format(const lldb_private::ObjectFile::Strata &strata,
> + raw_ostream &OS, StringRef Style);
> +};
> +} // namespace llvm
> +
>  #endif // liblldb_ObjectFile_h_
>
> Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms?rev=348592&view=auto
> ==
> --- lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms (added)
> +++ lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms Fri Dec  7 
> 06:20:27 2018
> @@ -0,0 +1,2 @@
> +MODULE Linux x86_64 E5894855+C35D+0 linux.out
> +PUBLIC 1000 0 _start
>
> Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms?rev=348592&view=auto
>

[Lldb-commits] [PATCH] D55330: [CMake] Revised RPATH handling

2018-12-07 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a comment.

Looks good to me overall. You also probably probably also invoke 
`lldb_setup_rpaths_framework` for the tools included in the framework 
(argdumper, darwin-debug, debugserver, lldb-server).


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

https://reviews.llvm.org/D55330



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


Re: [Lldb-commits] [lldb] r348592 - Introduce ObjectFileBreakpad

2018-12-07 Thread Pavel Labath via lldb-commits

On 07/12/2018 19:39, Davide Italiano wrote:

Pavel, this broke the MacOS lldb cmake bot.

In particular, this test started failing.
lldb-Suite.macosx/function-starts.TestFunctionStarts.py
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/

May I ask you to take a look?


That's interesting. I can't look at it right now. Could you please 
revert that for me, and I'll check it out later?

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


[Lldb-commits] [lldb] r348629 - Revert "Introduce ObjectFileBreakpad"

2018-12-07 Thread Shafik Yaghmour via lldb-commits
Author: shafik
Date: Fri Dec  7 10:59:00 2018
New Revision: 348629

URL: http://llvm.org/viewvc/llvm-project?rev=348629&view=rev
Log:
Revert "Introduce ObjectFileBreakpad"

This reverts commit 5e056e624cc57bb22a4c29a70b522783c6242293.

Reverting because this lldb cmake bot: 
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/13712/

Removed:
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-windows.syms
lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
lldb/trunk/lit/Modules/Breakpad/lit.local.cfg
lldb/trunk/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
Modified:
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Plugins/ObjectFile/CMakeLists.txt
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=348629&r1=348628&r2=348629&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Dec  7 10:59:00 2018
@@ -817,16 +817,4 @@ private:
 
 } // namespace lldb_private
 
-namespace llvm {
-template <> struct format_provider {
-  static void format(const lldb_private::ObjectFile::Type &type,
- raw_ostream &OS, StringRef Style);
-};
-
-template <> struct format_provider {
-  static void format(const lldb_private::ObjectFile::Strata &strata,
- raw_ostream &OS, StringRef Style);
-};
-} // namespace llvm
-
 #endif // liblldb_ObjectFile_h_

Removed: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms?rev=348628&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms (original)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms (removed)
@@ -1,2 +0,0 @@
-MODULE Linux x86_64 E5894855+C35D+0 linux.out
-PUBLIC 1000 0 _start

Removed: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms?rev=348628&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms (original)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms (removed)
@@ -1,2 +0,0 @@
-MODULE Linux x86_64 E5894855C35DC linux.out
-PUBLIC 1000 0 _start

Removed: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms?rev=348628&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms (original)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms (removed)
@@ -1,2 +0,0 @@
-MODULE Linux x86_64 E58X4855C35DXCCC0 linux.out
-PUBLIC 1000 0 _start

Removed: lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms?rev=348628&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms (original)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms (removed)
@@ -1,6 +0,0 @@
-MODULE Linux x86_64 E5894855C35D0 linux.out
-INFO CODE_ID 554889E55DC3
-PUBLIC 1000 0 _start
-STACK CFI INIT 1000 6 .cfa: $rsp 8 + .ra: .cfa -8 + ^
-STACK CFI 1001 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
-STACK CFI 1004 .cfa: $rbp 16 +

Removed: lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms?rev=348628&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms (original)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms (removed)
@@

Re: [Lldb-commits] [lldb] r348592 - Introduce ObjectFileBreakpad

2018-12-07 Thread Shafik Yaghmour via lldb-commits
Pavel,

I just reverted it.

-Shafik

> On Dec 7, 2018, at 10:46 AM, Pavel Labath via lldb-commits 
>  wrote:
> 
> On 07/12/2018 19:39, Davide Italiano wrote:
>> Pavel, this broke the MacOS lldb cmake bot.
>> In particular, this test started failing.
>> lldb-Suite.macosx/function-starts.TestFunctionStarts.py
>> http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/
>> May I ask you to take a look?
> 
> That's interesting. I can't look at it right now. Could you please revert 
> that for me, and I'll check it out later?
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [PATCH] D55384: [NativePDB] Reconstruct FunctionDecl AST nodes from PDB debug info

2018-12-07 Thread Zachary Turner via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348631: [NativePDB] Reconstruct function declarations from 
debug info. (authored by zturner, committed by ).
Herald added subscribers: llvm-commits, kristina.

Changed prior to commit:
  https://reviews.llvm.org/D55384?vs=177244&id=177264#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55384

Files:
  lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit
  lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit
  lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
  lldb/trunk/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp
  lldb/trunk/lit/SymbolFile/NativePDB/ast-functions.cpp
  lldb/trunk/lit/SymbolFile/NativePDB/ast-reconstruction.cpp
  lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
  llvm/trunk/include/llvm/Support/BinaryStreamArray.h
  llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp

Index: llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
===
--- llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
+++ llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
@@ -50,4 +50,15 @@
 assert(false && "Unknown record type");
 return 0;
   }
-}
\ No newline at end of file
+}
+
+CVSymbolArray
+llvm::codeview::limitSymbolArrayToScope(const CVSymbolArray &Symbols,
+uint32_t ScopeBegin) {
+  CVSymbol Opener = *Symbols.at(ScopeBegin);
+  assert(symbolOpensScope(Opener.kind()));
+  uint32_t EndOffset = getScopeEndOffset(Opener);
+  CVSymbol Closer = *Symbols.at(EndOffset);
+  EndOffset += Closer.RecordData.size();
+  return Symbols.substream(ScopeBegin, EndOffset);
+}
Index: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
===
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
@@ -50,7 +50,11 @@
 
 /// Given a symbol P for which symbolOpensScope(P) == true, return the
 /// corresponding end offset.
-uint32_t getScopeEndOffset(const CVSymbol &symbol);
+uint32_t getScopeEndOffset(const CVSymbol &Symbol);
+
+CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols,
+  uint32_t ScopeBegin);
+
 } // namespace codeview
 } // namespace llvm
 
Index: llvm/trunk/include/llvm/Support/BinaryStreamArray.h
===
--- llvm/trunk/include/llvm/Support/BinaryStreamArray.h
+++ llvm/trunk/include/llvm/Support/BinaryStreamArray.h
@@ -113,6 +113,15 @@
 
   bool empty() const { return Stream.getLength() == 0; }
 
+  VarStreamArray substream(uint32_t Begin,
+ uint32_t End) const {
+assert(Begin >= Skew);
+// We should never cut off the beginning of the stream since it might be
+// skewed, meaning the initial bytes are important.
+BinaryStreamRef NewStream = Stream.slice(0, End);
+return {NewStream, E, Begin};
+  }
+
   /// given an offset into the array's underlying stream, return an
   /// iterator to the record at that offset.  This is considered unsafe
   /// since the behavior is undefined if \p Offset does not refer to the
Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -112,6 +112,8 @@
   size_t ParseVariablesForContext(const SymbolContext &sc) override {
 return 0;
   }
+
+  CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override;
   Type *ResolveTypeUID(lldb::user_id_t type_uid) override;
   llvm::Optional GetDynamicArrayInfoForUID(
   lldb::user_id_t type_uid,
@@ -217,7 +219,7 @@
 
   llvm::DenseMap m_decl_to_status;
 
-  llvm::DenseMap m_uid_to_decl;
+  llvm::DenseMap m_uid_to_decl;
   llvm::DenseMap
   m_parent_types;
 
Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -37,6 +37,7 @@
 #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
 #include "llvm/DebugInfo/CodeView/RecordName.h"
 #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
 #include "llvm/DebugInf

[Lldb-commits] [lldb] r348631 - [NativePDB] Reconstruct function declarations from debug info.

2018-12-07 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Fri Dec  7 11:34:02 2018
New Revision: 348631

URL: http://llvm.org/viewvc/llvm-project?rev=348631&view=rev
Log:
[NativePDB] Reconstruct function declarations from debug info.

Previously we would create an lldb::Function object for each function
parsed, but we would not add these to the clang AST. This is a first
step towards getting local variable support working, as we first need an
AST decl so that when we create local variable entries, they have the
proper DeclContext.

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

Added:
lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit
lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
lldb/trunk/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp
lldb/trunk/lit/SymbolFile/NativePDB/ast-functions.cpp
lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp
Removed:
lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit
lldb/trunk/lit/SymbolFile/NativePDB/ast-reconstruction.cpp
Modified:
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Added: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit?rev=348631&view=auto
==
--- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit (added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit Fri Dec  
7 11:34:02 2018
@@ -0,0 +1,8 @@
+
+break set -n main
+break set -n static_fn
+break set -n varargs_fn
+
+target modules dump ast
+
+quit

Removed: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit?rev=348630&view=auto
==
--- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit 
(original)
+++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit 
(removed)
@@ -1,20 +0,0 @@
-target variable TC
-target variable TS
-target variable TU
-target variable TE
-
-target variable ABCInt
-target variable ABCFloat
-target variable ABCVoid
-
-target variable AC0
-target variable ACNeg1
-
-target variable AC0D
-target variable ACNeg1D
-target variable AD
-target variable ADE
-
-target modules dump ast
-
-quit

Added: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit?rev=348631&view=auto
==
--- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit (added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit Fri Dec  7 
11:34:02 2018
@@ -0,0 +1,20 @@
+target variable TC
+target variable TS
+target variable TU
+target variable TE
+
+target variable ABCInt
+target variable ABCFloat
+target variable ABCVoid
+
+target variable AC0
+target variable ACNeg1
+
+target variable AC0D
+target variable ACNeg1D
+target variable AD
+target variable ADE
+
+target modules dump ast
+
+quit

Added: lldb/trunk/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp?rev=348631&view=auto
==
--- lldb/trunk/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp (added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp Fri Dec  7 
11:34:02 2018
@@ -0,0 +1,7 @@
+// clang-format off
+// REQUIRES: msvc
+
+// RUN: %build --compiler=msvc --nodefaultlib -o %t.exe -- %S/ast-functions.cpp
+
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
+// RUN: %p/Inputs/ast-functions.lldbinit 2>&1 | FileCheck 
%S/ast-functions.cpp

Added: lldb/trunk/lit/SymbolFile/NativePDB/ast-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/ast-functions.cpp?rev=348631&view=auto
==
--- lldb/trunk/lit/SymbolFile/NativePDB/ast-functions.cpp (added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/ast-functions.cpp Fri Dec  7 11:34:02 
2018
@@ -0,0 +1,29 @@
+// clang-format off
+// REQUIRES: lld
+
+// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s
+
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
+// RUN: %p/Inputs/ast-functions.lldbinit 2>&1 | FileCheck %s
+
+static int static_fn() {
+  return 42;
+}
+
+int varargs_fn(int x, int y, ...) {
+  return x + y;
+}
+
+int main(int argc, char **argv) {
+  return static_fn() + varargs_fn(argc, argc);
+}
+
+// CHECK:  TranslationUnitDecl
+// CHECK-NEXT: |-FunctionDecl 

[Lldb-commits] [PATCH] D55457: Do not use PATH_MAX with SmallString

2018-12-07 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova created this revision.
stella.stamenova added reviewers: labath, asmith.
Herald added a subscriber: lldb-commits.

Instead use a more reasonable value to start and rely on the fact that 
SmallString will resize if necessary.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D55457

Files:
  source/Commands/CommandCompletions.cpp
  source/Commands/CommandObjectPlatform.cpp
  source/Host/common/Host.cpp
  source/Host/posix/PipePosix.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  source/Target/ProcessInfo.cpp

Index: source/Target/ProcessInfo.cpp
===
--- source/Target/ProcessInfo.cpp
+++ source/Target/ProcessInfo.cpp
@@ -63,7 +63,7 @@
   if (exe_file) {
 m_executable = exe_file;
 if (add_exe_file_as_first_arg) {
-  llvm::SmallString filename;
+  llvm::SmallString<128> filename;
   exe_file.GetPath(filename);
   if (!filename.empty())
 m_arguments.InsertArgumentAtIndex(0, filename);
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
===
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -538,8 +538,8 @@
 
 FileSpec
 GDBRemoteCommunicationServerPlatform::GetDomainSocketPath(const char *prefix) {
-  llvm::SmallString socket_path;
-  llvm::SmallString socket_name(
+  llvm::SmallString<128> socket_path;
+  llvm::SmallString<128> socket_name(
   (llvm::StringRef(prefix) + ".%%").str());
 
   FileSpec socket_path_spec(GetDomainSocketDir());
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1011,7 +1011,7 @@
   debugserver_args.AppendArgument(llvm::StringRef("--setsid"));
 }
 
-llvm::SmallString named_pipe_path;
+llvm::SmallString<128> named_pipe_path;
 // socket_pipe is used by debug server to communicate back either
 // TCP port or domain socket name which it listens on.
 // The second purpose of the pipe to serve as a synchronization point -
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -889,7 +889,7 @@
 // At this moment we only have the base name of the DLL. The full path can
 // only be seen after the dynamic loading.  Our best guess is Try to get it
 // with the help of the object file's directory.
-llvm::SmallString dll_fullpath;
+llvm::SmallString<128> dll_fullpath;
 FileSpec dll_specs(dll_name);
 dll_specs.GetDirectory().SetString(m_file.GetDirectory().GetCString());
 
Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -832,7 +832,7 @@
 
   if (should_create_file) {
 int temp_fd = -1;
-llvm::SmallString result_path;
+llvm::SmallString<128> result_path;
 if (FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir()) {
   tmpdir_file_spec.AppendPathComponent("lldb-%%.expr");
   std::string temp_source_path = tmpdir_file_spec.GetPath();
Index: source/Host/posix/PipePosix.cpp
===
--- source/Host/posix/PipePosix.cpp
+++ source/Host/posix/PipePosix.cpp
@@ -125,8 +125,8 @@
 Status PipePosix::CreateWithUniqueName(llvm::StringRef prefix,
bool child_process_inherit,
llvm::SmallVectorImpl &name) {
-  llvm::SmallString named_pipe_path;
-  llvm::SmallString pipe_spec((prefix + ".%%").str());
+  llvm::SmallString<128> named_pipe_path;
+  llvm::SmallString<128> pipe_spec((prefix + ".%%").str());
   FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir();
   if (!tmpdir_file_spec)
 tmpdir_file_spec.AppendPathComponent("/tmp");
Index: source/Host/common/Host.cpp
===
--- source/Host/common/Host.cpp
+++ source/Host/common/Host.cpp
@@ -496,7 +496,7 @@
 
   if (working_dir)
 launch_info.SetWorkingDirectory(working_dir);
-  llvm::SmallString output_file_path;
+  llvm::SmallString<64> output_file_path;
 
   if (command_output_ptr) {
 // Create a 

[Lldb-commits] [PATCH] D55434: ObjectFileBreakpad: Implement sections

2018-12-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

So we do something like you describe with the DYSM files. The object file is 
"a.out" and it has a dSYM file "a.out.dSYM/Context/Resources/DWARF/a.out" and 
the dSYM file will share sections with the "a.out" object file. So if you plan 
on loading the breakpad file as a symbol file that just needs some sections 
that it can give to the debug info it will eventually create, these sections 
must be the same between the binary and the breakpad object file. So I would 
still recommend trying to make sections that make sense like a real object 
file. It is also nice to be able to live off of the breakpad file itself. In 
this case the ObjectFile for breakpad when it is stand alone should do as good 
of a job as possible.


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

https://reviews.llvm.org/D55434



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


[Lldb-commits] [PATCH] D55434: ObjectFileBreakpad: Implement sections

2018-12-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

If you plan on not making the breakpad file ever stand alone, then you will 
need to take any addresses and look them up in the module section list and use 
the other sections. I don't see why the breakpad file can't be stand alone 
though. It won't be as accurate, but it sure would be nice to be able to load a 
bunch of them into LLDB without needing to find the original executable and 
just symbolicate no?


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

https://reviews.llvm.org/D55434



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


[Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-07 Thread Leonard Mosescu via Phabricator via lldb-commits
lemo updated this revision to Diff 177329.
lemo marked 3 inline comments as done.
lemo added a comment.

Incorporating feedback + adding a test case


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

https://reviews.llvm.org/D55142

Files:
  lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp
  lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.dmp
  lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.lldbinit
  lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.pdb
  lit/Minidump/Windows/Sigsegv/sigsegv.test
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
  source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
  source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
  source/Plugins/SymbolFile/NativePDB/PdbIndex.h
  source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp

Index: source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -30,6 +30,7 @@
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/Variable.h"
 #include "lldb/Symbol/VariableList.h"
+#include "lldb/Utility/UUID.h"
 
 #include "llvm/DebugInfo/CodeView/CVRecord.h"
 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
@@ -102,33 +103,59 @@
 }
 
 static std::unique_ptr
-loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) {
-  // Try to find a matching PDB for an EXE.
+loadMatchingPDBFile(lldb_private::ObjectFile& obj_file,
+llvm::BumpPtrAllocator &allocator) {
   using namespace llvm::object;
-  auto expected_binary = createBinary(exe_path);
 
-  // If the file isn't a PE/COFF executable, fail.
-  if (!expected_binary) {
-llvm::consumeError(expected_binary.takeError());
-return nullptr;
-  }
-  OwningBinary binary = std::move(*expected_binary);
+  // Try to find a matching PDB for an EXE.
+  std::string pdb_file;
+  llvm::codeview::GUID guid;
 
-  auto *obj = llvm::dyn_cast(binary.getBinary());
-  if (!obj)
-return nullptr;
-  const llvm::codeview::DebugInfo *pdb_info = nullptr;
+  auto expected_binary = createBinary(obj_file.GetFileSpec().GetPath());
+  if (expected_binary) {
+OwningBinary binary = std::move(*expected_binary);
 
-  // If it doesn't have a debug directory, fail.
-  llvm::StringRef pdb_file;
-  auto ec = obj->getDebugPDBInfo(pdb_info, pdb_file);
-  if (ec)
-return nullptr;
+auto *obj = llvm::dyn_cast(binary.getBinary());
+if (!obj)
+  return nullptr;
+
+const llvm::codeview::DebugInfo *pdb_info = nullptr;
+llvm::StringRef pdb_file_name_ref;
+if (obj->getDebugPDBInfo(pdb_info, pdb_file_name_ref)) {
+  // If it doesn't have a debug directory, fail.
+  return nullptr;
+}
+pdb_file = pdb_file_name_ref;
+
+// Extract the debug GUID from the debug directory
+memcpy(&guid, pdb_info->PDB70.Signature, sizeof(guid));
+  } else {
+// If the file isn't a PE/COFF executable, look for the PDB in the
+// current directory. This provides a basic solution for debugging minidumps
+// although it's only a stop-gap (until we implement a SymbolVendor)
+//
+// TODO: Implement a SymbolVendor for PDBs.
+//
+llvm::consumeError(expected_binary.takeError());
+pdb_file = obj_file.GetFileSpec()
+   .GetFileNameStrippingExtension()
+   .GetStringRef()
+   .str();
+pdb_file += ".pdb";
+
+// Extract the debug GUID from the ObjectFile
+lldb_private::UUID uuid;
+obj_file.GetUUID(&uuid);
+auto uuid_bytes = uuid.GetBytes();
+if (uuid_bytes.size() != sizeof(guid) + 4) // CvRecordPdb70
+  return nullptr;
+memcpy(&guid, uuid_bytes.data(), sizeof(guid));
+  }
 
   // if the file doesn't exist, is not a pdb, or doesn't have a matching guid,
   // fail.
   llvm::file_magic magic;
-  ec = llvm::identify_magic(pdb_file, magic);
+  auto ec = llvm::identify_magic(pdb_file, magic);
   if (ec || magic != llvm::file_magic::pdb)
 return nullptr;
   std::unique_ptr pdb = loadPDBFile(pdb_file, allocator);
@@ -140,11 +167,11 @@
 llvm::consumeError(expected_info.takeError());
 return nullptr;
   }
-  llvm::codeview::GUID guid;
-  memcpy(&guid, pdb_info->PDB70.Signature, 16);
 
+  // TODO: we need to compare the age, in addition to the GUID
   if (expected_info->getGuid() != guid)
 return nullptr;
+
   return pdb;
 }
 
@@ -521,7 +548,7 @@
   if (!m_index) {
 // Lazily load and match the PDB file, but only do this once.
 std::unique_ptr file_up =
-loadMatchingPDBFile(m_obj_file->GetFileSpec().GetPath(), m_allocator);
+loadMatchingPDBFile(*m_obj_file, m_allocator);
 
 if (!file_up) {
   auto module_sp = m_obj_file->GetModule();
@@ -1459,11 +1486,10 @@

[Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-07 Thread Leonard Mosescu via Phabricator via lldb-commits
lemo added inline comments.



Comment at: source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp:171-174
+  // TODO: we need to compare the age, in addition to the GUID
   if (expected_info->getGuid() != guid)
 return nullptr;
+

labath wrote:
> Mainly out of curiosity, what's the complication here? The llvm interface 
> does not provide the means to retrieve the age?
Yes, the interface doesn't expose the age, although that's not not really the 
problem (the age is a detail - part of the generic "Debug ID")

We just need to make the handling of PE/COFF & VC UUIDs more consistent: right 
now most places expect a stripped version (just the GUID). This is wrong since 
a correct PDB match should take the age into account, but it's outside the 
scope of this change.


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

https://reviews.llvm.org/D55142



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


[Lldb-commits] [lldb] r348664 - [lit] Fix case-insensitive test

2018-12-07 Thread Stella Stamenova via lldb-commits
Author: stella.stamenova
Date: Fri Dec  7 15:30:38 2018
New Revision: 348664

URL: http://llvm.org/viewvc/llvm-project?rev=348664&view=rev
Log:
[lit] Fix case-insensitive test

The test still only passes when not run from VS because the previous patch did 
not remove the original build commands This also simplifies the build 
command by removing some defaults

Modified:
lldb/trunk/lit/Breakpoint/case-insensitive.test

Modified: lldb/trunk/lit/Breakpoint/case-insensitive.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/case-insensitive.test?rev=348664&r1=348663&r2=348664&view=diff
==
--- lldb/trunk/lit/Breakpoint/case-insensitive.test (original)
+++ lldb/trunk/lit/Breakpoint/case-insensitive.test Fri Dec  7 15:30:38 2018
@@ -1,9 +1,6 @@
 # REQUIRES: system-windows
 
-# RUN: %build --mode=compile-and-link --compiler=any 
%p/Inputs/case-sensitive.c --nodefaultlib -o %t
-# RUN: lldb-test breakpoints %t %s | FileCheck %s
-#
-# RUN: %clang %p/Inputs/case-sensitive.c -g -o %t
+# RUN: %build %p/Inputs/case-sensitive.c --nodefaultlib -o %t
 # RUN: lldb-test breakpoints %t %s | FileCheck %s
 
 breakpoint set -f case-sensitive.c -l 3


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


[Lldb-commits] [PATCH] D55383: Implement basic DidAttach for DynamicLoaderWindowsDYLD for use with ds2

2018-12-07 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

@zturner and I spoke about it before landing

@labath - correct. Dll loading needs handled. This was to upstream hello world 
functionality without DLLs. I need to figure out where and when to synchronize 
between ds2 and lldb for the `LOAD_DLL_DEBUG_EVENT`. I'll probably get to this 
early next week.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55383



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


[Lldb-commits] [PATCH] D55472: Speadup memory regions handling and cleanup related code

2018-12-07 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: clayborg.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, abidh.

- replace unnecessary shared pointers with unique pointers
- reserve space before filling a vector with 'push_back' in a loop to avoid 
muptiple allocations and memory fragmentation (except 
Process::GetMemoryRegions, it is not possible to know the size in advance here)
- override GetMemoryRegions for the ProcessMinidump:

Process::GetMemoryRegions fills the list of regions by calling 
GetMemoryRegionInfo until it returns an error. But ProcessMinidump 
implementation GetMemoryRegionInfo parses whole list every time and searches 
requested range there. Now GetMemoryRegions does this work just once.

- use move semantic where it is possible (and desirable)
- fix size_t -> uint32_t truncation
- add missing constness

I had to change API slightly, but believe these changes doesn't break existing 
code that uses this API.
Profiling a sipmle program I got nice results - execution of GetMemoryRegions 
function took just 0.01% of total time against 0.17% for unchanged version.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D55472

Files:
  include/lldb/API/SBMemoryRegionInfo.h
  include/lldb/API/SBMemoryRegionInfoList.h
  include/lldb/Target/Process.h
  include/lldb/lldb-forward.h
  source/API/SBMemoryRegionInfo.cpp
  source/API/SBMemoryRegionInfoList.cpp
  source/API/SBProcess.cpp
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.cpp
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -6030,7 +6030,7 @@
 }
 
 Status
-Process::GetMemoryRegions(std::vector ®ion_list) {
+Process::GetMemoryRegions(std::vector ®ion_list) {
 
   Status error;
 
@@ -6038,7 +6038,7 @@
 
   region_list.clear();
   do {
-lldb::MemoryRegionInfoSP region_info(new lldb_private::MemoryRegionInfo());
+lldb::MemoryRegionInfoUP region_info(new lldb_private::MemoryRegionInfo());
 error = GetMemoryRegionInfo(range_end, *region_info);
 // GetMemoryRegionInfo should only return an error if it is unimplemented.
 if (error.Fail()) {
@@ -6048,7 +6048,7 @@
 
 range_end = region_info->GetRange().GetRangeEnd();
 if (region_info->GetMapped() == MemoryRegionInfo::eYes) {
-  region_list.push_back(region_info);
+  region_list.push_back(std::move(region_info));
 }
   } while (range_end != LLDB_INVALID_ADDRESS);
 
Index: source/Plugins/Process/minidump/ProcessMinidump.h
===
--- source/Plugins/Process/minidump/ProcessMinidump.h
+++ source/Plugins/Process/minidump/ProcessMinidump.h
@@ -78,6 +78,9 @@
   Status GetMemoryRegionInfo(lldb::addr_t load_addr,
  MemoryRegionInfo &range_info) override;
 
+  Status
+  GetMemoryRegions(std::vector ®ion_list) override;
+
   bool GetProcessInfo(ProcessInstanceInfo &info) override;
 
   Status WillResume() override {
Index: source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -294,6 +294,12 @@
   return error;
 }
 
+Status ProcessMinidump::GetMemoryRegions(
+std::vector ®ion_list) {
+  region_list.clear();
+  return m_minidump_parser.GetMemoryRegions(region_list);
+}
+
 void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); }
 
 bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
Index: source/Plugins/Process/minidump/MinidumpTypes.cpp
===
--- source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -242,6 +242,8 @@
 return {};
 
   std::vector result;
+  result.reserve(header->num_of_entries);
+
   for (uint64_t i = 0; i < header->num_of_entries; ++i) {
 result.push_back(reinterpret_cast(
 data.data() + i * header->size_of_entry));
Index: source/Plugins/Process/minidump/MinidumpParser.h
===
--- source/Plugins/Process/minidump/MinidumpParser.h
+++ source/Plugins/Process/minidump/MinidumpParser.h
@@ -88,6 +88,8 @@
 
   llvm::Optional GetMemoryRegionInfo(lldb::addr_t);
 
+  Status GetMemoryRegions(std::vector ®ion_list);
+
   // Perform consistency checks and initialize internal data structures
   Status Initialize();
 
Index: source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- source/Plugins/Process/minidump/Min