[Lldb-commits] [PATCH] D33998: Add pretty-printer for wait(2) statuses and modernize the code handling them

2017-06-08 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

NetBSD part looks fine.


https://reviews.llvm.org/D33998



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


[Lldb-commits] [PATCH] D32022: Fix backtrace of noreturn functions situated at the end of a module

2017-06-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for the review. I'm not entirely proud of how I implemented this, but I 
hope it's not too ugly either. The reason I opted for this approach is that I 
needed to implement the "if the module is null then decrement the address and 
recompute" logic in two places. RegisterContextLLDB (computes the backtrace) 
and StackFrame (computes the symbol name to display). This avoids the 
duplication, but adds another argument to a bunch of functions. I don't really 
have an idea on how to make this better, but maybe you will think of something.


https://reviews.llvm.org/D32022



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


[Lldb-commits] [lldb] r304976 - Fix backtrace of noreturn functions situated at the end of a module

2017-06-08 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun  8 08:26:35 2017
New Revision: 304976

URL: http://llvm.org/viewvc/llvm-project?rev=304976&view=rev
Log:
Fix backtrace of noreturn functions situated at the end of a module

Summary:
When a call instruction is the last instruction in a function, the
backtrace PC will point past the end of the function. We already had
special code to handle that, but we did not handle the case where the PC
ends up outside of the bounds of the module containing the function,
which is a situation that occured in TestNoreturnUnwind on android for
some arch/compiler combinations.

I fix this by adding an argument to Address resolution code which states
that we are ok with addresses pointing to the end of a module/section to
resolve to that module/section.

I create a reproducible test case for this situation by hand-crafting an
executable which has a noreturn function at the end of a module.

Reviewers: jasonmolenda, jingham

Subscribers: lldb-commits

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/a.s

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.core

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.out
   (with props)
Modified:
lldb/trunk/include/lldb/Core/Address.h
lldb/trunk/include/lldb/Core/Section.h
lldb/trunk/include/lldb/Target/SectionLoadList.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/main.c
lldb/trunk/source/Core/Address.cpp
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Target/SectionLoadList.cpp
lldb/trunk/source/Target/StackFrame.cpp

Modified: lldb/trunk/include/lldb/Core/Address.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=304976&r1=304975&r2=304976&view=diff
==
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Thu Jun  8 08:26:35 2017
@@ -422,6 +422,10 @@ public:
   /// a section + offset. The Target's SectionLoadList object
   /// is used to resolve the address.
   ///
+  /// @param[in] allow_section_end
+  /// If true, treat an address pointing to the end of the module as
+  /// belonging to that module.
+  ///
   /// @return
   /// Returns \b true if the load address was resolved to be
   /// section/offset, \b false otherwise. It is often ok for an
@@ -429,11 +433,13 @@ public:
   /// happens for JIT'ed code, or any load addresses on the stack
   /// or heap.
   //--
-  bool SetLoadAddress(lldb::addr_t load_addr, Target *target);
+  bool SetLoadAddress(lldb::addr_t load_addr, Target *target,
+  bool allow_section_end = false);
 
   bool SetOpcodeLoadAddress(
   lldb::addr_t load_addr, Target *target,
-  lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
+  lldb::AddressClass addr_class = lldb::eAddressClassInvalid,
+  bool allow_section_end = false);
 
   bool SetCallableLoadAddress(lldb::addr_t load_addr, Target *target);
 

Modified: lldb/trunk/include/lldb/Core/Section.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=304976&r1=304975&r2=304976&view=diff
==
--- lldb/trunk/include/lldb/Core/Section.h (original)
+++ lldb/trunk/include/lldb/Core/Section.h Thu Jun  8 08:26:35 2017
@@ -143,7 +143,8 @@ public:
 
   lldb::addr_t GetLoadBaseAddress(Target *target) const;
 
-  bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr) const;
+  bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr,
+   bool allow_section_end = false) const;
 
   lldb::offset_t GetFileOffset() const { return m_file_offset; }
 

Modified: lldb/trunk/include/lldb/Target/SectionLoadList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/SectionLoadList.h?rev=304976&r1=304975&r2=304976&view=diff
==
--- lldb/trunk/include/lldb/Target/SectionLoadList.h (original)
+++ lldb/trunk/include/lldb/Target/SectionLoadList.h Thu Jun  8 08:26:35 2017
@@ -47,7 +47,8 @@ public:
 
   lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp) const;
 
-  bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr) 

[Lldb-commits] [PATCH] D32022: Fix backtrace of noreturn functions situated at the end of a module

2017-06-08 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304976: Fix backtrace of noreturn functions situated at the 
end of a module (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D32022?vs=101555&id=101900#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32022

Files:
  lldb/trunk/include/lldb/Core/Address.h
  lldb/trunk/include/lldb/Core/Section.h
  lldb/trunk/include/lldb/Target/SectionLoadList.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/main.c
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/a.s
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.core
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.out
  lldb/trunk/source/Core/Address.cpp
  lldb/trunk/source/Core/Section.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/trunk/source/Target/SectionLoadList.cpp
  lldb/trunk/source/Target/StackFrame.cpp

Index: lldb/trunk/include/lldb/Core/Address.h
===
--- lldb/trunk/include/lldb/Core/Address.h
+++ lldb/trunk/include/lldb/Core/Address.h
@@ -422,18 +422,24 @@
   /// a section + offset. The Target's SectionLoadList object
   /// is used to resolve the address.
   ///
+  /// @param[in] allow_section_end
+  /// If true, treat an address pointing to the end of the module as
+  /// belonging to that module.
+  ///
   /// @return
   /// Returns \b true if the load address was resolved to be
   /// section/offset, \b false otherwise. It is often ok for an
   /// address no not resolve to a section in a module, this often
   /// happens for JIT'ed code, or any load addresses on the stack
   /// or heap.
   //--
-  bool SetLoadAddress(lldb::addr_t load_addr, Target *target);
+  bool SetLoadAddress(lldb::addr_t load_addr, Target *target,
+  bool allow_section_end = false);
 
   bool SetOpcodeLoadAddress(
   lldb::addr_t load_addr, Target *target,
-  lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
+  lldb::AddressClass addr_class = lldb::eAddressClassInvalid,
+  bool allow_section_end = false);
 
   bool SetCallableLoadAddress(lldb::addr_t load_addr, Target *target);
 
Index: lldb/trunk/include/lldb/Core/Section.h
===
--- lldb/trunk/include/lldb/Core/Section.h
+++ lldb/trunk/include/lldb/Core/Section.h
@@ -143,7 +143,8 @@
 
   lldb::addr_t GetLoadBaseAddress(Target *target) const;
 
-  bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr) const;
+  bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr,
+   bool allow_section_end = false) const;
 
   lldb::offset_t GetFileOffset() const { return m_file_offset; }
 
Index: lldb/trunk/include/lldb/Target/SectionLoadList.h
===
--- lldb/trunk/include/lldb/Target/SectionLoadList.h
+++ lldb/trunk/include/lldb/Target/SectionLoadList.h
@@ -47,7 +47,8 @@
 
   lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp) const;
 
-  bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr) const;
+  bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
+  bool allow_section_end = false) const;
 
   bool SetSectionLoadAddress(const lldb::SectionSP §ion_sp,
  lldb::addr_t load_addr,
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/a.s
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/a.s
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/a.s
@@ -0,0 +1,35 @@
+# compile this with:
+# as a.s -o a.o --32 && ld a.o -m elf_i386
+# generate core file with:
+# ulimit -s 12 && ./a.out
+
+.text
+
+.globl func2
+.type func2, @function
+func2:
+  pushl %ebp
+  movl  %esp, %ebp
+  movl  0,%eax
+  popl  %ebp
+  ret
+.size func2, .-func2
+
+.globl _start
+.type _start, @function
+_start:
+  pushl %ebp
+  movl  %esp, %ebp
+  call  func1
+  popl  %ebp
+  ret
+.size _start, .-_start
+
+.globl func1
+.type func1, @function
+func1:
+  pushl %ebp
+  movl  %esp, %ebp
+  call  func2
+.size func1, .-func1
+
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
===

[Lldb-commits] [PATCH] D33998: Add pretty-printer for wait(2) statuses and modernize the code handling them

2017-06-08 Thread Eugene Zemtsov via Phabricator via lldb-commits
eugene added inline comments.



Comment at: source/Host/common/Host.cpp:1010
+static constexpr char type[] = "WXS";
+OS << formatv("{0}{1:x-2}", type[WS.type], WS.status);
+return;

 type[WS.type] seems to be a somewhat unnecessary hack. I would use a simple 
switch here.



Comment at: source/Host/common/Host.cpp:1017
+  {"Exited with status"}, {"Killed by signal"}, {"Stopped by signal"}};
+  OS << desc[WS.type] << " " << int(WS.status);
+}

Same as above.


https://reviews.llvm.org/D33998



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


[Lldb-commits] [lldb] r305035 - [VMRange] Simplify a couple of member functions. NFCI.

2017-06-08 Thread Davide Italiano via lldb-commits
Author: davide
Date: Thu Jun  8 18:49:56 2017
New Revision: 305035

URL: http://llvm.org/viewvc/llvm-project?rev=305035&view=rev
Log:
[VMRange] Simplify a couple of member functions. NFCI.

Modified:
lldb/trunk/source/Utility/VMRange.cpp

Modified: lldb/trunk/source/Utility/VMRange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/VMRange.cpp?rev=305035&r1=305034&r2=305035&view=diff
==
--- lldb/trunk/source/Utility/VMRange.cpp (original)
+++ lldb/trunk/source/Utility/VMRange.cpp Thu Jun  8 18:49:56 2017
@@ -25,23 +25,15 @@ using namespace lldb_private;
 bool VMRange::ContainsValue(const VMRange::collection &coll,
 lldb::addr_t value) {
   ValueInRangeUnaryPredicate in_range_predicate(value);
-  VMRange::const_iterator pos;
   VMRange::const_iterator end = coll.end();
-  pos = std::find_if(coll.begin(), end, in_range_predicate);
-  if (pos != end)
-return true;
-  return false;
+  return std::find_if(coll.begin(), end, in_range_predicate) != end;
 }
 
 bool VMRange::ContainsRange(const VMRange::collection &coll,
 const VMRange &range) {
   RangeInRangeUnaryPredicate in_range_predicate(range);
-  VMRange::const_iterator pos;
   VMRange::const_iterator end = coll.end();
-  pos = std::find_if(coll.begin(), end, in_range_predicate);
-  if (pos != end)
-return true;
-  return false;
+  return std::find_if(coll.begin(), end, in_range_predicate) != end;
 }
 
 size_t VMRange::FindRangeIndexThatContainsValue(const VMRange::collection 
&coll,


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


Re: [Lldb-commits] [lldb] r305035 - [VMRange] Simplify a couple of member functions. NFCI.

2017-06-08 Thread Zachary Turner via lldb-commits
Note that even simpler would be

```
return llvm::find_if(col, in_range_predicate) != col.end();
```

On Thu, Jun 8, 2017 at 4:50 PM Davide Italiano via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: davide
> Date: Thu Jun  8 18:49:56 2017
> New Revision: 305035
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305035&view=rev
> Log:
> [VMRange] Simplify a couple of member functions. NFCI.
>
> Modified:
> lldb/trunk/source/Utility/VMRange.cpp
>
> Modified: lldb/trunk/source/Utility/VMRange.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/VMRange.cpp?rev=305035&r1=305034&r2=305035&view=diff
>
> ==
> --- lldb/trunk/source/Utility/VMRange.cpp (original)
> +++ lldb/trunk/source/Utility/VMRange.cpp Thu Jun  8 18:49:56 2017
> @@ -25,23 +25,15 @@ using namespace lldb_private;
>  bool VMRange::ContainsValue(const VMRange::collection &coll,
>  lldb::addr_t value) {
>ValueInRangeUnaryPredicate in_range_predicate(value);
> -  VMRange::const_iterator pos;
>VMRange::const_iterator end = coll.end();
> -  pos = std::find_if(coll.begin(), end, in_range_predicate);
> -  if (pos != end)
> -return true;
> -  return false;
> +  return std::find_if(coll.begin(), end, in_range_predicate) != end;
>  }
>
>  bool VMRange::ContainsRange(const VMRange::collection &coll,
>  const VMRange &range) {
>RangeInRangeUnaryPredicate in_range_predicate(range);
> -  VMRange::const_iterator pos;
>VMRange::const_iterator end = coll.end();
> -  pos = std::find_if(coll.begin(), end, in_range_predicate);
> -  if (pos != end)
> -return true;
> -  return false;
> +  return std::find_if(coll.begin(), end, in_range_predicate) != end;
>  }
>
>  size_t VMRange::FindRangeIndexThatContainsValue(const VMRange::collection
> &coll,
>
>
> ___
> 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


Re: [Lldb-commits] [lldb] r305035 - [VMRange] Simplify a couple of member functions. NFCI.

2017-06-08 Thread Davide Italiano via lldb-commits
Fair enough. I'll make this change and run the testsuite again.
I've been a little scared of pushing NFCI changes in lldb as the
testsuite doesn't seem to be consistently "green" (even without
modifications), but I'll try this one.

Thanks Zachary!

--
Davide

On Thu, Jun 8, 2017 at 4:55 PM, Zachary Turner  wrote:
> Note that even simpler would be
>
> ```
> return llvm::find_if(col, in_range_predicate) != col.end();
> ```
>
> On Thu, Jun 8, 2017 at 4:50 PM Davide Italiano via lldb-commits
>  wrote:
>>
>> Author: davide
>> Date: Thu Jun  8 18:49:56 2017
>> New Revision: 305035
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=305035&view=rev
>> Log:
>> [VMRange] Simplify a couple of member functions. NFCI.
>>
>> Modified:
>> lldb/trunk/source/Utility/VMRange.cpp
>>
>> Modified: lldb/trunk/source/Utility/VMRange.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/VMRange.cpp?rev=305035&r1=305034&r2=305035&view=diff
>>
>> ==
>> --- lldb/trunk/source/Utility/VMRange.cpp (original)
>> +++ lldb/trunk/source/Utility/VMRange.cpp Thu Jun  8 18:49:56 2017
>> @@ -25,23 +25,15 @@ using namespace lldb_private;
>>  bool VMRange::ContainsValue(const VMRange::collection &coll,
>>  lldb::addr_t value) {
>>ValueInRangeUnaryPredicate in_range_predicate(value);
>> -  VMRange::const_iterator pos;
>>VMRange::const_iterator end = coll.end();
>> -  pos = std::find_if(coll.begin(), end, in_range_predicate);
>> -  if (pos != end)
>> -return true;
>> -  return false;
>> +  return std::find_if(coll.begin(), end, in_range_predicate) != end;
>>  }
>>
>>  bool VMRange::ContainsRange(const VMRange::collection &coll,
>>  const VMRange &range) {
>>RangeInRangeUnaryPredicate in_range_predicate(range);
>> -  VMRange::const_iterator pos;
>>VMRange::const_iterator end = coll.end();
>> -  pos = std::find_if(coll.begin(), end, in_range_predicate);
>> -  if (pos != end)
>> -return true;
>> -  return false;
>> +  return std::find_if(coll.begin(), end, in_range_predicate) != end;
>>  }
>>
>>  size_t VMRange::FindRangeIndexThatContainsValue(const VMRange::collection
>> &coll,
>>
>>
>> ___
>> lldb-commits mailing list
>> lldb-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits