[Lldb-commits] [PATCH] D66357: Fix GetDIEForDeclContext so it only returns entries matching the provided context

2019-08-17 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade added a comment.

In D66357#1633461 , @clayborg wrote:

> Needs a test, but looks good.


Sure, I agree. Though, it's not total clear to me how we could do that.

I imagined something like the following.

  TEST_F(DWARFASTParserClangTests,
 TestGetDIEForDeclContextReturnsOnlyMatchingEntries) {
auto ast = ClangASTContext(...);
auto ast_parser = DWARFASTParserClang(ast);
CompilerDeclContext decl1(nullptr, (void *)1LL);
CompilerDeclContext decl2(nullptr, (void *)2LL);
CompilerDeclContext decl3(nullptr, (void *)2LL);
CompilerDeclContext decl4(nullptr, (void *)3LL);
ast_parser->LinkDeclContextToDIE(decl1, DWARFDIE());
ast_parser->LinkDeclContextToDIE(decl2, DWARFDIE());
ast_parser->LinkDeclContextToDIE(decl3, DWARFDIE());
ast_parser->LinkDeclContextToDIE(decl4, DWARFDIE());
  
auto decl_ctx_die_list = ast_parser->GetDIEForDeclContext(decl2);
EXPECT_EQ(2u, decl_ctx_die_list.size());
EXPECT_EQ(decl2.GetOpaqueDeclContext(),
  decl_ctx_die_list[0].GetDeclContext().GetOpaqueDeclContext());
EXPECT_EQ(decl3.GetOpaqueDeclContext(),
  decl_ctx_die_list[1].GetDeclContext().GetOpaqueDeclContext());
  }

But DWARFASTParserClang::LinkDeclContextToDIE is protected. Do you have any 
ideas to overcome that?

Thanks!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66357



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


[Lldb-commits] [PATCH] D66370: [dotest] Add a dotest flag `--force-dwarf` to override the tested DWARF version.

2019-08-17 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

For DWARF >= 4 it also matters for testing whether one is using 
`-fdebug-types-section` or not.




Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:373
 
+
 if args.executable:

intentional?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D66370



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


[Lldb-commits] [lldb] r369198 - [lldb][NFC] Remove unused MaterializeInitializer and MaterializeInternalVariable

2019-08-17 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Sat Aug 17 14:57:51 2019
New Revision: 369198

URL: http://llvm.org/viewvc/llvm-project?rev=369198&view=rev
Log:
[lldb][NFC] Remove unused MaterializeInitializer and MaterializeInternalVariable

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=369198&r1=369197&r2=369198&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Sat Aug 17 
14:57:51 2019
@@ -1180,71 +1180,6 @@ bool IRForTarget::RewritePersistentAlloc
   return true;
 }
 
-bool IRForTarget::MaterializeInitializer(uint8_t *data, Constant *initializer) 
{
-  if (!initializer)
-return true;
-
-  lldb_private::Log *log(
-  lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
-  LLDB_LOGV(log, "  MaterializeInitializer({0}, {1})", (void *)data,
-PrintValue(initializer));
-
-  Type *initializer_type = initializer->getType();
-
-  if (ConstantInt *int_initializer = dyn_cast(initializer)) {
-size_t constant_size = m_target_data->getTypeStoreSize(initializer_type);
-lldb_private::Scalar scalar = int_initializer->getValue().zextOrTrunc(
-llvm::NextPowerOf2(constant_size) * 8);
-
-lldb_private::Status get_data_error;
-return scalar.GetAsMemoryData(data, constant_size,
-  lldb_private::endian::InlHostByteOrder(),
-  get_data_error) != 0;
-  } else if (ConstantDataArray *array_initializer =
- dyn_cast(initializer)) {
-if (array_initializer->isString()) {
-  std::string array_initializer_string = array_initializer->getAsString();
-  memcpy(data, array_initializer_string.c_str(),
- m_target_data->getTypeStoreSize(initializer_type));
-} else {
-  ArrayType *array_initializer_type = array_initializer->getType();
-  Type *array_element_type = array_initializer_type->getElementType();
-
-  size_t element_size = 
m_target_data->getTypeAllocSize(array_element_type);
-
-  for (unsigned i = 0; i < array_initializer->getNumOperands(); ++i) {
-Value *operand_value = array_initializer->getOperand(i);
-Constant *operand_constant = dyn_cast(operand_value);
-
-if (!operand_constant)
-  return false;
-
-if (!MaterializeInitializer(data + (i * element_size),
-operand_constant))
-  return false;
-  }
-}
-return true;
-  } else if (ConstantStruct *struct_initializer =
- dyn_cast(initializer)) {
-StructType *struct_initializer_type = struct_initializer->getType();
-const StructLayout *struct_layout =
-m_target_data->getStructLayout(struct_initializer_type);
-
-for (unsigned i = 0; i < struct_initializer->getNumOperands(); ++i) {
-  if (!MaterializeInitializer(data + struct_layout->getElementOffset(i),
-  struct_initializer->getOperand(i)))
-return false;
-}
-return true;
-  } else if (isa(initializer)) {
-memset(data, 0, m_target_data->getTypeStoreSize(initializer_type));
-return true;
-  }
-  return false;
-}
-
 // This function does not report errors; its callers are responsible.
 bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
   lldb_private::Log *log(

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h?rev=369198&r1=369197&r2=369198&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h Sat Aug 17 
14:57:51 2019
@@ -332,27 +332,6 @@ private:
   /// a call to a function pointer whose value is the address of the function
   /// in the target process.
 
-  /// Write an initializer to a memory array of assumed sufficient size.
-  ///
-  /// \param[in] data
-  /// A pointer to the data to write to.
-  ///
-  /// \param[in] initializer
-  /// The initializer itself.
-  ///
-  /// \return
-  /// True on success; false otherwise
-  bool MaterializeInitializer(uint8_t *data, llvm::Constant *initializer);
-
-  /// Move an internal variable into the static allocation section.
-  ///
-  /// \param[in] global_variable
-  /// The variable.
-  ///
-  /// \return
-  /// True on success; false otherwise
-  bool MaterializeInternalVariable(llvm::GlobalVariable *global_variable);
-
   /// Handle a single exte