Re: [Lldb-commits] [lldb] r300138 - Use two LC_NOTE load commands for identifying the main binary that

2017-04-12 Thread Hal Finkel via lldb-commits


On 04/12/2017 06:33 PM, Jason Molenda via lldb-commits wrote:

Author: jmolenda
Date: Wed Apr 12 18:33:30 2017
New Revision: 300138

URL: http://llvm.org/viewvc/llvm-project?rev=300138&view=rev
Log:
Use two LC_NOTE load commands for identifying the main binary that
lldb should use when given a corefile.

This uses an LC_NOTE "main bin spec" or an LC_NOTE "kern ver str"
if they are present in a Mach-O core file.

Core files may have multiple different binaries -- different kernels,
or a mix of user process and kernel binaries -- and it can be
difficult for lldb to detect the correct one to use simply by looking
at the pages of memory.  These two new LC_NOTE load commands allow
for the correct binary to be recorded unambiguously.



Modified:
 lldb/trunk/include/lldb/Symbol/ObjectFile.h
 lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
 lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
 lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=300138&r1=300137&r2=300138&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Wed Apr 12 18:33:30 2017
@@ -18,6 +18,7 @@
  #include "lldb/Utility/DataExtractor.h"
  #include "lldb/Utility/Endian.h"
  #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
  #include "lldb/lldb-private.h"
  
  namespace lldb_private {

@@ -576,6 +577,32 @@ public:
return std::string();
}
  
+  //--

+  /// When the ObjectFile is a core file, lldb needs to locate the
+  /// "binary" in the core file.  lldb can iterate over the pages looking
+  /// for a valid binary, but some core files may have metadata
+  /// describing where the main binary is exactly which removes ambiguity
+  /// when there are multiple binaries present in the captured memory pages.
+  ///
+  /// @param[out] address
+  ///   If the address of the binary is specified, this will be set.
+  ///   This is an address is the virtual address space of the core file
+  ///   memory segments; it is not an offset into the object file.
+  ///   If no address is available, will be set to LLDB_INVALID_ADDRESS.
+  ///
+  /// @param[out] uuid
+  ///   If the uuid of the binary is specified, this will be set.
+  ///   If no UUID is available, will be cleared.
+  ///
+  /// @return
+  ///   Returns true if either address or uuid has been set.
+  //--
+  virtual bool GetCorefileMainBinaryInfo (lldb::addr_t &address, UUID &uuid) {
+  address = LLDB_INVALID_ADDRESS;
+  uuid.Clear();
+  return false;
+  }
+
virtual lldb::RegisterContextSP
GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread) {
  return lldb::RegisterContextSP();

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=300138&r1=300137&r2=300138&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Apr 12 
18:33:30 2017
@@ -60,6 +60,8 @@
  
  #ifndef __APPLE__

  #include "Utility/UuidCompatibility.h"
+#else
+#include 
  #endif


This doesn't build for me on Linux:

/src/llvm/tools/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:5471:39: 
error: ‘uuid_clear’ was not declared in this scope

   uuid_clear (raw_uuid);
   ^

There is a uuid_clear in my system uuid.h header, but on non-Apple 
systems we seem to use ./source/Utility/UuidCompatibility.h, and there's 
no uuid_clear in there.


 -Hal

  
  #define THUMB_ADDRESS_BIT_MASK 0xfffeull

@@ -5354,23 +5356,67 @@ uint32_t ObjectFileMachO::GetNumThreadCo
return m_thread_context_offsets.GetSize();
  }
  
-// The LC_IDENT load command has been obsoleted for a very

-// long time and it should not occur in Mach-O files.  But
-// if it is there, it may contain a hint about where to find
-// the main binary in a core file, so we'll use it.
  std::string ObjectFileMachO::GetIdentifierString() {
std::string result;
ModuleSP module_sp(GetModule());
if (module_sp) {
  std::lock_guard guard(module_sp->GetMutex());
+
+// First, look over the load commands for an LC_NOTE load command
+// with data_owner string "kern ver str" & use that if found.
  lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
  for (uint32_t i = 0; i < m_header.ncmds; ++i) {
const uint32_t cmd_offset = offs

[Lldb-commits] [lldb] r283520 - [lit] Don't assume you'll find debugserver

2016-10-06 Thread Hal Finkel via lldb-commits
Author: hfinkel
Date: Thu Oct  6 21:26:41 2016
New Revision: 283520

URL: http://llvm.org/viewvc/llvm-project?rev=283520&view=rev
Log:
[lit] Don't assume you'll find debugserver

On Linux, there is no "debugserver" process, and the RUN-line substitution will
fail if you try to substitute '%debugserver' with None.

Fixes PR30492.

Modified:
lldb/trunk/lit/lit.cfg

Modified: lldb/trunk/lit/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/lit.cfg?rev=283520&r1=283519&r2=283520&view=diff
==
--- lldb/trunk/lit/lit.cfg (original)
+++ lldb/trunk/lit/lit.cfg Thu Oct  6 21:26:41 2016
@@ -140,7 +140,9 @@ config.substitutions.append(('%cc', conf
 config.substitutions.append(('%cxx', config.cxx))
 
 config.substitutions.append(('%lldb', lldb))
-config.substitutions.append(('%debugserver', debugserver))
+
+if debugserver is not None:
+config.substitutions.append(('%debugserver', debugserver))
 
 for pattern in [r"\bFileCheck\b",
 r"\| \bnot\b"]:


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


Re: [Lldb-commits] [lldb] r287631 - Fix build failure on Linux and BSD by reverting r287597

2016-11-22 Thread Hal Finkel via lldb-commits
- Original Message -
> From: "Omair Javaid via lldb-commits" 
> To: lldb-commits@lists.llvm.org
> Sent: Tuesday, November 22, 2016 3:47:01 AM
> Subject: [Lldb-commits] [lldb] r287631 - Fix build failure on Linux and BSD   
> by reverting r287597
> 
> Author: omjavaid
> Date: Tue Nov 22 03:47:00 2016
> New Revision: 287631
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=287631&view=rev
> Log:
> Fix build failure on Linux and BSD by reverting r287597
> 
> Linux and BSD builds failing after this changes from rev 287597.

Thanks. For me at least, it looked like this:

/src/llvm/tools/lldb/include/lldb/Interpreter/Args.h:155:3: error: 'auto' 
return without trailing return type; deduced return types are a C++14 extension
  auto begin() const { return m_entries.begin(); }
  ^
/src/llvm/tools/lldb/include/lldb/Interpreter/Args.h:156:3: error: 'auto' 
return without trailing return type; deduced return types are a C++14 extension
  auto end() const { return m_entries.end(); }
  ^
/src/llvm/tools/lldb/include/lldb/Interpreter/Args.h:155:31: error: no viable 
conversion from returned value of type 'const_iterator' (aka 
'__normal_iterator > >') to function return type 'int'
  auto begin() const { return m_entries.begin(); }
  ^
/src/llvm/tools/lldb/include/lldb/Interpreter/Args.h:156:29: error: no viable 
conversion from returned value of type 'const_iterator' (aka 
'__normal_iterator > >') to function return type 'int'
  auto end() const { return m_entries.end(); }
^~~

 -Hal

> 
> 
> Modified:
> lldb/trunk/include/lldb/Interpreter/Args.h
> lldb/trunk/source/Breakpoint/BreakpointIDList.cpp
> lldb/trunk/source/Commands/CommandObjectCommands.cpp
> lldb/trunk/source/Commands/CommandObjectFrame.cpp
> lldb/trunk/source/Commands/CommandObjectProcess.cpp
> lldb/trunk/source/Commands/CommandObjectSettings.cpp
> lldb/trunk/source/Interpreter/CommandInterpreter.cpp
> lldb/trunk/source/Interpreter/OptionValueDictionary.cpp
> 
> Modified: lldb/trunk/include/lldb/Interpreter/Args.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=287631&r1=287630&r2=287631&view=diff
> ==
> --- lldb/trunk/include/lldb/Interpreter/Args.h (original)
> +++ lldb/trunk/include/lldb/Interpreter/Args.h Tue Nov 22 03:47:00
> 2016
> @@ -150,13 +150,8 @@ public:
>const char *GetArgumentAtIndex(size_t idx) const;
>  
>llvm::ArrayRef entries() const { return m_entries; }
> -  char GetArgumentQuoteCharAtIndex(size_t idx) const;
> -
> -  auto begin() const { return m_entries.begin(); }
> -  auto end() const { return m_entries.end(); }
>  
> -  size_t size() const { return GetArgumentCount(); }
> -  const ArgEntry &operator[](size_t n) const { return m_entries[n];
> }
> +  char GetArgumentQuoteCharAtIndex(size_t idx) const;
>  
>//--
>/// Gets the argument vector.
> 
> Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointIDList.cpp?rev=287631&r1=287630&r2=287631&view=diff
> ==
> --- lldb/trunk/source/Breakpoint/BreakpointIDList.cpp (original)
> +++ lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Tue Nov 22
> 03:47:00 2016
> @@ -122,12 +122,13 @@ void BreakpointIDList::FindAndReplaceIDR
>llvm::StringRef range_from;
>llvm::StringRef range_to;
>llvm::StringRef current_arg;
> +  const size_t num_old_args = old_args.GetArgumentCount();
>std::set names_found;
>  
> -  for (size_t i = 0; i < old_args.size(); ++i) {
> +  for (size_t i = 0; i < num_old_args; ++i) {
>  bool is_range = false;
>  
> -current_arg = old_args[i].ref;
> +current_arg = old_args.GetArgumentAtIndex(i);
>  if (!allow_locations && current_arg.contains('.')) {
>result.AppendErrorWithFormat(
>"Breakpoint locations not allowed, saw location: %s.",
> @@ -151,17 +152,19 @@ void BreakpointIDList::FindAndReplaceIDR
>  return;
>} else
>  names_found.insert(current_arg);
> -} else if ((i + 2 < old_args.size()) &&
> -   BreakpointID::IsRangeIdentifier(old_args[i + 1].ref)
> &&
> +} else if ((i + 2 < num_old_args) &&
> +   BreakpointID::IsRangeIdentifier(
> +   old_args.GetArgumentAtIndex(i + 1)) &&
> BreakpointID::IsValidIDExpression(current_arg) &&
> -   BreakpointID::IsValidIDExpression(old_args[i +
> 2].ref)) {
> +   BreakpointID::IsValidIDExpression(
> +   old_args.GetArgumentAtIndex(i + 2))) {
>range_from = current_arg;
> -  range_to = old_args[i + 2].ref;
> +  range_to = old_args.GetArgumentAtIndex(i + 2);
>is_range