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

2016-06-03 Thread Howard Hellyer via lldb-commits
hhellyer updated this revision to Diff 59524.
hhellyer marked an inline comment as done.
hhellyer added a comment.

Fix the latest code review comments to remove unnecessary tests for a valid 
pointer that will always be initialised.

The change to the == operator on SBMemoryRegionInfo required an additional 
change. It also required adding the == and != operators to MemoryRegionInfo.h, 
that shouldn't be a problem as far as behaviour goes as nothing can have been 
comparing MemoryRegionInfo's with == until now. It does mean that 
SBMemoryRegionInfo's == operator behaves differently to all the other SB* 
classes operators which do pointer comparison via get() which might not be 
ideal.


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/MemoryRegionInfo.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 &sb_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(&process_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(&process_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,162 @@
+//===-- SBMemoryRegionInfoList.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---

Re: [Lldb-commits] [PATCH] D16237: Fixes to ensure TestLogging.py tests work with Python 3.5 as well as 2.7.

2016-06-03 Thread Adrian McCarthy via lldb-commits
amccarth abandoned this revision.
amccarth added a comment.

This was committed a while back.


http://reviews.llvm.org/D16237



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


Re: [Lldb-commits] [PATCH] D16476: XFail TestNamespaceLookup on Windows.

2016-06-03 Thread Adrian McCarthy via lldb-commits
amccarth abandoned this revision.
amccarth added a comment.

Already committed.


http://reviews.llvm.org/D16476



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


Re: [Lldb-commits] [PATCH] D17027: [expression evaluator] Allow runtimes to execute custom LLVM ModulePasses over the generated IR at various stages after expression compilation.

2016-06-03 Thread Luke Drummond via lldb-commits
ldrumm added a comment.

I'd like to give this another *bump*, and commit this soon assuming positive 
review.

@spyffe


http://reviews.llvm.org/D17027



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


[Lldb-commits] [lldb] r271696 - Add support in debug LLDB builds (if LLDB_CONFIGURATION_DEBUG is defined) where we can set an environment variable named LLDB_DWARF_DONT_COMPLETE_TYPENAMES that can con

2016-06-03 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Fri Jun  3 12:59:26 2016
New Revision: 271696

URL: http://llvm.org/viewvc/llvm-project?rev=271696&view=rev
Log:
Add support in debug LLDB builds (if LLDB_CONFIGURATION_DEBUG is defined) where 
we can set an environment variable named LLDB_DWARF_DONT_COMPLETE_TYPENAMES 
that can contain one or more typenames separated by ';' characters. This will 
cause us to not complete any types whose names match and can help us to try and 
reproduce issues we see in bugs. 

So you can launch LLDB with the environment variable:

% LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo;Bar;Baz lldb


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

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=271696&r1=271695&r2=271696&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Jun  
3 12:59:26 2016
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+#include 
+
 #include "DWARFASTParserClang.h"
 #include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
@@ -2120,6 +2122,44 @@ DWARFASTParserClang::CompleteTypeFromDWA
 if (!die)
 return false;
 
+#if defined LLDB_CONFIGURATION_DEBUG
+//--
+// For debugging purposes, the LLDB_DWARF_DONT_COMPLETE_TYPENAMES
+// environment variable can be set with one or more typenames separated
+// by ';' characters. This will cause this function to not complete any
+// types whose names match.
+//
+// Examples of setting this environment variable:
+//
+// LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo
+// LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo;Bar;Baz
+//--
+const char *dont_complete_typenames_cstr = 
getenv("LLDB_DWARF_DONT_COMPLETE_TYPENAMES");
+if (dont_complete_typenames_cstr && dont_complete_typenames_cstr[0])
+{
+const char *die_name = die.GetName();
+if (die_name && die_name[0])
+{
+const char *match = strstr(dont_complete_typenames_cstr, die_name);
+if (match)
+{
+size_t die_name_length = strlen(die_name);
+while (match)
+{
+const char separator_char = ';';
+const char next_char = match[die_name_length];
+if (next_char == '\0' || next_char == separator_char)
+{
+if (match == dont_complete_typenames_cstr || match[-1] 
== separator_char)
+return false;
+}
+match = strstr(match+1, die_name);
+}
+}
+}
+}
+#endif
+
 const dw_tag_t tag = die.Tag();
 
 Log *log = nullptr; // 
(LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));


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


[Lldb-commits] [lldb] r271716 - Fix a printf warning.

2016-06-03 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Fri Jun  3 14:45:05 2016
New Revision: 271716

URL: http://llvm.org/viewvc/llvm-project?rev=271716&view=rev
Log:
Fix a printf warning.


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

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=271716&r1=271715&r2=271716&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Jun  
3 14:45:05 2016
@@ -1778,8 +1778,7 @@ DWARFASTParserClang::ParseTypeFromDWARF
 else
 {
 module_sp->ReportError ("DWARF DIE at 
0x%8.8x was not able to start its definition.\nPlease file a bug and attach the 
file at the start of this error message",
-
type_die_ref.die_offset,
-type_name_cstr);
+
type_die_ref.die_offset);
 }
 }
 


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


[Lldb-commits] [PATCH] D20990: Don't remove PIE executables when using svr4 packets

2016-06-03 Thread Francis Ricci via lldb-commits
fjricci created this revision.
fjricci added reviewers: clayborg, ADodds, tfiala.
fjricci added a subscriber: lldb-commits.

Because PIE executables have an e_type of llvm::ELF::ET_DYN,
they are not of type eTypeExecutable, and were being removed
when svr4 packets were used.

http://reviews.llvm.org/D20990

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4878,8 +4878,10 @@
 if (!found)
 {
 lldb_private::ObjectFile * obj = loaded_module->GetObjectFile 
();
-if (obj && obj->GetType () != 
ObjectFile::Type::eTypeExecutable)
+if (obj && obj->GetType () != 
ObjectFile::Type::eTypeExecutable &&
+loaded_module.get() != 
target.GetExecutableModulePointer()) {
 removed_modules.Append (loaded_module);
+}
 }
 }
 


Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4878,8 +4878,10 @@
 if (!found)
 {
 lldb_private::ObjectFile * obj = loaded_module->GetObjectFile ();
-if (obj && obj->GetType () != ObjectFile::Type::eTypeExecutable)
+if (obj && obj->GetType () != ObjectFile::Type::eTypeExecutable &&
+loaded_module.get() != target.GetExecutableModulePointer()) {
 removed_modules.Append (loaded_module);
+}
 }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D20990: Don't remove PIE executables when using svr4 packets

2016-06-03 Thread Francis Ricci via lldb-commits
fjricci updated this revision to Diff 59633.
fjricci added a comment.

Fix curly-brace style


http://reviews.llvm.org/D20990

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4878,8 +4878,11 @@
 if (!found)
 {
 lldb_private::ObjectFile * obj = loaded_module->GetObjectFile 
();
-if (obj && obj->GetType () != 
ObjectFile::Type::eTypeExecutable)
+if (obj && obj->GetType () != 
ObjectFile::Type::eTypeExecutable &&
+loaded_module.get() != target.GetExecutableModulePointer())
+{
 removed_modules.Append (loaded_module);
+}
 }
 }
 


Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4878,8 +4878,11 @@
 if (!found)
 {
 lldb_private::ObjectFile * obj = loaded_module->GetObjectFile ();
-if (obj && obj->GetType () != ObjectFile::Type::eTypeExecutable)
+if (obj && obj->GetType () != ObjectFile::Type::eTypeExecutable &&
+loaded_module.get() != target.GetExecutableModulePointer())
+{
 removed_modules.Append (loaded_module);
+}
 }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D20990: Don't remove PIE executables when using svr4 packets

2016-06-03 Thread Francis Ricci via lldb-commits
fjricci updated this revision to Diff 59637.
fjricci added a comment.

Refactor to remove unnecessary object file type checking


http://reviews.llvm.org/D20990

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4875,11 +4875,9 @@
 found = true;
 }
 
-if (!found)
+if (!found && loaded_module.get() != 
target.GetExecutableModulePointer())
 {
-lldb_private::ObjectFile * obj = loaded_module->GetObjectFile 
();
-if (obj && obj->GetType () != 
ObjectFile::Type::eTypeExecutable)
-removed_modules.Append (loaded_module);
+removed_modules.Append (loaded_module);
 }
 }
 


Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4875,11 +4875,9 @@
 found = true;
 }
 
-if (!found)
+if (!found && loaded_module.get() != target.GetExecutableModulePointer())
 {
-lldb_private::ObjectFile * obj = loaded_module->GetObjectFile ();
-if (obj && obj->GetType () != ObjectFile::Type::eTypeExecutable)
-removed_modules.Append (loaded_module);
+removed_modules.Append (loaded_module);
 }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r271774 - Add armv7 compact unwind printing to the compact-unwind-dumper.c tool

2016-06-03 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Fri Jun  3 23:10:15 2016
New Revision: 271774

URL: http://llvm.org/viewvc/llvm-project?rev=271774&view=rev
Log:
Add armv7 compact unwind printing to the compact-unwind-dumper.c tool
as a prototype for adding armv7 compact unwind reading to lldb.

Modified:
lldb/trunk/tools/compact-unwind/compact-unwind-dumper.c

Modified: lldb/trunk/tools/compact-unwind/compact-unwind-dumper.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/compact-unwind/compact-unwind-dumper.c?rev=271774&r1=271773&r2=271774&view=diff
==
--- lldb/trunk/tools/compact-unwind/compact-unwind-dumper.c (original)
+++ lldb/trunk/tools/compact-unwind/compact-unwind-dumper.c Fri Jun  3 23:10:15 
2016
@@ -35,6 +35,28 @@ enum {
 UNWIND_ARM64_DWARF_SECTION_OFFSET  = 0x00FF,
 };
 
+enum {
+  UNWIND_ARM_MODE_MASK = 0x0F00,
+  UNWIND_ARM_MODE_FRAME= 0x0100,
+  UNWIND_ARM_MODE_FRAME_D  = 0x0200,
+  UNWIND_ARM_MODE_DWARF= 0x0400,
+
+  UNWIND_ARM_FRAME_STACK_ADJUST_MASK   = 0x00C0,
+
+  UNWIND_ARM_FRAME_FIRST_PUSH_R4   = 0x0001,
+  UNWIND_ARM_FRAME_FIRST_PUSH_R5   = 0x0002,
+  UNWIND_ARM_FRAME_FIRST_PUSH_R6   = 0x0004,
+
+  UNWIND_ARM_FRAME_SECOND_PUSH_R8  = 0x0008,
+  UNWIND_ARM_FRAME_SECOND_PUSH_R9  = 0x0010,
+  UNWIND_ARM_FRAME_SECOND_PUSH_R10 = 0x0020,
+  UNWIND_ARM_FRAME_SECOND_PUSH_R11 = 0x0040,
+  UNWIND_ARM_FRAME_SECOND_PUSH_R12 = 0x0080,
+
+  UNWIND_ARM_FRAME_D_REG_COUNT_MASK= 0x0700,
+
+  UNWIND_ARM_DWARF_SECTION_OFFSET  = 0x00FF,
+};
 
 #define EXTRACT_BITS(value, mask) \
 ( (value >> __builtin_ctz(mask)) & (((1 << 
__builtin_popcount(mask)))-1) )
@@ -218,12 +240,14 @@ scan_macho_load_commands (struct baton *
 if (is_64bit)
 {
 struct section_64 sect;
+memset (§, 0, sizeof (struct section_64));
 memcpy (§, offset, sizeof (struct section_64));
 baton->compact_unwind_start = 
baton->mach_header_start + sect.offset;
 }
 else
 {
 struct section sect;
+memset (§, 0, sizeof (struct section));
 memcpy (§, offset, sizeof (struct section));
 baton->compact_unwind_start = 
baton->mach_header_start + sect.offset;
 }
@@ -233,12 +257,14 @@ scan_macho_load_commands (struct baton *
 if (is_64bit)
 {
 struct section_64 sect;
+memset (§, 0, sizeof (struct section_64));
 memcpy (§, offset, sizeof (struct section_64));
 baton->eh_section_file_address = sect.addr;
 }
 else
 {
 struct section sect;
+memset (§, 0, sizeof (struct section));
 memcpy (§, offset, sizeof (struct section));
 baton->eh_section_file_address = sect.addr;
 }
@@ -248,6 +274,7 @@ scan_macho_load_commands (struct baton *
 if (is_64bit)
 {
 struct section_64 sect;
+memset (§, 0, sizeof (struct section_64));
 memcpy (§, offset, sizeof (struct section_64));
 baton->text_section_vmaddr = sect.addr;
 baton->text_section_file_offset = sect.offset;
@@ -255,6 +282,7 @@ scan_macho_load_commands (struct baton *
 else
 {
 struct section sect;
+memset (§, 0, sizeof (struct section));
 memcpy (§, offset, sizeof (struct section));
 baton->text_section_vmaddr = sect.addr;
 }
@@ -305,6 +333,7 @@ scan_macho_load_commands (struct baton *
 for (int i = 0; i < local_syms_count; i++)
 {
 struct nlist_64 nlist;
+memset (&nlist, 0, sizeof (struct nlist_64));
 if (is_64bit)
 {
 memcpy (&nlist, local_syms + (i * nlist_size), sizeof 
(struct nlist_64));
@@ -312,6 +341,7 @@ scan_macho_load_commands (struct baton *
 else
 {
 struct nlist nlist_32;
+m