[Lldb-commits] [lldb] r330066 - [debugserver] Remove dead function call. NFCI.

2018-04-13 Thread Davide Italiano via lldb-commits
Author: davide
Date: Fri Apr 13 13:47:25 2018
New Revision: 330066

URL: http://llvm.org/viewvc/llvm-project?rev=330066=rev
Log:
[debugserver] Remove dead function call. NFCI.

Modified:
lldb/trunk/tools/debugserver/source/RNBRemote.cpp

Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=330066=330065=330066=diff
==
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Fri Apr 13 13:47:25 2018
@@ -6089,9 +6089,6 @@ rnb_err_t RNBRemote::HandlePacket_qProce
   ((addr_size == 8) ? sizeof(mach_header_64) : sizeof(mach_header));
   load_command lc;
   for (uint32_t i = 0; i < mh.ncmds && !os_handled; ++i) {
-const nub_size_t bytes_read =
-DNBProcessMemoryRead(pid, load_command_addr, sizeof(lc), );
-
 uint32_t major_version, minor_version, patch_version;
 auto *platform = DNBGetDeploymentInfo(pid, lc, load_command_addr,
   major_version, minor_version,


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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Which compilers / platforms generate / support this? Is this an ELF-only 
feature?


https://reviews.llvm.org/D45628



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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In https://reviews.llvm.org/D45628#1067375, @aprantl wrote:

> Which compilers / platforms generate / support this? Is this an ELF-only 
> feature?


Clang/LLVM do (-Wa,--compress-debug-sections). Yeah, it's ELF only so far as I 
know. There's a couple of variations (-compress-debug-sections=zlib or 
zlib-gnu) the ".zdebug_foo" is zlib-gnu style, but a more modern variant (zlib) 
uses a section attribute SHF_COMPRESSED instead of the name mangling.

In https://reviews.llvm.org/D45628#1067382, @clayborg wrote:

> If this is for current and future debugging, it would be nice to change the 
> tool to just use the normal .debug prefixes and just specify SHF_COMPRESSED???


At least for now, zlib-gnu style is used at Google - I don't actually know what 
it'd cost to switch to the more modern zlib (using SHF_COMPRESSED) style. No 
doubt there are a variety of tools that may not have been updated/improved to 
support the new format - hard to say.


https://reviews.llvm.org/D45628



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


[Lldb-commits] [lldb] r330071 - Revert "[debugserver] Remove dead function call. NFCI."

2018-04-13 Thread Davide Italiano via lldb-commits
Author: davide
Date: Fri Apr 13 14:26:32 2018
New Revision: 330071

URL: http://llvm.org/viewvc/llvm-project?rev=330071=rev
Log:
Revert "[debugserver] Remove dead function call. NFCI."

This reverts commit r330066 as it was wrong and the call was
not dead. Thanks to Fred for pointing this out.

Modified:
lldb/trunk/tools/debugserver/source/RNBRemote.cpp

Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=330071=330070=330071=diff
==
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Fri Apr 13 14:26:32 2018
@@ -6089,6 +6089,9 @@ rnb_err_t RNBRemote::HandlePacket_qProce
   ((addr_size == 8) ? sizeof(mach_header_64) : sizeof(mach_header));
   load_command lc;
   for (uint32_t i = 0; i < mh.ncmds && !os_handled; ++i) {
+const nub_size_t bytes_read =
+DNBProcessMemoryRead(pid, load_command_addr, sizeof(lc), );
+
 uint32_t major_version, minor_version, patch_version;
 auto *platform = DNBGetDeploymentInfo(pid, lc, load_command_addr,
   major_version, minor_version,


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


Re: [Lldb-commits] [lldb] r330066 - [debugserver] Remove dead function call. NFCI.

2018-04-13 Thread Frédéric Riss via lldb-commits


> On Apr 13, 2018, at 1:47 PM, Davide Italiano via lldb-commits 
>  wrote:
> 
> Author: davide
> Date: Fri Apr 13 13:47:25 2018
> New Revision: 330066
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=330066=rev
> Log:
> [debugserver] Remove dead function call. NFCI.
> 
> Modified:
>lldb/trunk/tools/debugserver/source/RNBRemote.cpp
> 
> Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=330066=330065=330066=diff
> ==
> --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
> +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Fri Apr 13 13:47:25 2018
> @@ -6089,9 +6089,6 @@ rnb_err_t RNBRemote::HandlePacket_qProce
>   ((addr_size == 8) ? sizeof(mach_header_64) : sizeof(mach_header));
>   load_command lc;
>   for (uint32_t i = 0; i < mh.ncmds && !os_handled; ++i) {
> -const nub_size_t bytes_read =
> -DNBProcessMemoryRead(pid, load_command_addr, sizeof(lc), );
> -
> uint32_t major_version, minor_version, patch_version;
> auto *platform = DNBGetDeploymentInfo(pid, lc, load_command_addr,
>   major_version, minor_version,

This is not dead, it fills in lc which is used on the next line. I doubt this 
passes tests if you use the built debug server. The return value is unused 
though.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45554: Make sure deleting all breakpoints clears their sites first

2018-04-13 Thread Eugene Zemtsov via Phabricator via lldb-commits
eugene added a comment.

Well, I agree that breakpoints, locations and sites could benefit from 
ownership refactoring. 
shared_ptr cycles are bad. 
Let's discuss it at lldb-dev. 
Meanwhile I think it's still ok to fix this bug right now, by doing what has 
already been done in other places.


https://reviews.llvm.org/D45554



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


[Lldb-commits] [PATCH] D45554: Make sure deleting all breakpoints clears their sites first

2018-04-13 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

That sounds like a good plan to me.


https://reviews.llvm.org/D45554



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


Re: [Lldb-commits] [lldb] r330066 - [debugserver] Remove dead function call. NFCI.

2018-04-13 Thread Davide Italiano via lldb-commits
davide@Davidinos-Mac-Pro ~/w/l/llvm-project-20170507> git llvm push
Pushing 1 commit:
  deaca6ae380 Revert "[debugserver] Remove dead function call. NFCI."

On Fri, Apr 13, 2018 at 2:21 PM, Davide Italiano  wrote:
> Oops. Sorry. Fixing this now.
>
> On Fri, Apr 13, 2018 at 1:55 PM, Frédéric Riss via lldb-commits
>  wrote:
>>
>>
>>> On Apr 13, 2018, at 1:47 PM, Davide Italiano via lldb-commits 
>>>  wrote:
>>>
>>> Author: davide
>>> Date: Fri Apr 13 13:47:25 2018
>>> New Revision: 330066
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=330066=rev
>>> Log:
>>> [debugserver] Remove dead function call. NFCI.
>>>
>>> Modified:
>>>lldb/trunk/tools/debugserver/source/RNBRemote.cpp
>>>
>>> Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=330066=330065=330066=diff
>>> ==
>>> --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
>>> +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Fri Apr 13 13:47:25 
>>> 2018
>>> @@ -6089,9 +6089,6 @@ rnb_err_t RNBRemote::HandlePacket_qProce
>>>   ((addr_size == 8) ? sizeof(mach_header_64) : sizeof(mach_header));
>>>   load_command lc;
>>>   for (uint32_t i = 0; i < mh.ncmds && !os_handled; ++i) {
>>> -const nub_size_t bytes_read =
>>> -DNBProcessMemoryRead(pid, load_command_addr, sizeof(lc), );
>>> -
>>> uint32_t major_version, minor_version, patch_version;
>>> auto *platform = DNBGetDeploymentInfo(pid, lc, load_command_addr,
>>>   major_version, minor_version,
>>
>> This is not dead, it fills in lc which is used on the next line. I doubt 
>> this passes tests if you use the built debug server. The return value is 
>> unused though.
>> ___
>> 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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Thanks for clarifying. You'll also need to add a testcase. If clang supports 
this then I don't have a problem with supporting this in LLDB and adding a 
testcase should be easy.




Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1893
 sect_type = eSectionTypeDWARFDebugAbbrev;
-  else if (name == g_sect_name_dwarf_debug_addr)
+  else if (name == g_sect_name_dwarf_debug_addr ||
+   name == g_sect_name_dwarf_zdebug_addr)

Could this entire device be replaced by a llvm::StringSwitch or something else 
more elegant?


https://reviews.llvm.org/D45628



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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

We should test both ways: using normal DWARF section names with SHF_COMPRESSED, 
and with ".zdebug" prefixed section names.


https://reviews.llvm.org/D45628



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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Davide Italiano via Phabricator via lldb-commits
davide added subscribers: jasonmolenda, davide.
davide requested changes to this revision.
davide added a comment.
This revision now requires changes to proceed.

This requires an unittest (or an lldb-test test). Some comments inline.
I think @clayborg or @jasonmolenda are in a better position to review the 
structure, I can take a look at the ELF specific details.




Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1890-1891
   // http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
-  else if (name == g_sect_name_dwarf_debug_abbrev)
+  else if (name == g_sect_name_dwarf_debug_abbrev ||
+   name == g_sect_name_dwarf_zdebug_abbrev)
 sect_type = eSectionTypeDWARFDebugAbbrev;

this whole cascade is really not ideal. Maybe we should factor the checks out 
or move this to be a switch?



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2113-2115
+  // GOOGLE3: never use hash or hash.
+#if 0
+

Please remove references to GOOGLE3.


Repository:
  rL LLVM

https://reviews.llvm.org/D45628



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


[Lldb-commits] [PATCH] D45547: [Command] Implement `stats`

2018-04-13 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

In https://reviews.llvm.org/D45547#1066044, @xiaobai wrote:

> I really like this idea! It will be very helpful for @sas and I. I'd like to 
> +1 creating a separate `stats dump` subcommand instead of dumping stats on 
> `stats disable`.


Thanks! If you has ideas or want to add stuffs, don't hesitate to start a 
discussion and/or submit a review!


Repository:
  rL LLVM

https://reviews.llvm.org/D45547



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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Erik Welander via Phabricator via lldb-commits
alur created this revision.
alur added reviewers: labath, clayborg.
alur added a project: LLDB.
Herald added subscribers: llvm-commits, JDevlieghere, arichardson, aprantl, 
emaste.
Herald added a reviewer: espindola.

Repository:
  rL LLVM

https://reviews.llvm.org/D45628

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1819,6 +1819,32 @@
   static ConstString g_sect_name_dwarf_debug_str_dwo(".debug_str.dwo");
   static ConstString g_sect_name_dwarf_debug_str_offsets_dwo(
   ".debug_str_offsets.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_abbrev(".zdebug_abbrev");
+  static ConstString g_sect_name_dwarf_zdebug_addr(".zdebug_addr");
+  static ConstString g_sect_name_dwarf_zdebug_aranges(".zdebug_aranges");
+  static ConstString g_sect_name_dwarf_zdebug_cu_index(".zdebug_cu_index");
+  static ConstString g_sect_name_dwarf_zdebug_frame(".zdebug_frame");
+  static ConstString g_sect_name_dwarf_zdebug_info(".zdebug_info");
+  static ConstString g_sect_name_dwarf_zdebug_line(".zdebug_line");
+  static ConstString g_sect_name_dwarf_zdebug_loc(".zdebug_loc");
+  static ConstString g_sect_name_dwarf_zdebug_macinfo(".zdebug_macinfo");
+  static ConstString g_sect_name_dwarf_zdebug_macro(".zdebug_macro");
+  static ConstString g_sect_name_dwarf_zdebug_pubnames(".zdebug_pubnames");
+  static ConstString g_sect_name_dwarf_zdebug_pubtypes(".zdebug_pubtypes");
+  static ConstString g_sect_name_dwarf_zdebug_ranges(".zdebug_ranges");
+  static ConstString g_sect_name_dwarf_zdebug_str(".zdebug_str");
+  static ConstString g_sect_name_dwarf_zdebug_str_offsets(
+  ".zdebug_str_offsets");
+  static ConstString g_sect_name_dwarf_zdebug_abbrev_dwo(
+  ".zdebug_abbrev.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_info_dwo(".zdebug_info.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_line_dwo(".zdebug_line.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_macro_dwo(
+  ".zdebug_macro.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_loc_dwo(".zdebug_loc.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_str_dwo(".zdebug_str.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_str_offsets_dwo(
+  ".zdebug_str_offsets.dwo");
   static ConstString g_sect_name_eh_frame(".eh_frame");
   static ConstString g_sect_name_arm_exidx(".ARM.exidx");
   static ConstString g_sect_name_arm_extab(".ARM.extab");
@@ -1861,49 +1887,71 @@
   // http://src.chromium.org/viewvc/chrome/trunk/src/build/gdb-add-index?pathrev=144644
   // MISSING? .debug_types - Type descriptions from DWARF 4? See
   // http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
-  else if (name == g_sect_name_dwarf_debug_abbrev)
+  else if (name == g_sect_name_dwarf_debug_abbrev ||
+   name == g_sect_name_dwarf_zdebug_abbrev)
 sect_type = eSectionTypeDWARFDebugAbbrev;
-  else if (name == g_sect_name_dwarf_debug_addr)
+  else if (name == g_sect_name_dwarf_debug_addr ||
+   name == g_sect_name_dwarf_zdebug_addr)
 sect_type = eSectionTypeDWARFDebugAddr;
-  else if (name == g_sect_name_dwarf_debug_aranges)
+  else if (name == g_sect_name_dwarf_debug_aranges ||
+   name == g_sect_name_dwarf_zdebug_aranges)
 sect_type = eSectionTypeDWARFDebugAranges;
-  else if (name == g_sect_name_dwarf_debug_cu_index)
+  else if (name == g_sect_name_dwarf_debug_cu_index ||
+   name == g_sect_name_dwarf_zdebug_cu_index)
 sect_type = eSectionTypeDWARFDebugCuIndex;
-  else if (name == g_sect_name_dwarf_debug_frame)
+  else if (name == g_sect_name_dwarf_debug_frame ||
+   name == g_sect_name_dwarf_zdebug_frame)
 sect_type = eSectionTypeDWARFDebugFrame;
-  else if (name == g_sect_name_dwarf_debug_info)
+  else if (name == g_sect_name_dwarf_debug_info ||
+   name == g_sect_name_dwarf_zdebug_info)
 sect_type = eSectionTypeDWARFDebugInfo;
-  else if (name == g_sect_name_dwarf_debug_line)
+  else if (name == g_sect_name_dwarf_debug_line ||
+   name == g_sect_name_dwarf_zdebug_line)
 sect_type = eSectionTypeDWARFDebugLine;
-  else if (name == g_sect_name_dwarf_debug_loc)
+  else if (name == g_sect_name_dwarf_debug_loc ||
+   name == g_sect_name_dwarf_zdebug_loc)
 sect_type = eSectionTypeDWARFDebugLoc;
-  else if (name == g_sect_name_dwarf_debug_macinfo)
+  else if (name == g_sect_name_dwarf_debug_macinfo ||
+   name == g_sect_name_dwarf_zdebug_macinfo)
 sect_type = eSectionTypeDWARFDebugMacInfo;
-  else if (name == 

[Lldb-commits] [lldb] r330043 - [Command] Implement `statistics` command.

2018-04-13 Thread Davide Italiano via lldb-commits
Author: davide
Date: Fri Apr 13 11:02:39 2018
New Revision: 330043

URL: http://llvm.org/viewvc/llvm-project?rev=330043=rev
Log:
[Command] Implement `statistics` command.

This allows us to collect useful metrics about lldb debugging sessions.

I thought that an example would be better than a thousand words:

  Process 19705 stopped
  * thread #1, queue = 'com.apple.main-thread', stop reason = step in
  frame #0: 0x00010fb4 blah`main at blah.c:3
 1int main(void) {
 2  int a = 6;
  -> 3  return 0;
 4}
  (lldb) statistics enable
  (lldb) frame var a
  (int) a = 6
  (lldb) expr a
  (int) $1 = 6
  (lldb) statistics disable
  (lldb) statistics dump
  Number of expr evaluation successes : 1
  Number of expr evaluation failures : 0
  Number of frame var successes : 1
  Number of frame var failures : 0

Future improvements might include:

1. Passing a file, or implementing categories. The way this patch has
been implemented is generic enough to allow this to be extended
easily without breaking the grammar.
2. Adding an SBAPI and Python API for use in scripts.

Thanks to Jim Ingham for discussing the design with me.



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

Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats/
lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats/Makefile
lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats/TestStats.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats/main.c
Modified:
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/lldb-private-enumerations.h
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectStats.cpp
lldb/trunk/source/Commands/CommandObjectStats.h
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=330043=330042=330043=diff
==
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Fri Apr 13 11:02:39 2018
@@ -35,6 +35,7 @@
 #include "lldb/Target/ProcessLaunchInfo.h"
 #include "lldb/Target/SectionLoadHistory.h"
 #include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-public.h"
 
@@ -1284,6 +1285,28 @@ protected:
   static void ImageSearchPathsChanged(const PathMappingList _list,
   void *baton);
 
+  //--
+  // Utilities for `statistics` command.
+  //--
+private:
+  std::vector m_stats_storage;
+  bool m_collecting_stats = false;
+
+public:
+  void SetCollectingStats(bool v) { m_collecting_stats = v; }
+
+  bool GetCollectingStats() { return m_collecting_stats; }
+
+  void IncrementStats(lldb_private::StatisticKind key) {
+if (!GetCollectingStats())
+  return;
+lldbassert(key < lldb_private::StatisticKind::StatisticMax &&
+   "invalid statistics!");
+m_stats_storage[key] += 1;
+  }
+
+  std::vector GetStatistics() { return m_stats_storage; }
+
 private:
   //--
   /// Construct with optional file and arch.

Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=330043=330042=330043=diff
==
--- lldb/trunk/include/lldb/lldb-private-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-private-enumerations.h Fri Apr 13 11:02:39 2018
@@ -234,6 +234,18 @@ enum class CompilerContextKind {
   Typedef
 };
 
+//--
+// Enumerations that can be used to specify the kind of metric we're
+// looking at when collecting stats.
+//--
+enum StatisticKind {
+  ExpressionSuccessful = 0,
+  ExpressionFailure = 1,
+  FrameVarSuccess = 2,
+  FrameVarFailure = 3,
+  StatisticMax = 4
+};
+
 } // namespace lldb_private
 
 namespace llvm {

Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats/Makefile?rev=330043=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats/Makefile 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats/Makefile 
Fri Apr 13 11:02:39 2018
@@ 

[Lldb-commits] [PATCH] D45592: Allow relative file paths when settings source breakpoints

2018-04-13 Thread Davide Italiano via Phabricator via lldb-commits
davide added subscribers: clayborg, jingham, jasonmolenda, labath.
davide added a comment.

thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D45592



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


[Lldb-commits] [PATCH] D45554: Make sure deleting all breakpoints clears their sites first

2018-04-13 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Sure, if somebody has the time fixing this to use weak pointers would be great.

But that doesn't seem like the real issue to me.

When a breakpoint gets removed from the Target BreakpointList(s), regardless of 
who else is holding onto it, it needs to get its breakpoint sites removed 
(since the Target can no longer reason about them they will look like 
unrecognized traps.)  We can't rely on Destructors to do this as long as we are 
handing out BreakpointSP's.  So you still need an explicit operation to clear 
the breakpoint sites.

I can't think of any compelling use for preserving a Breakpoint once it is 
removed from the Target.  So I'm pretty convinced we should go to the model 
where removing a Breakpoint from the Target's BreakpointList immediately 
deletes the Breakpoint.  Then we can fix this dependency so the destructors do 
the right thing.  Note, for the sake of making an important step less indirect, 
I would vote to also have the Breakpoint destructor call ClearBreakpointSites().

This is a more intrusive change, since it means either that everybody who is 
now holding BreakpointSP's should switch over to holding BreakpointID's or 
BreakpointWP's.  But that models more closely what should happen with 
breakpoints.


https://reviews.llvm.org/D45554



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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2937-2938
 {
   static const char *debug_prefix = ".debug";
+  static const char *zdebug_prefix = ".zdebug";
 

Might be worth making these llvm::StringRef, then see comments below..



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2948
 
   const char *section_name = section->GetName().GetCString();
   // Can't relocate that which can't be named

Make this a StringRef:

```
llvm::StringRef section_name = section->GetName().GetStringRef();
```



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2954-2955
   // We don't relocate non-debug sections at the moment
-  if (strncmp(section_name, debug_prefix, strlen(debug_prefix)))
+  if (strncmp(section_name, debug_prefix, strlen(debug_prefix)) ||
+  strncmp(section_name, zdebug_prefix, strlen(zdebug_prefix)))
 return;

use StringRef::startswith:

```
if (section_name.startswith(debug_prefix) || 
section_name.startswith(zdebug_prefix))
```



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3451
+  if (!llvm::object::Decompressor::isCompressedELFSection(
+  section->Get(), section->GetName().GetStringRef()))
 return ObjectFile::ReadSectionData(section, section_offset, dst, dst_len);

use "section_name" here instead of "section->GetName().GetStringRef()" since we 
switched it to a StringRef



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3472
+ section->Get(), section->GetName().GetStringRef()))
 return result;
 

Ditto


https://reviews.llvm.org/D45628



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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

If this is for current and future debugging, it would be nice to change the 
tool to just use the normal .debug prefixes and just specify SHF_COMPRESSED???


https://reviews.llvm.org/D45628



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


Re: [Lldb-commits] [PATCH] D45592: Allow relative file paths when settings source breakpoints

2018-04-13 Thread Davide Italiano via lldb-commits
thanks!

On Fri, Apr 13, 2018 at 8:10 AM, Greg Clayton via Phabricator
 wrote:
> clayborg marked 2 inline comments as done.
> clayborg added a comment.
>
> Didn't update the diffs, but I did fix the things Davide requested before 
> submission
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D45592
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r330047 - [Command] Simplify the code and make it less error prone. NFCI.

2018-04-13 Thread Davide Italiano via lldb-commits
Author: davide
Date: Fri Apr 13 11:37:14 2018
New Revision: 330047

URL: http://llvm.org/viewvc/llvm-project?rev=330047=rev
Log:
[Command] Simplify the code and make it less error prone. NFCI.

Pointed out by Jim.

Modified:
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=330047=330046=330047=diff
==
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Apr 13 11:37:14 
2018
@@ -623,10 +623,7 @@ bool CommandObjectExpression::DoExecute(
   if (expr == nullptr)
 expr = command;
 
-  Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
-  if (!target)
-target = GetDummyTarget();
-
+  Target *target = GetSelectedOrDummyTarget();
   if (EvaluateExpression(expr, &(result.GetOutputStream()),
  &(result.GetErrorStream()), )) {
 

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=330047=330046=330047=diff
==
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Apr 13 11:37:14 2018
@@ -722,9 +722,7 @@ protected:
 
 // Increment statistics.
 bool res = result.Succeeded();
-Target *target = m_exe_ctx.GetTargetPtr();
-if (!target)
-  target = GetDummyTarget();
+Target *target = GetSelectedOrDummyTarget();
 if (res)
   target->IncrementStats(StatisticKind::FrameVarSuccess);
 else


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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Davide Italiano via Phabricator via lldb-commits
davide added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1773-1781
+static SectionType getSectionType(llvm::StringRef section_name) {
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+mapped_name = section_name.drop_front(2);
+  } else if (!section_name.startswith(".")) {
+return eSectionTypeOther;
+  } else {

Thanks! This was exactly what I had in mind. Do you mind to split the NFC 
changes into a separate patch (that can be committed without review)? This will 
make this patch much easier to review.


https://reviews.llvm.org/D45628



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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Erik Welander via Phabricator via lldb-commits
alur added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1893
 sect_type = eSectionTypeDWARFDebugAbbrev;
-  else if (name == g_sect_name_dwarf_debug_addr)
+  else if (name == g_sect_name_dwarf_debug_addr ||
+   name == g_sect_name_dwarf_zdebug_addr)

aprantl wrote:
> Could this entire device be replaced by a llvm::StringSwitch or something 
> else more elegant?
I moved it out into a separate method with a StringSwitch



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3451
+  if (!llvm::object::Decompressor::isCompressedELFSection(
+  section->Get(), section->GetName().GetStringRef()))
 return ObjectFile::ReadSectionData(section, section_offset, dst, dst_len);

clayborg wrote:
> use "section_name" here instead of "section->GetName().GetStringRef()" since 
> we switched it to a StringRef
This is a separate method, which doesn't have a section_name variable.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3472
+ section->Get(), section->GetName().GetStringRef()))
 return result;
 

clayborg wrote:
> Ditto
Same here.


https://reviews.llvm.org/D45628



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


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Erik Welander via Phabricator via lldb-commits
alur updated this revision to Diff 142478.
alur marked 7 inline comments as done.
alur added a comment.

I refactored the code to address the comments on it. I'll add those tests once 
I get the test runner to work.


https://reviews.llvm.org/D45628

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1770,6 +1770,68 @@
   return 0;
 }
 
+static SectionType getSectionType(llvm::StringRef section_name) {
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+mapped_name = section_name.drop_front(2);
+  } else if (!section_name.startswith(".")) {
+return eSectionTypeOther;
+  } else {
+mapped_name = section_name.drop_front(1);
+  }
+
+  // MISSING? .gnu_debugdata - "mini debuginfo / MiniDebugInfo" section,
+  // http://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html
+  // MISSING? .debug-index -
+  // http://src.chromium.org/viewvc/chrome/trunk/src/build/gdb-add-index?pathrev=144644
+  // MISSING? .debug_types - Type descriptions from DWARF 4? See
+  // http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
+  return llvm::StringSwitch(mapped_name)
+  .Case("text", eSectionTypeCode)
+  .Case("data", eSectionTypeData)
+  .Case("bss", eSectionTypeZeroFill)
+  .Case("tdata", eSectionTypeData)
+  .Case("tbss", eSectionTypeZeroFill)
+  // Abbreviations used in the .debug_info section
+  .Case("debug_abbrev", eSectionTypeDWARFDebugAbbrev)
+  .Case("debug_abbrev.dwo", eSectionTypeDWARFDebugAbbrev)
+  .Case("debug_addr", eSectionTypeDWARFDebugAddr)
+  // Lookup table for mapping addresses to compilation units
+  .Case("debug_aranges", eSectionTypeDWARFDebugAranges)
+  .Case("debug_cu_index", eSectionTypeDWARFDebugCuIndex)
+  // Call frame information
+  .Case("debug_frame", eSectionTypeDWARFDebugFrame)
+  // The core DWARF information section
+  .Case("debug_info", eSectionTypeDWARFDebugInfo)
+  .Case("debug_info.dwo", eSectionTypeDWARFDebugInfo)
+  // Line number information
+  .Case("debug_line", eSectionTypeDWARFDebugLine)
+  .Case("debug_line.dwo", eSectionTypeDWARFDebugLine)
+  // Location lists used in DW_AT_location attributes
+  .Case("debug_loc", eSectionTypeDWARFDebugLoc)
+  .Case("debug_loc.dwo", eSectionTypeDWARFDebugLoc)
+  // Macro information
+  .Case("debug_macinfo", eSectionTypeDWARFDebugMacInfo)
+  .Case("debug_macro", eSectionTypeDWARFDebugMacro)
+  .Case("debug_macro.dwo", eSectionTypeDWARFDebugMacro)
+  // Lookup table for mapping object and function names to compilation units
+  .Case("debug_pubnames", eSectionTypeDWARFDebugPubNames)
+  // Lookup table for mapping type names to compilation units
+  .Case("debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
+  // Address ranges used in DW_AT_ranges attributes
+  .Case("debug_ranges", eSectionTypeDWARFDebugRanges)
+  // String table used in .debug_info
+  .Case("debug_str", eSectionTypeDWARFDebugStr)
+  .Case("debug_str.dwo", eSectionTypeDWARFDebugStr)
+  .Case("debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
+  .Case("debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsets)
+  .Case("eh_frame", eSectionTypeEHFrame)
+  .Case("ARM.exidx", eSectionTypeARMexidx)
+  .Case("ARM.extab", eSectionTypeARMextab)
+  .Case("gosymtab", eSectionTypeGoSymtab)
+  .Default(eSectionTypeOther);
+}
+
 void ObjectFileELF::CreateSections(SectionList _section_list) {
   if (!m_sections_ap.get() && ParseSectionHeaders()) {
 m_sections_ap.reset(new SectionList());
@@ -1784,135 +1846,14 @@
  I != m_section_headers.end(); ++I) {
   const ELFSectionHeaderInfo  = *I;
 
-  ConstString  = I->section_name;
+  llvm::StringRef section_name = I->section_name.GetStringRef();
   const uint64_t file_size =
   header.sh_type == SHT_NOBITS ? 0 : header.sh_size;
   const uint64_t vm_size = header.sh_flags & SHF_ALLOC ? header.sh_size : 0;
 
-  static ConstString g_sect_name_text(".text");
-  static ConstString g_sect_name_data(".data");
-  static ConstString g_sect_name_bss(".bss");
-  static ConstString g_sect_name_tdata(".tdata");
-  static ConstString g_sect_name_tbss(".tbss");
-  static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev");
-  static ConstString g_sect_name_dwarf_debug_addr(".debug_addr");
-  static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges");
-  static ConstString g_sect_name_dwarf_debug_cu_index(".debug_cu_index");
-  static ConstString g_sect_name_dwarf_debug_frame(".debug_frame");
-  static ConstString g_sect_name_dwarf_debug_info(".debug_info");
-  static ConstString g_sect_name_dwarf_debug_line(".debug_line");
-   

[Lldb-commits] [lldb] r330002 - Prevent deadlock in OS Plugins

2018-04-13 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Fri Apr 13 03:25:23 2018
New Revision: 330002

URL: http://llvm.org/viewvc/llvm-project?rev=330002=rev
Log:
Prevent deadlock in OS Plugins

Summary:
When performing a synchronous resume, the API mutex is held until the
process is stopped. This is fine, except for when the OS plugins are processing
an event before the main thread is aware of it, in which case we end up with a
deadlock because in the internal thread we acquire a resource lock first, and
then wait for the API lock, while in the main thread we do the opposite, we
already hold the API mutex but are now waiting for the event mutex to handle
the event.

This patch fixes this by relaxing the need for the API lock in the OS plugins.
We can get away with this because we now this code is executed in the main
thread. As stated in the comment above, we just want to ensure nobody else
messes with the API while we're making a change. In theory it's possible that
the main thread would release the lock while we're executing the function, but
prevent this would require a more structural solution (which we want, but do
not have today).

The same workaround was already present, but this patch generalizes it to the
whole file.

This will allow me to re-land r329891.

Reviewers: clayborg, jingham, labath

Subscribers: llvm-commits, lldb-commits

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

Modified:
lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp

Modified: 
lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp?rev=330002=330001=330002=diff
==
--- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp 
(original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp 
Fri Apr 13 03:25:23 2018
@@ -156,9 +156,10 @@ bool OperatingSystemPython::UpdateThread
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
 
-  // First thing we have to do is to try to get the API lock, and the run lock.
-  // We're going to change the thread content of the process, and we're going
-  // to use python, which requires the API lock to do it.
+  // First thing we have to do is to try to get the API lock, and the
+  // interpreter lock. We're going to change the thread content of the process,
+  // and we're going to use python, which requires the API lock to do it. We
+  // need the interpreter lock to make sure thread_info_dict stays alive.
   //
   // If someone already has the API lock, that is ok, we just want to avoid
   // external code from making new API calls while this call is happening.
@@ -166,9 +167,10 @@ bool OperatingSystemPython::UpdateThread
   // This is a recursive lock so we can grant it to any Python code called on
   // the stack below us.
   Target  = m_process->GetTarget();
-  std::unique_lock lock(target.GetAPIMutex(),
-  std::defer_lock);
-  lock.try_lock();
+  std::unique_lock api_lock(target.GetAPIMutex(),
+  std::defer_lock);
+  api_lock.try_lock();
+  auto interpreter_lock = m_interpreter->AcquireInterpreterLock();
 
   if (log)
 log->Printf("OperatingSystemPython::UpdateThreadList() fetching thread "
@@ -176,12 +178,8 @@ bool OperatingSystemPython::UpdateThread
 m_process->GetID());
 
   // The threads that are in "new_thread_list" upon entry are the threads from
-  // the
-  // lldb_private::Process subclass, no memory threads will be in this list.
-
-  auto interpreter_lock =
-  m_interpreter
-  ->AcquireInterpreterLock(); // to make sure threads_list stays alive
+  // the lldb_private::Process subclass, no memory threads will be in this
+  // list.
   StructuredData::ArraySP threads_list =
   m_interpreter->OSPlugin_ThreadsInfo(m_python_object_sp);
 
@@ -301,20 +299,24 @@ OperatingSystemPython::CreateRegisterCon
   if (!IsOperatingSystemPluginThread(thread->shared_from_this()))
 return reg_ctx_sp;
 
-  // First thing we have to do is get the API lock, and the run lock.  We're
-  // going to change the thread
-  // content of the process, and we're going to use python, which requires the
-  // API lock to do it.
-  // So get & hold that.  This is a recursive lock so we can grant it to any
-  // Python code called on the stack below us.
+  // First thing we have to do is to try to get the API lock, and the
+  // interpreter lock. We're going to change the thread content of the process,
+  // and we're going to use python, which requires the API lock to do it. We
+  // need the interpreter lock to make sure thread_info_dict stays alive.
+  //
+  // If someone already has the API lock, that is ok, we just want to avoid
+  // external code from making new API calls while this call is 

[Lldb-commits] [PATCH] D45592: Allow relative file paths when settings source breakpoints

2018-04-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg marked 2 inline comments as done.
clayborg added a comment.

Didn't update the diffs, but I did fix the things Davide requested before 
submission


Repository:
  rL LLVM

https://reviews.llvm.org/D45592



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


[Lldb-commits] [lldb] r330005 - Re-land "Don't assume backing thread shares protocol ID."

2018-04-13 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Fri Apr 13 04:31:34 2018
New Revision: 330005

URL: http://llvm.org/viewvc/llvm-project?rev=330005=rev
Log:
Re-land "Don't assume backing thread shares protocol ID."

When we're dealing with virtual (memory) threads created by the OS
plugins, there's no guarantee that the real thread and the backing
thread share a protocol ID. Instead, we should iterate over the memory
threads to find the virtual thread that is backed by the current real
thread.

Differential revision: https://reviews.llvm.org/D45497

rdar://36485830

The original revision (r329891) was reverted because the associated
tests ran into a deadlock on the Linux bots. That problem was resolved
by r330002.

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py
Modified:
lldb/trunk/include/lldb/Target/ThreadList.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Target/ThreadList.cpp

Modified: lldb/trunk/include/lldb/Target/ThreadList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadList.h?rev=330005=330004=330005=diff
==
--- lldb/trunk/include/lldb/Target/ThreadList.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadList.h Fri Apr 13 04:31:34 2018
@@ -102,6 +102,8 @@ public:
 
   lldb::ThreadSP GetThreadSPForThreadPtr(Thread *thread_ptr);
 
+  lldb::ThreadSP GetBackingThread(const lldb::ThreadSP _thread);
+
   bool ShouldStop(Event *event_ptr);
 
   Vote ShouldReportStop(Event *event_ptr);

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py?rev=330005=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py
 Fri Apr 13 04:31:34 2018
@@ -0,0 +1,50 @@
+from __future__ import print_function
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestThreadSelectionBug(GDBRemoteTestBase):
+def test(self):
+class MyResponder(MockGDBServerResponder):
+def cont(self):
+# Simulate process stopping due to a raise(SIGINT)
+return "T01reason:signal"
+
+self.server.responder = MyResponder()
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+python_os_plugin_path = os.path.join(self.getSourceDir(),
+ 'operating_system.py')
+command = "settings set target.process.python-os-plugin-path 
'{}'".format(
+python_os_plugin_path)
+self.dbg.HandleCommand(command)
+
+self.assertTrue(process, PROCESS_IS_VALID)
+self.assertEqual(process.GetNumThreads(), 3)
+
+# Verify our OS plug-in threads showed up
+thread = process.GetThreadByID(0x1)
+self.assertTrue(
+thread.IsValid(),
+"Make sure there is a thread 0x1 after we load the python OS 
plug-in")
+thread = process.GetThreadByID(0x2)
+self.assertTrue(
+thread.IsValid(),
+"Make sure there is a thread 0x2 after we load the python OS 
plug-in")
+thread = process.GetThreadByID(0x3)
+self.assertTrue(
+thread.IsValid(),
+"Make sure there is a thread 0x3 after we load the python OS 
plug-in")
+
+# Verify that a thread other than 3 is selected.
+thread = process.GetSelectedThread()
+self.assertNotEqual(thread.GetThreadID(), 0x3)
+
+# Verify that we select the thread backed by physical thread 1, rather
+# than virtual thread 1. The mapping comes from the OS plugin, where we
+# specified that thread 3 is backed by real thread 1.
+process.Continue()
+thread = process.GetSelectedThread()
+self.assertEqual(thread.GetThreadID(), 0x3)

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py?rev=330005=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py
 Fri Apr 13 

[Lldb-commits] [PATCH] D45554: Make sure deleting all breakpoints clears their sites first

2018-04-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In https://reviews.llvm.org/D45554#1066730, @eugene wrote:

> There is an ownership cycle between BreakpointSite::m_owners and 
> BreakpointLocation::m_bp_site_sp.
>  We should probably make m_owners a collection of weak references. 
>  But currently most of the code just works it around by calling 
> Breakpoint::ClearAllBreakpointSites() before deleting a breakpoint.


Anytime there is a clear hierarchy we should use shared and weak pointers 
correctly. I would vote to fix this issue.


https://reviews.llvm.org/D45554



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


[Lldb-commits] [PATCH] D45592: Allow relative file paths when settings source breakpoints

2018-04-13 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330028: Allow relative file paths when settings source 
breakpoints (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45592?vs=142289=142413#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45592

Files:
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
  lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
@@ -576,7 +576,7 @@
 if 'file' in break_results:
 out_file_name = break_results['file']
 test.assertTrue(
-file_name == out_file_name,
+file_name.endswith(out_file_name),
 "Breakpoint file name '%s' doesn't match resultant name '%s'." %
 (file_name,
  out_file_name))
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -62,7 +62,31 @@
 # setting breakpoint commands on two breakpoints at a time
 lldbutil.run_break_set_by_file_and_line(
 self, None, self.line, num_expected_locations=1, loc_exact=True)
-
+# Make sure relative path source breakpoints work as expected. We test
+# with partial paths with and without "./" prefixes.
+lldbutil.run_break_set_by_file_and_line(
+self, "./main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "breakpoint_command/main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "./breakpoint_command/main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "breakpoint/breakpoint_command/main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "./breakpoint/breakpoint_command/main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+# Test relative breakpoints with incorrect paths and make sure we get
+# no breakpoint locations
+lldbutil.run_break_set_by_file_and_line(
+self, "invalid/main.c", self.line,
+num_expected_locations=0, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "./invalid/main.c", self.line,
+num_expected_locations=0, loc_exact=True)
 # Now add callbacks for the breakpoints just created.
 self.runCmd(
 "breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4")
Index: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
===
--- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -115,15 +115,35 @@
 // here is handling inlined functions -- in this case we need to make sure we
 // look at the declaration line of the inlined function, NOT the function it was
 // inlined into.
-void BreakpointResolverFileLine::FilterContexts(SymbolContextList _list) {
+void BreakpointResolverFileLine::FilterContexts(SymbolContextList _list,
+bool is_relative) {
   if (m_exact_match)
 return; // Nothing to do. Contexts are precise.
 
+  llvm::StringRef relative_path;
+  if (is_relative)
+relative_path = m_file_spec.GetNormalizedPath().GetDirectory().GetStringRef();
+
   Log * log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
   for(uint32_t i = 0; i < sc_list.GetSize(); ++i) {
 SymbolContext sc;
 sc_list.GetContextAtIndex(i, sc);
-if (! sc.block)
+if (is_relative) {
+  // If the path was relative, make sure any matches match as long as the
+  // relative parts of the path match the path from support files
+  auto sc_dir = sc.line_entry.file.GetDirectory().GetStringRef();
+  if (!sc_dir.endswith(relative_path)) {
+// We had a relative path specified and the relative directory
+// doesn't match so