[Lldb-commits] [lldb] r271618 - Fix makefile for TestExternCSymbols

2016-06-02 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Thu Jun  2 20:03:04 2016
New Revision: 271618

URL: http://llvm.org/viewvc/llvm-project?rev=271618=rev
Log:
Fix makefile for TestExternCSymbols

Modified:
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile?rev=271618=271617=271618=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile Thu 
Jun  2 20:03:04 2016
@@ -1,3 +1,3 @@
 LEVEL = ../../../make
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp
 include $(LEVEL)/Makefile.rules


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


[Lldb-commits] [lldb] r271551 - Fixed a problem where we couldn't call extern "C" functions.

2016-06-02 Thread Sean Callanan via lldb-commits
Author: spyffe
Date: Thu Jun  2 12:59:47 2016
New Revision: 271551

URL: http://llvm.org/viewvc/llvm-project?rev=271551=rev
Log:
Fixed a problem where we couldn't call extern "C" functions.

Some compilers do not mark up C++ functions as extern "C" in the DWARF, so LLDB
has to fall back (if it is about to give up finding a symbol) to using the base
name of the function.

This fix also ensures that we search by full name rather than "auto," which
could cause unrelated C++ names to be found.  Finally, it adds a test case.



Added:
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/TestExternCSymbols.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp
Modified:
lldb/trunk/include/lldb/Expression/IRExecutionUnit.h
lldb/trunk/source/Expression/IRExecutionUnit.cpp

Modified: lldb/trunk/include/lldb/Expression/IRExecutionUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRExecutionUnit.h?rev=271551=271550=271551=diff
==
--- lldb/trunk/include/lldb/Expression/IRExecutionUnit.h (original)
+++ lldb/trunk/include/lldb/Expression/IRExecutionUnit.h Thu Jun  2 12:59:47 
2016
@@ -294,6 +294,10 @@ private:
const std::vector _specs,
const SymbolContext );
 
+void
+CollectFallbackNames(std::vector _specs,
+ const std::vector _specs);
+
 lldb::addr_t
 FindInSymbols(const std::vector ,
   const lldb_private::SymbolContext );

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile?rev=271551=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile Thu 
Jun  2 12:59:47 2016
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/TestExternCSymbols.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/TestExternCSymbols.py?rev=271551=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/TestExternCSymbols.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/TestExternCSymbols.py
 Thu Jun  2 12:59:47 2016
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp?rev=271551=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp Thu 
Jun  2 12:59:47 2016
@@ -0,0 +1,29 @@
+//===-- main.cpp *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 
+#include 
+
+extern "C"
+{
+   int foo();
+};
+
+int foo()
+{
+puts("foo");
+return 2;
+}
+
+int main (int argc, char const *argv[], char const *envp[])
+{  
+foo();
+return 0; //% self.expect("expression -- foo()", substrs = ['2'])
+}
+

Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=271551=271550=271551=diff
==
--- lldb/trunk/source/Expression/IRExecutionUnit.cpp (original)
+++ lldb/trunk/source/Expression/IRExecutionUnit.cpp Thu Jun  2 12:59:47 2016
@@ -758,7 +758,7 @@ struct IRExecutionUnit::SearchSpec
 ConstString name;
 uint32_tmask;
 
-SearchSpec(ConstString n, uint32_t m = lldb::eFunctionNameTypeAuto) :
+SearchSpec(ConstString n, uint32_t m = lldb::eFunctionNameTypeFull) :
 name(n),
 mask(m)
 {
@@ -819,6 +819,36 @@ IRExecutionUnit::CollectCandidateCPlusPl
 }
 }
 
+void
+IRExecutionUnit::CollectFallbackNames(std::vector _specs,
+  const std::vector _specs)
+{
+// 

[Lldb-commits] [lldb] r271545 - LLDB needs to be able to handle DW_AT_GNU_dwo_name that are relative to the DW_AT_comp_dir when using -gmodules with DWARF in .o files on darwin.

2016-06-02 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Thu Jun  2 12:22:42 2016
New Revision: 271545

URL: http://llvm.org/viewvc/llvm-project?rev=271545=rev
Log:
LLDB needs to be able to handle DW_AT_GNU_dwo_name that are relative to the 
DW_AT_comp_dir when using -gmodules with DWARF in .o files on darwin.

 


Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=271545=271544=271545=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Jun  2 
12:22:42 2016
@@ -1834,9 +1834,25 @@ SymbolFileDWARF::UpdateExternalModuleLis
 {
 ModuleSpec dwo_module_spec;
 dwo_module_spec.GetFileSpec().SetFile(dwo_path, false);
+if (dwo_module_spec.GetFileSpec().IsRelative())
+{
+const char *comp_dir = 
die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr);
+if (comp_dir)
+{
+
dwo_module_spec.GetFileSpec().SetFile(comp_dir, true);
+
dwo_module_spec.GetFileSpec().AppendPathComponent(dwo_path);
+}
+}
 dwo_module_spec.GetArchitecture() = 
m_obj_file->GetModule()->GetArchitecture();
 //printf ("Loading dwo = '%s'\n", dwo_path);
 Error error = ModuleList::GetSharedModule 
(dwo_module_spec, module_sp, NULL, NULL, NULL);
+if (!module_sp)
+{
+GetObjectFile()->GetModule()->ReportWarning 
("0x%8.8x: unable to locate module needed for external types: %s\nerror: 
%s\nDebugging will be degraded due to missing types. Rebuilding your project 
will regenerate the needed module files.",
+ 
die.GetOffset(),
+ 
dwo_module_spec.GetFileSpec().GetPath().c_str(),
+ 
error.AsCString("unknown error"));
+}
 }
 m_external_type_modules[const_name] = module_sp;
 }


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


[Lldb-commits] [lldb] r271543 - Fixed a problem where -gmodules debug info would be loaded by the DWO file support accidentally and cause 1000s of files to be mapped into LLDB's address space for each

2016-06-02 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Thu Jun  2 12:19:39 2016
New Revision: 271543

URL: http://llvm.org/viewvc/llvm-project?rev=271543=rev
Log:
Fixed a problem where -gmodules debug info would be loaded by the DWO file 
support accidentally and cause 1000s of files to be mapped into LLDB's address 
space for each .o file that reference a module.

 -gmodules causes LLDB.framework to map hundreds of 
copies of the same .pcm file

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=271543=271542=271543=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Jun  2 
12:19:39 2016
@@ -1769,6 +1769,12 @@ SymbolFileDWARF::GetDIE (const DIERef 
 std::unique_ptr
 SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(DWARFCompileUnit _cu, 
const DWARFDebugInfoEntry _die)
 {
+// If we are using a dSYM file, we never want the standard DWO files since
+// the -gmodule support uses the same DWO machanism to specify full debug
+// info files for modules.
+if (GetDebugMapSymfile())
+return nullptr;
+
 const char *dwo_name = cu_die.GetAttributeValueAsString(this, _cu, 
DW_AT_GNU_dwo_name, nullptr);
 if (!dwo_name)
 return nullptr;


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


Re: [Lldb-commits] [PATCH] D20565: Add MemoryRegionInfo to SB API

2016-06-02 Thread Greg Clayton via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

So a bit more cleanup. We should always have a valid object inside of a 
SBMemoryRegionInfo or SBMemoryRegionInfoList so there is no need to ever check 
the m_opaque_ap to see if it contains a valid pointer so all if statements that 
are doing:

  if (m_opaque_ap.get())
  m_opaque_ap->DoSomething();

Can be just:

  m_opaque_ap->DoSomething();

Also, no functions should ever call "m_opaque_ap->reset();". All the changes 
should be easy after that.



Comment at: source/API/SBMemoryRegionInfo.cpp:45-48
@@ +44,6 @@
+{
+if (rhs.IsValid())
+ref() = rhs.ref();
+else
+m_opaque_ap.reset();
+}

These 4 lines should just be:

```
ref() = rhs.ref();
```

We never want m_opaque_ap to contain an invalid pointer or we can crash.


Comment at: source/API/SBMemoryRegionInfo.cpp:60
@@ +59,3 @@
+{
+return m_opaque_ap.get() != NULL;
+}

We shouldn't check for NULL since the auto pointer should never be invalid. 
This should just call through and ask the underlying object:

```
return m_opaque_ap->IsValid();
```

If there is no IsValid() function on the underlying object, this function can 
be removed.


Comment at: source/API/SBMemoryRegionInfo.cpp:66
@@ +65,3 @@
+{
+m_opaque_ap.reset();
+}

We should never clear the underlying object, this should just call through:

```
m_opaque_ap->Clear();
```


Comment at: source/API/SBMemoryRegionInfo.cpp:72-74
@@ +71,5 @@
+{
+if (m_opaque_ap)
+return m_opaque_ap.get() == rhs.m_opaque_ap.get();
+return false;
+}

This should compare the objects:

```
return ref() == rhs.ref();
```


Comment at: source/API/SBMemoryRegionInfo.cpp:80-82
@@ +79,5 @@
+{
+if (m_opaque_ap)
+return m_opaque_ap.get() != rhs.m_opaque_ap.get();
+return false;
+}

This should compare the objects:

```
return ref() != rhs.ref();
```


Comment at: source/API/SBMemoryRegionInfo.cpp:88-89
@@ +87,4 @@
+{
+if (m_opaque_ap.get() == NULL)
+m_opaque_ap.reset (new MemoryRegionInfo ());
+return *m_opaque_ap;

You should remove these lines now since m_opaque_ap will never contain an 
invalid object.


Comment at: source/API/SBMemoryRegionInfo.cpp:101-104
@@ +100,6 @@
+SBMemoryRegionInfo::GetRegionBase () {
+if (m_opaque_ap.get())
+{
+return m_opaque_ap->GetRange().GetRangeBase();
+}
+return 0;

No need to check the object


Comment at: source/API/SBMemoryRegionInfo.cpp:110-113
@@ +109,6 @@
+SBMemoryRegionInfo::GetRegionEnd () {
+if (m_opaque_ap.get())
+{
+return m_opaque_ap->GetRange().GetRangeEnd();
+}
+return 0;

No need to check the object, just call the accessor


Comment at: source/API/SBMemoryRegionInfoList.cpp:108
@@ +107,3 @@
+{
+if (m_opaque_ap.get())
+return m_opaque_ap->GetSize();

No need to check the object, just call the accessor. Remove the if and the 
other return.


Comment at: source/API/SBMemoryRegionInfoList.cpp:136
@@ +135,3 @@
+{
+if (m_opaque_ap.get())
+m_opaque_ap->Clear();

No need to check the object, just call the accessor. Remove the if statement.


Comment at: source/API/SBMemoryRegionInfoList.cpp:143
@@ +142,3 @@
+{
+if (sb_region.IsValid() && m_opaque_ap.get())
+m_opaque_ap->Append(sb_region);

No need to check m_opaque_ap since it will always be valid.


Comment at: source/API/SBMemoryRegionInfoList.cpp:150
@@ +149,3 @@
+{
+if (sb_region_list.IsValid() && m_opaque_ap.get())
+m_opaque_ap->Append(*sb_region_list);

No need to check m_opaque_ap since it will always be valid.


Comment at: source/API/SBMemoryRegionInfoList.cpp:157
@@ +156,3 @@
+{
+return m_opaque_ap.get() != NULL;
+}

No need for an IsValid() since the list is always valid, this function can 
actually be removed. 


http://reviews.llvm.org/D20565



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


Re: [Lldb-commits] [PATCH] D20565: Add MemoryRegionInfo to SB API

2016-06-02 Thread Howard Hellyer via lldb-commits
hhellyer updated this revision to Diff 59352.
hhellyer added a comment.

Made sure an object was always constructed for the std::unique_ptr in 
SBMemoryRegionInfo.cpp.
Removed unused constructor from SBMemoryRegionInfo.h.


http://reviews.llvm.org/D20565

Files:
  include/lldb/API/LLDB.h
  include/lldb/API/SBDefines.h
  include/lldb/API/SBMemoryRegionInfo.h
  include/lldb/API/SBMemoryRegionInfoList.h
  include/lldb/API/SBProcess.h
  include/lldb/API/SBStream.h
  include/lldb/Target/Process.h
  include/lldb/lldb-forward.h
  source/API/CMakeLists.txt
  source/API/SBMemoryRegionInfo.cpp
  source/API/SBMemoryRegionInfoList.cpp
  source/API/SBProcess.cpp

Index: source/API/SBProcess.cpp
===
--- source/API/SBProcess.cpp
+++ source/API/SBProcess.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Core/State.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/SystemRuntime.h"
@@ -36,6 +37,8 @@
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "lldb/API/SBMemoryRegionInfoList.h"
 #include "lldb/API/SBThread.h"
 #include "lldb/API/SBThreadCollection.h"
 #include "lldb/API/SBStream.h"
@@ -1476,3 +1479,74 @@
 error.ref() = PluginManager::SaveCore(process_sp, core_file);
 return error;
 }
+
+lldb::SBError
+SBProcess::GetMemoryRegionInfo (lldb::addr_t load_addr, SBMemoryRegionInfo _region_info)
+{
+lldb::SBError sb_error;
+ProcessSP process_sp(GetSP());
+MemoryRegionInfoSP region_info_sp = std::make_shared();
+if (process_sp)
+{
+Process::StopLocker stop_locker;
+if (stop_locker.TryLock(_sp->GetRunLock()))
+{
+std::lock_guard guard(process_sp->GetTarget().GetAPIMutex());
+sb_error.ref() = process_sp->GetMemoryRegionInfo(load_addr, *region_info_sp);
+if( sb_error.Success() ) {
+sb_region_info.ref() = *region_info_sp;
+}
+}
+else
+{
+Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+if (log)
+log->Printf ("SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
+ static_cast(process_sp.get()));
+sb_error.SetErrorString("process is running");
+}
+}
+else
+{
+sb_error.SetErrorString ("SBProcess is invalid");
+}
+return sb_error;
+}
+
+lldb::SBMemoryRegionInfoList
+SBProcess::GetMemoryRegions()
+{
+lldb::SBError sb_error;
+lldb::SBMemoryRegionInfoList sb_region_list;
+ProcessSP process_sp(GetSP());
+if (process_sp)
+{
+Process::StopLocker stop_locker;
+if (stop_locker.TryLock(_sp->GetRunLock()))
+{
+std::lock_guard guard(process_sp->GetTarget().GetAPIMutex());
+std::vector region_list;
+sb_error.ref() = process_sp->GetMemoryRegions(region_list);
+if( sb_error.Success() ) {
+std::vector::iterator end = region_list.end();
+for( std::vector::iterator it = region_list.begin(); it != end; it++ ) {
+SBMemoryRegionInfo sb_region_info(it->get());
+sb_region_list.Append(sb_region_info);
+}
+}
+}
+else
+{
+Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+if (log)
+log->Printf ("SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
+ static_cast(process_sp.get()));
+sb_error.SetErrorString("process is running");
+}
+}
+else
+{
+sb_error.SetErrorString ("SBProcess is invalid");
+}
+return sb_region_list;
+}
Index: source/API/SBMemoryRegionInfoList.cpp
===
--- /dev/null
+++ source/API/SBMemoryRegionInfoList.cpp
@@ -0,0 +1,172 @@
+//===-- SBMemoryRegionInfoList.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "lldb/API/SBMemoryRegionInfoList.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+class MemoryRegionInfoListImpl
+{
+public:
+MemoryRegionInfoListImpl () :
+m_regions()
+{
+}
+
+MemoryRegionInfoListImpl (const MemoryRegionInfoListImpl& rhs) :
+