Re: [Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-11 Thread Adrian McCarthy via lldb-commits
It's really frustrating how the email discussion doesn't always make it to
Phabricator.

The Windowsy thing to do is what Zach said:  Check the directory that
contains the .dmp for the .pdb.  It's the first place the VS debugger looks
when opening a minidump.  It's less sensitive to the user's environment.
(Making the user change the current working directory for this could be at
odds with other bits of the software that look relative the cwd.)

https://docs.microsoft.com/en-us/visualstudio/debugger/using-dump-files?view=vs-2017#BKMK_Find_binaries__symbol___pdb__files__and_source_files

While security is not a big issue here, note that Windows generally
searches for DLLs in the known/expected places _before_ checking to see if
it's in the current working directory.  This prevents a sneaky download
from effectively replacing a DLL.  Replacing a PDB is probably less of a
concern.

https://docs.microsoft.com/en-us/windows/desktop/dlls/dynamic-link-library-search-order#standard-search-order-for-desktop-applications

So I +1 Zach's proposal.

On Tue, Dec 11, 2018 at 12:07 PM Leonard Mosescu  wrote:

> I think as combination of explicit symbol search path + something similar
> to Microsoft's symsrv would be a good "real" solution (and yes, that would
> be packaged as a SymbolVendor, outside SymbolFilePDB)
>
> For short term, I don't see a clearly superior alternative to searching
> the current directory.
>
> On Tue, Dec 11, 2018 at 12:02 PM Pavel Labath  wrote:
>
>> On 11/12/2018 20:34, Zachary Turner wrote:
>> > I meant the location of the minidump.  So if you have C:\A\B\C\foo.dmp
>> > which is the dump file for bar.exe which crashed on another machine,
>> > then it would look for C:\A\B\C\bar.pdb.  That actually seems like
>> > fairly intuitive behavior to me, but maybe I'm in the minority :)
>> >
>> > We can see what Pavel, Adrian, and others think though or if they have
>> > any other suggestions.
>> >
>>
>> It sounds like there is a precedent for searching in CWD. I don't know
>> how useful it is (I traced it back to r185366, but it is not mentioned
>> there specifically), but it is there, and I guess it's not completely
>> nonsensical from the POV of a command line user.
>>
>> I guess we can just keep that there and not call it a hack (though, the
>> fact that the searching happens inside SymbolFilePDB *is* a hack).
>>
>> Searching in the minidump directory would also make sense somewhat, but
>> I expect you would need more plumbing for that to happen (and I don't
>> know of a precedent for that).
>>
>> pl
>>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-11 Thread Adrian McCarthy via lldb-commits
I believe the PDB is searched for in the EXE directory before the symbol
search path is used.  At least, that's what it used to do, back when I used
VS debugger for post-mortem debugging.  It was the only sane way to ensure
it would find the right version of the PDB if you didn't have a local
symbol server.

Yes, I understand that the security note was about DLL loading.  My point
was that, in general, Windows looks in well known places first, before
checking the current working directory.

On Tue, Dec 11, 2018 at 2:12 PM Leonard Mosescu  wrote:

> The Windowsy thing to do is what Zach said:  Check the directory that
>> contains the .dmp for the .pdb.  It's the first place the VS debugger looks
>> when opening a minidump.  It's less sensitive to the user's environment.
>> (Making the user change the current working directory for this could be at
>> odds with other bits of the software that look relative the cwd.)
>>
>> https://docs.microsoft.com/en-us/visualstudio/debugger/using-dump-files?view=vs-2017#BKMK_Find_binaries__symbol___pdb__files__and_source_files
>>
>
> Except that it doesn't :) Neither VisualStudio nor the Windows Debuggers
> (windbg & co) look for PDBs in the same directory as the dump file. The
> search is controlled by an explicit "symbol search path". The link you
> mentioned is a bit confusing indeed (although it only claims that the
> .exe's are searched in the same directory as the .dmp)
>
> While security is not a big issue here, note that Windows generally
>> searches for DLLs in the known/expected places _before_ checking to see if
>> it's in the current working directory.  This prevents a sneaky download
>> from effectively replacing a DLL.  Replacing a PDB is probably less of a
>> concern.
>>
>> https://docs.microsoft.com/en-us/windows/desktop/dlls/dynamic-link-library-search-order#standard-search-order-for-desktop-applications
>>
>
> This is about the runtime dynamic module loader, not the debugger.
>
>
>
>
> On Tue, Dec 11, 2018 at 1:28 PM Adrian McCarthy 
> wrote:
>
>> It's really frustrating how the email discussion doesn't always make it
>> to Phabricator.
>>
>> The Windowsy thing to do is what Zach said:  Check the directory that
>> contains the .dmp for the .pdb.  It's the first place the VS debugger looks
>> when opening a minidump.  It's less sensitive to the user's environment.
>> (Making the user change the current working directory for this could be at
>> odds with other bits of the software that look relative the cwd.)
>>
>>
>> https://docs.microsoft.com/en-us/visualstudio/debugger/using-dump-files?view=vs-2017#BKMK_Find_binaries__symbol___pdb__files__and_source_files
>>
>> While security is not a big issue here, note that Windows generally
>> searches for DLLs in the known/expected places _before_ checking to see if
>> it's in the current working directory.  This prevents a sneaky download
>> from effectively replacing a DLL.  Replacing a PDB is probably less of a
>> concern.
>>
>>
>> https://docs.microsoft.com/en-us/windows/desktop/dlls/dynamic-link-library-search-order#standard-search-order-for-desktop-applications
>>
>> So I +1 Zach's proposal.
>>
>> On Tue, Dec 11, 2018 at 12:07 PM Leonard Mosescu 
>> wrote:
>>
>>> I think as combination of explicit symbol search path + something
>>> similar to Microsoft's symsrv would be a good "real" solution (and yes,
>>> that would be packaged as a SymbolVendor, outside SymbolFilePDB)
>>>
>>> For short term, I don't see a clearly superior alternative to searching
>>> the current directory.
>>>
>>> On Tue, Dec 11, 2018 at 12:02 PM Pavel Labath  wrote:
>>>
 On 11/12/2018 20:34, Zachary Turner wrote:
 > I meant the location of the minidump.  So if you have
 C:\A\B\C\foo.dmp
 > which is the dump file for bar.exe which crashed on another machine,
 > then it would look for C:\A\B\C\bar.pdb.  That actually seems like
 > fairly intuitive behavior to me, but maybe I'm in the minority :)
 >
 > We can see what Pavel, Adrian, and others think though or if they
 have
 > any other suggestions.
 >

 It sounds like there is a precedent for searching in CWD. I don't know
 how useful it is (I traced it back to r185366, but it is not mentioned
 there specifically), but it is there, and I guess it's not completely
 nonsensical from the POV of a command line user.

 I guess we can just keep that there and not call it a hack (though, the
 fact that the searching happens inside SymbolFilePDB *is* a hack).

 Searching in the minidump directory would also make sense somewhat, but
 I expect you would need more plumbing for that to happen (and I don't
 know of a precedent for that).

 pl

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


Re: [Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-11 Thread Adrian McCarthy via lldb-commits
>  But here, we're talking about a situation where there is no EXE, only a
minidump.  If there is a minidump and no EXE then neither WinDbg nor VS
will search the minidump folder for the PDB.

For the record, the experiments do not bear this out.  VS will indeed
search in the minidump folder for the PDB.  Unfortunately, a lot of this
conversation was taken offline.

On Tue, Dec 11, 2018 at 3:30 PM Zachary Turner via Phabricator <
revi...@reviews.llvm.org> wrote:

> zturner added a comment.
>
> In D55142#1326247 , @lemo wrote:
>
> > > How large is the PDB file here?
> >
> > ~100kb
>
>
> We have a couple of tests in LLVM where PDB files are checked in, but they
> are very few.  We cannot explode the repo with large numbers of binary
> files.  So this is probably fine, but if this becomes a pattern, we will
> need to come up with a different solution.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D55142/new/
>
> https://reviews.llvm.org/D55142
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] Support of MSVC function-level linking

2018-05-31 Thread Adrian McCarthy via lldb-commits
Can you post your patch to https://reviews.llvm.org/ ?

On Thu, May 31, 2018 at 10:36 AM, Leonard Mosescu via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> If anyone's working on this I'd suggest adding a test case for the "split
> code" case as well (where even a single function is split into multiple
> ranges). MSVC with PGO should help produce hot/cold cold split repros.
>
> On Thu, May 31, 2018 at 10:24 AM, Greg Clayton via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
>>
>>
>> On May 31, 2018, at 2:31 AM, Aleksandr Urakov via lldb-commits <
>> lldb-commits@lists.llvm.org> wrote:
>>
>> Hello!
>>
>> I'm Aleksandr from JetBrains. We are working on improving support of
>> MSVC-compiled binaries in lldb. We have made several fixes and would like
>> to upstream them.
>>
>> The first patch adds support of function-level linking feature. The
>> SymbolFilePDB::ParseCompileUnitLineTable function relies on the fact
>> that ranges of compiled source files in the binary are continuous and don't
>> intersect with each other. ParseCompileUnitLineTable creates LineSequence
>> for each file and inserts it into LineTable, and the implementation of
>> LineTable relies on continuity of the sequence. But it's not always true
>> when function-level linking is enabled, e.g. in the attached input test
>> file test-pdb-function-level-linking.exe there is xstring's
>> std__basic_string_char_std__char_traits_char__std__allocator_char_max_size
>> (.00454820) between test-pdb-function-level-linking.cpp's foo
>> (.00454770) and main (.004548F0). The source is compiled with Microsoft
>> C/C++ compiler version 19.14.26429.4 for x86.
>>
>> To fix the problem we propose to renew the sequence on each address gap.
>>
>>
>> That is what DWARF does as well. A line table can have many sequences
>> where each sequence is a vector of rows whose addresses must always
>> increase or stay the same. The line tables we have in LLDB mimic the DWARF
>> line tables in many ways.
>>
>>
>>
>> The link to the patch and related files is: https://drive.google.com/o
>> pen?id=1ozp06jyqugjLGT-6wuJKS1UhRuXFsixf
>>
>> Thanks!
>>
>> --
>> Aleksandr Urakov
>> Software Developer
>> JetBrains
>> http://www.jetbrains.com
>> The Drive to Develop
>> ___
>> 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 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] r320242 - Change uses of strncpy in debugserver to strlcpy

2017-12-11 Thread Adrian McCarthy via lldb-commits
I have some concerns about this change.

1.  strlcpy is not a C++ standard function, so it's not available for
non-POSIX targets.  As far as I can tell, this is the first use of strlcpy
in LLVM.

2.  In some of the changed calls, the buffer size argument still has a -1,
which is redundant with what strlcpy is going to do, so this could cause
strings to be truncated a char too soon.

3.  At some of the call sites, there remains now-redundant code to
guarantee termination.. Since that's the point of changing these calls, we
should probably eliminate that.

4.  I'm not familiar with this part of the code base.  Is it necessary for
the APIs to work with pointer+length rather than a std::string (or other
class) that would give us safety and portability?

On Sun, Dec 10, 2017 at 3:52 PM, Davide Italiano via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> On Fri, Dec 8, 2017 at 7:37 PM, Jason Molenda via lldb-commits
>  wrote:
> > Author: jmolenda
> > Date: Fri Dec  8 19:37:09 2017
> > New Revision: 320242
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=320242&view=rev
> > Log:
> > Change uses of strncpy in debugserver to strlcpy
> > for better safety.
> >
> > 
> >
>
> Thanks!
> ___
> 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] [lldb] r324925 - Remove dead code for handling DWARF pubnames

2018-02-12 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Mon Feb 12 11:19:04 2018
New Revision: 324925

URL: http://llvm.org/viewvc/llvm-project?rev=324925&view=rev
Log:
Remove dead code for handling DWARF pubnames

Summary:
LLDB doesn't use this code, the code has no tests, and the code does suspicious
things like hashing pointers to strings instead of the strings themselves.

Subscribers: sanjoy, mgorny, JDevlieghere

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

Removed:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt?rev=324925&r1=324924&r2=324925&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt Mon Feb 12 
11:19:04 2018
@@ -17,8 +17,6 @@ add_lldb_library(lldbPluginSymbolFileDWA
   DWARFDebugMacro.cpp
   DWARFDebugMacinfo.cpp
   DWARFDebugMacinfoEntry.cpp
-  DWARFDebugPubnames.cpp
-  DWARFDebugPubnamesSet.cpp
   DWARFDebugRanges.cpp
   DWARFDeclContext.cpp
   DWARFDefines.cpp

Removed: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp?rev=324924&view=auto
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp (removed)
@@ -1,255 +0,0 @@
-//===-- DWARFDebugPubnames.cpp --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "DWARFDebugPubnames.h"
-
-#include "lldb/Utility/Stream.h"
-#include "lldb/Utility/Timer.h"
-
-#include "DWARFCompileUnit.h"
-#include "DWARFDIECollection.h"
-#include "DWARFDebugInfo.h"
-#include "DWARFFormValue.h"
-#include "LogChannelDWARF.h"
-#include "SymbolFileDWARF.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-DWARFDebugPubnames::DWARFDebugPubnames() : m_sets() {}
-
-bool DWARFDebugPubnames::Extract(const DWARFDataExtractor &data) {
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat,
- "DWARFDebugPubnames::Extract (byte_size = %" PRIu64 ")",
- (uint64_t)data.GetByteSize());
-  Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
-  if (log)
-log->Printf("DWARFDebugPubnames::Extract (byte_size = %" PRIu64 ")",
-(uint64_t)data.GetByteSize());
-
-  if (data.ValidOffset(0)) {
-lldb::offset_t offset = 0;
-
-DWARFDebugPubnamesSet set;
-while (data.ValidOffset(offset)) {
-  if (set.Extract(data, &offset)) {
-m_sets.push_back(set);
-offset = set.GetOffsetOfNextEntry();
-  } else
-break;
-}
-if (log)
-  Dump(log);
-return true;
-  }
-  return false;
-}
-
-bool DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF *dwarf2Data) {
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat,
- "DWARFDebugPubnames::GeneratePubnames (data = %p)",
- static_cast(dwarf2Data));
-
-  Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
-  if (log)
-log->Printf("DWARFDebugPubnames::GeneratePubnames (data = %p)",
-static_cast(dwarf2Data));
-
-  m_sets.clear();
-  DWARFDebugInfo *debug_info = dwarf2Data->DebugInfo();
-  if (debug_info) {
-uint32_t cu_idx = 0;
-const uint32_t num_compile_units = dwarf2Data->GetNumCompileUnits();
-for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
-
-  DWARFCompileUnit *cu = debug_info->GetCompileUnitAtIndex(cu_idx);
-
-  DWARFFormValue::FixedFormSizes fixed_form_sizes =
-  DWARFFormValue::GetFixedFormSizesForAddressSize(
-  cu->GetAddressByteSize(), cu->IsDWARF64());
-
-  bool clear_dies = cu->ExtractDIEsIfNeeded(false) > 1;
-
-  DWARFDIECollection dies;
-  const size_t die_count = cu->AppendDIEsWithTag(DW_TAG_subprogram, dies) +
-   cu->AppendDIEsWithTag(DW_TAG_variable, dies);
-
-  dw_offs

[Lldb-commits] [lldb] r325188 - Supply missing break in case statement.

2018-02-14 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Feb 14 15:16:36 2018
New Revision: 325188

URL: http://llvm.org/viewvc/llvm-project?rev=325188&view=rev
Log:
Supply missing break in case statement.

Summary:
All the tests pass without hitting the situation mentioned in the FIXME, so,
per Aaron Smith's suggestion, this case will now return unconditionally.

Subscribers: sanjoy, mgorny, JDevlieghere

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

Modified:
lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp?rev=325188&r1=325187&r2=325188&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp Wed Feb 14 
15:16:36 2018
@@ -107,9 +107,7 @@ CompilerType GetBuiltinTypeForPDBEncodin
   case PDB_BuiltinType::None:
 return CompilerType();
   case PDB_BuiltinType::Void:
-// FIXME: where is non-zero size of `void` from?
-if (width == 0)
-  return clang_ast->GetBasicType(eBasicTypeVoid);
+return clang_ast->GetBasicType(eBasicTypeVoid);
   case PDB_BuiltinType::Bool:
 return clang_ast->GetBasicType(eBasicTypeBool);
   case PDB_BuiltinType::Long:


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


[Lldb-commits] [lldb] r325704 - Fix TestBreakpointInGlobalConstructor for Windows

2018-02-21 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Feb 21 10:08:23 2018
New Revision: 325704

URL: http://llvm.org/viewvc/llvm-project?rev=325704&view=rev
Log:
Fix TestBreakpointInGlobalConstructor for Windows

Summary:
This test was failing on Windows because it expected the breakpoint in the
dynamic library to be resolved before the process is launched.  Since the DLL
isn't loaded until the process is launched this didn't work.

The fix creates a special value (-2) for num_expected_locations that ignores
the actual number of breakpoint locations found.

Reviewers: jasonmolenda

Subscribers: sanjoy, lldb-commits

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py?rev=325704&r1=325703&r2=325704&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
 Wed Feb 21 10:08:23 2018
@@ -29,8 +29,9 @@ class TestBreakpointInGlobalConstructors
 
 bp_main = lldbutil.run_break_set_by_file_and_line(
 self, 'main.cpp', self.line_main)
+
 bp_foo = lldbutil.run_break_set_by_file_and_line(
-self, 'foo.cpp', self.line_foo)
+self, 'foo.cpp', self.line_foo, num_expected_locations=-2)
 
 process = target.LaunchSimple(
 None, env, self.get_process_working_directory())

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py?rev=325704&r1=325703&r2=325704&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py Wed Feb 21 10:08:23 
2018
@@ -343,7 +343,8 @@ def run_break_set_by_file_and_line(
 
 If extra_options is not None, then we append it to the breakpoint set 
command.
 
-If num_expected_locations is -1 we check that we got AT LEAST one 
location, otherwise we check that num_expected_locations equals the number of 
locations.
+If num_expected_locations is -1, we check that we got AT LEAST one 
location. If num_expected_locations is -2, we don't
+check the actual number at all. Otherwise, we check that 
num_expected_locations equals the number of locations.
 
 If loc_exact is true, we check that there is one location, and that 
location must be at the input file and line number."""
 
@@ -563,7 +564,7 @@ def check_breakpoint_result(
 if num_locations == -1:
 test.assertTrue(out_num_locations > 0,
 "Expecting one or more locations, got none.")
-else:
+elif num_locations != -2:
 test.assertTrue(
 num_locations == out_num_locations,
 "Expecting %d locations, got %d." %


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


[Lldb-commits] [lldb] r325835 - Fix TestSBData.py on Windows

2018-02-22 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Feb 22 14:47:14 2018
New Revision: 325835

URL: http://llvm.org/viewvc/llvm-project?rev=325835&view=rev
Log:
Fix TestSBData.py on Windows

Ensure that the test data is an array of bytes rather than a string that gets
encoded differently between Python 2 and Python 3.

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

Modified:
lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py?rev=325835&r1=325834&r2=325835&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py 
Thu Feb 22 14:47:14 2018
@@ -25,7 +25,7 @@ class SBDataAPICase(TestBase):
 def test_byte_order_and_address_byte_size(self):
 """Test the SBData::SetData() to ensure the byte order and address 
 byte size are obeyed"""
-addr_data = '\x11\x22\x33\x44\x55\x66\x77\x88'
+addr_data = b'\x11\x22\x33\x44\x55\x66\x77\x88'
 error = lldb.SBError()
 data = lldb.SBData()
 data.SetData(error, addr_data, lldb.eByteOrderBig, 4)


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


[Lldb-commits] [lldb] r325836 - Fix TestMoveNearest on Windows

2018-02-22 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Feb 22 14:47:47 2018
New Revision: 325836

URL: http://llvm.org/viewvc/llvm-project?rev=325836&view=rev
Log:
Fix TestMoveNearest on Windows

The header file for the DLL tried to declare inline functions and a local
function as dllexport which broke the compile and link.  Removing the bad
declarations solves the problem, and the test passes on Windows now.

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h?rev=325836&r1=325835&r2=325836&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
 Thu Feb 22 14:47:47 2018
@@ -1,6 +1,5 @@
-LLDB_TEST_API inline int foo1() { return 1; } // !BR1
+inline int foo1() { return 1; } // !BR1
 
-LLDB_TEST_API inline int foo2() { return 2; } // !BR2
+inline int foo2() { return 2; } // !BR2
 
 LLDB_TEST_API extern int call_foo1();
-LLDB_TEST_API extern int call_foo2();


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


[Lldb-commits] [lldb] r326095 - Fix tabs/spaces indentation problem in TestUnicodeSymbols.py

2018-02-26 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Mon Feb 26 07:53:31 2018
New Revision: 326095

URL: http://llvm.org/viewvc/llvm-project?rev=326095&view=rev
Log:
Fix tabs/spaces indentation problem in TestUnicodeSymbols.py

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py?rev=326095&r1=326094&r2=326095&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py 
Mon Feb 26 07:53:31 2018
@@ -10,10 +10,10 @@ class TestUnicodeSymbols(TestBase):
 
 def test_union_members(self):
 self.build()
-   spec = lldb.SBModuleSpec()
-   spec.SetFileSpec(lldb.SBFileSpec(self.getBuildArtifact("a.out")))
-   module = lldb.SBModule(spec)
-   self.assertTrue(module.IsValid())
-   mytype = module.FindFirstType("foobár")
-   self.assertTrue(mytype.IsValid())
-   self.assertTrue(mytype.IsPointerType())
+spec = lldb.SBModuleSpec()
+spec.SetFileSpec(lldb.SBFileSpec(self.getBuildArtifact("a.out")))
+module = lldb.SBModule(spec)
+self.assertTrue(module.IsValid())
+mytype = module.FindFirstType("foobár")
+self.assertTrue(mytype.IsValid())
+self.assertTrue(mytype.IsPointerType())


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


[Lldb-commits] [lldb] r326130 - Partial fix for TestConflictingSymbol.py on Windows

2018-02-26 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Mon Feb 26 13:22:39 2018
New Revision: 326130

URL: http://llvm.org/viewvc/llvm-project?rev=326130&view=rev
Log:
Partial fix for TestConflictingSymbol.py on Windows

Without this fix, the test ERRORs because the link of the inferior fails. This
patch adds the LLDB_TEST_API macro where needed and uses the new -2 magic
value for num_expected_locations to account for lazy-loading of module symbols
on Windows.

With this fix, the test itself still fails:  conflicting_symbol isn't in the
debug info nor the export table, and Windows binaries don't have an equivalent
of the ELF .symtab.  We need to understand why the test works to keep the
symbol out of the debug info.  In the mean time, having the test fail at this
point is a better indication of the remaining problem than a build error.

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h

lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py

lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h?rev=326130&r1=326129&r2=326130&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h 
Mon Feb 26 13:22:39 2018
@@ -1,4 +1,4 @@
 #ifndef ONE_H
 #define ONE_H
-void one();
+LLDB_TEST_API void one();
 #endif

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py?rev=326130&r1=326129&r2=326130&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py
 Mon Feb 26 13:22:39 2018
@@ -33,9 +33,9 @@ class TestConflictingSymbols(TestBase):
 target, ['One', 'Two'])
 
 lldbutil.run_break_set_by_source_regexp(self, '// break here',
-extra_options='-f One.c')
+extra_options='-f One.c', num_expected_locations=-2)
 lldbutil.run_break_set_by_source_regexp(self, '// break here',
-extra_options='-f Two.c')
+extra_options='-f Two.c', num_expected_locations=-2)
 lldbutil.run_break_set_by_source_regexp(self, '// break here',
 extra_options='-f main.c', num_expected_locations=1)
 

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h?rev=326130&r1=326129&r2=326130&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h 
Mon Feb 26 13:22:39 2018
@@ -1,4 +1,4 @@
 #ifndef TWO_H
 #define TWO_H
-void two();
+LLDB_TEST_API void two();
 #endif


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


[Lldb-commits] [lldb] r330354 - Fix narrowing warning by appending `f` to literal constant.

2018-04-19 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Apr 19 11:31:57 2018
New Revision: 330354

URL: http://llvm.org/viewvc/llvm-project?rev=330354&view=rev
Log:
Fix narrowing warning by appending `f` to literal constant.

Modified:
lldb/trunk/unittests/Core/ScalarTest.cpp

Modified: lldb/trunk/unittests/Core/ScalarTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/ScalarTest.cpp?rev=330354&r1=330353&r2=330354&view=diff
==
--- lldb/trunk/unittests/Core/ScalarTest.cpp (original)
+++ lldb/trunk/unittests/Core/ScalarTest.cpp Thu Apr 19 11:31:57 2018
@@ -31,7 +31,7 @@ TEST(ScalarTest, RightShiftOperator) {
 TEST(ScalarTest, GetBytes) {
   int a = 0x01020304;
   long long b = 0x0102030405060708LL;
-  float c = 1234567.89e32;
+  float c = 1234567.89e32f;
   double d = 1234567.89e42;
   char e[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
   char f[32] = {1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16,


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


Re: [Lldb-commits] [lldb] r300610 - Fix Windows bot failure

2017-04-18 Thread Adrian McCarthy via lldb-commits
Actually, Windows does have `struct timespec`.  It's defined in ``
and ``.

https://msdn.microsoft.com/en-us/library/mt633792.aspx

I suspect somebody had suppressed it for some reason.

On Tue, Apr 18, 2017 at 2:47 PM, Chris Bieneman via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: cbieneman
> Date: Tue Apr 18 16:47:50 2017
> New Revision: 300610
>
> URL: http://llvm.org/viewvc/llvm-project?rev=300610&view=rev
> Log:
> Fix Windows bot failure
>
> timespec is not available on Windows, and we should use size_t instead of
> nfds_t.
>
> Modified:
> lldb/trunk/source/Host/common/MainLoop.cpp
>
> Modified: lldb/trunk/source/Host/common/MainLoop.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/
> Host/common/MainLoop.cpp?rev=300610&r1=300609&r2=300610&view=diff
> 
> ==
> --- lldb/trunk/source/Host/common/MainLoop.cpp (original)
> +++ lldb/trunk/source/Host/common/MainLoop.cpp Tue Apr 18 16:47:50 2017
> @@ -33,7 +33,14 @@
>
>  #if !HAVE_PPOLL && !HAVE_SYS_EVENT_H
>
> -int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec
> *timeout_ts,
> +#ifdef LLVM_ON_WIN32
> +struct timespec {
> +  time_t   tv_sec;
> +  suseconds_t  tv_nsec;
> +};
> +#endif
> +
> +int ppoll(struct pollfd *fds, size_t nfds, const struct timespec
> *timeout_ts,
>const sigset_t *) {
>int timeout =
>(timeout_ts == nullptr)
>
>
> ___
> 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] [lldb] r312735 - Fix for bug 34510 - Minidump target does not resolve new symbols correctly

2017-09-07 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Sep  7 11:29:48 2017
New Revision: 312735

URL: http://llvm.org/viewvc/llvm-project?rev=312735&view=rev
Log:
Fix for bug 34510 - Minidump target does not resolve new symbols correctly

Even though the content of the minidump does not change in a debugging session,
frames can't be indiscriminately be cached since modules and symbols can be
explicitly added after the minidump is loaded.

The fix is simple, just let the base Thread::ClearStackFrames() do its job.

submitted by amccarth on behalf of lemo

Bug: https://bugs.llvm.org/show_bug.cgi?id=34510

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

Modified:
lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h

Modified: lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp?rev=312735&r1=312734&r2=312735&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp Thu Sep  7 
11:29:48 2017
@@ -43,8 +43,6 @@ ThreadMinidump::~ThreadMinidump() {}
 
 void ThreadMinidump::RefreshStateAfterStop() {}
 
-void ThreadMinidump::ClearStackFrames() {}
-
 RegisterContextSP ThreadMinidump::GetRegisterContext() {
   if (!m_reg_context_sp) {
 m_reg_context_sp = CreateRegisterContextForFrame(nullptr);

Modified: lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h?rev=312735&r1=312734&r2=312735&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h (original)
+++ lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.h Thu Sep  7 
11:29:48 2017
@@ -37,8 +37,6 @@ public:
   lldb::RegisterContextSP
   CreateRegisterContextForFrame(StackFrame *frame) override;
 
-  void ClearStackFrames() override;
-
 protected:
   lldb::RegisterContextSP m_thread_reg_ctx_sp;
   llvm::ArrayRef m_gpregset_data;


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


[Lldb-commits] [lldb] r313210 - Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Sep 13 15:57:11 2017
New Revision: 313210

URL: http://llvm.org/viewvc/llvm-project?rev=313210&view=rev
Log:
Fix for bug 34532 - A few rough corners related to post-mortem debugging 
(core/minidump)

The main change is to avoid setting the process state as running when
debugging core/minidumps (details in the bug).

Also included a few small, related fixes around how the errors propagate in
this case.

patch by lemo

Bug: https://bugs.llvm.org/show_bug.cgi?id=34532

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

Modified:
lldb/trunk/include/lldb/Target/Process.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/trunk/source/Commands/CommandObjectThread.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=313210&r1=313209&r2=313210&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Wed Sep 13 15:57:11 2017
@@ -1248,7 +1248,13 @@ public:
   /// @return
   /// Returns an error object.
   //--
-  virtual Status WillResume() { return Status(); }
+  virtual Status WillResume() {
+Status error;
+error.SetErrorStringWithFormat(
+"error: %s does not support resuming processes",
+GetPluginName().GetCString());
+return error;
+  }
 
   //--
   /// Resumes all of a process's threads as configured using the

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=313210&r1=313209&r2=313210&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 Wed Sep 13 15:57:11 2017
@@ -244,6 +244,34 @@ class LinuxCoreTestCase(TestBase):
 end_region.GetRegionBase())
 self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS)
 
+def check_state(self, process):
+with open(os.devnull) as devnul:
+# sanitize test output
+self.dbg.SetOutputFileHandle(devnul, False)
+self.dbg.SetErrorFileHandle(devnul, False)
+
+self.assertTrue(process.is_stopped)
+
+# Process.Continue
+error = process.Continue()
+self.assertFalse(error.Success())
+self.assertTrue(process.is_stopped)
+
+# Thread.StepOut
+thread = process.GetSelectedThread()
+thread.StepOut()
+self.assertTrue(process.is_stopped)
+
+# command line
+self.dbg.HandleCommand('s')
+self.assertTrue(process.is_stopped)
+self.dbg.HandleCommand('c')
+self.assertTrue(process.is_stopped)
+
+# restore file handles
+self.dbg.SetOutputFileHandle(None, False)
+self.dbg.SetErrorFileHandle(None, False)
+
 def do_test(self, filename, pid, region_count):
 target = self.dbg.CreateTarget(filename + ".out")
 process = target.LoadCore(filename + ".core")
@@ -251,6 +279,8 @@ class LinuxCoreTestCase(TestBase):
 self.assertEqual(process.GetNumThreads(), 1)
 self.assertEqual(process.GetProcessID(), pid)
 
+self.check_state(process)
+
 thread = process.GetSelectedThread()
 self.assertTrue(thread)
 self.assertEqual(thread.GetThreadID(), pid)

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=313210&r1=313209&r2=313210&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Wed Sep 13 15:57:11 2017
@@ -31,6 +31,34 @@ class MiniDumpNewTestCase(TestBase):
 lldb.DBG.SetSelectedPlatform(self._initial_platform)
 super(MiniDumpNewTestCase, self).tearDown()
 
+def check_state(self):
+  

[Lldb-commits] [lldb] r313540 - Revert "Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)"

2017-09-18 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Mon Sep 18 08:59:44 2017
New Revision: 313540

URL: http://llvm.org/viewvc/llvm-project?rev=313540&view=rev
Log:
Revert "Fix for bug 34532 - A few rough corners related to post-mortem 
debugging (core/minidump)"

Broke Windows and FreeBSD (at least).

This reverts commit 628ca7052b4a5dbace0f6205409113e12c8a78fa.

Modified:
lldb/trunk/include/lldb/Target/Process.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/trunk/source/Commands/CommandObjectThread.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=313540&r1=313539&r2=313540&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Mon Sep 18 08:59:44 2017
@@ -1248,13 +1248,7 @@ public:
   /// @return
   /// Returns an error object.
   //--
-  virtual Status WillResume() {
-Status error;
-error.SetErrorStringWithFormat(
-"error: %s does not support resuming processes",
-GetPluginName().GetCString());
-return error;
-  }
+  virtual Status WillResume() { return Status(); }
 
   //--
   /// Resumes all of a process's threads as configured using the

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=313540&r1=313539&r2=313540&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 Mon Sep 18 08:59:44 2017
@@ -244,34 +244,6 @@ class LinuxCoreTestCase(TestBase):
 end_region.GetRegionBase())
 self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS)
 
-def check_state(self, process):
-with open(os.devnull) as devnul:
-# sanitize test output
-self.dbg.SetOutputFileHandle(devnul, False)
-self.dbg.SetErrorFileHandle(devnul, False)
-
-self.assertTrue(process.is_stopped)
-
-# Process.Continue
-error = process.Continue()
-self.assertFalse(error.Success())
-self.assertTrue(process.is_stopped)
-
-# Thread.StepOut
-thread = process.GetSelectedThread()
-thread.StepOut()
-self.assertTrue(process.is_stopped)
-
-# command line
-self.dbg.HandleCommand('s')
-self.assertTrue(process.is_stopped)
-self.dbg.HandleCommand('c')
-self.assertTrue(process.is_stopped)
-
-# restore file handles
-self.dbg.SetOutputFileHandle(None, False)
-self.dbg.SetErrorFileHandle(None, False)
-
 def do_test(self, filename, pid, region_count):
 target = self.dbg.CreateTarget(filename + ".out")
 process = target.LoadCore(filename + ".core")
@@ -279,8 +251,6 @@ class LinuxCoreTestCase(TestBase):
 self.assertEqual(process.GetNumThreads(), 1)
 self.assertEqual(process.GetProcessID(), pid)
 
-self.check_state(process)
-
 thread = process.GetSelectedThread()
 self.assertTrue(thread)
 self.assertEqual(thread.GetThreadID(), pid)

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=313540&r1=313539&r2=313540&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Mon Sep 18 08:59:44 2017
@@ -31,34 +31,6 @@ class MiniDumpNewTestCase(TestBase):
 lldb.DBG.SetSelectedPlatform(self._initial_platform)
 super(MiniDumpNewTestCase, self).tearDown()
 
-def check_state(self):
-with open(os.devnull) as devnul:
-# sanitize test output
-self.dbg.SetOutputFileHandle(devnul, False)
-self.dbg.SetErrorFileHandle(devnul, False)
-
-self.assertTrue(s

[Lldb-commits] [lldb] r313655 - Re-land r313210 - Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-19 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Tue Sep 19 11:07:33 2017
New Revision: 313655

URL: http://llvm.org/viewvc/llvm-project?rev=313655&view=rev
Log:
Re-land r313210 - Fix for bug 34532 - A few rough corners related to 
post-mortem debugging (core/minidump)

The main change is to avoid setting the process state as running when
debugging core/minidumps (details in the bug).  Also included a few small,
related fixes around how the errors propagate in this case.

Fixed the FreeBSD/Windows break: the intention was to keep
Process::WillResume() and Process::DoResume() "in-sync", but this had the
unfortunate consequence of breaking Process sub-classes which don't override
WillResume().

The safer approach is to keep Process::WillResume() untouched and only
override it in the minidump and core implementations.

patch by lemo

Bug: https://bugs.llvm.org/show_bug.cgi?id=34532

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/trunk/source/Commands/CommandObjectThread.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/trunk/source/Target/Process.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=313655&r1=313654&r2=313655&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 Tue Sep 19 11:07:33 2017
@@ -244,6 +244,34 @@ class LinuxCoreTestCase(TestBase):
 end_region.GetRegionBase())
 self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS)
 
+def check_state(self, process):
+with open(os.devnull) as devnul:
+# sanitize test output
+self.dbg.SetOutputFileHandle(devnul, False)
+self.dbg.SetErrorFileHandle(devnul, False)
+
+self.assertTrue(process.is_stopped)
+
+# Process.Continue
+error = process.Continue()
+self.assertFalse(error.Success())
+self.assertTrue(process.is_stopped)
+
+# Thread.StepOut
+thread = process.GetSelectedThread()
+thread.StepOut()
+self.assertTrue(process.is_stopped)
+
+# command line
+self.dbg.HandleCommand('s')
+self.assertTrue(process.is_stopped)
+self.dbg.HandleCommand('c')
+self.assertTrue(process.is_stopped)
+
+# restore file handles
+self.dbg.SetOutputFileHandle(None, False)
+self.dbg.SetErrorFileHandle(None, False)
+
 def do_test(self, filename, pid, region_count):
 target = self.dbg.CreateTarget(filename + ".out")
 process = target.LoadCore(filename + ".core")
@@ -251,6 +279,8 @@ class LinuxCoreTestCase(TestBase):
 self.assertEqual(process.GetNumThreads(), 1)
 self.assertEqual(process.GetProcessID(), pid)
 
+self.check_state(process)
+
 thread = process.GetSelectedThread()
 self.assertTrue(thread)
 self.assertEqual(thread.GetThreadID(), pid)

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=313655&r1=313654&r2=313655&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Tue Sep 19 11:07:33 2017
@@ -31,6 +31,34 @@ class MiniDumpNewTestCase(TestBase):
 lldb.DBG.SetSelectedPlatform(self._initial_platform)
 super(MiniDumpNewTestCase, self).tearDown()
 
+def check_state(self):
+with open(os.devnull) as devnul:
+# sanitize test output
+self.dbg.SetOutputFileHandle(devnul, False)
+self.dbg.SetErrorFileHandle(devnul, False)
+
+self.assertTrue(self.process.is_stopped)
+
+# Process.Continue
+error = self.process.Continue()
+self.assertFalse(error.Success())
+self.assertTrue(self.process.is_stopped)
+
+# Thread.StepOut
+thread = self.process.GetSelectedThread()
+thread.StepOut()
+   

[Lldb-commits] [lldb] r313785 - Fix the SIGINT handlers

2017-09-20 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Sep 20 11:09:39 2017
New Revision: 313785

URL: http://llvm.org/viewvc/llvm-project?rev=313785&view=rev
Log:
Fix the SIGINT handlers

1. Fix a data race (g_interrupt_sent flag usage was not thread safe, signals
can be handled on arbitrary threads)

2. exit() is not signal-safe, replaced it with the signal-safe equivalent
_exit()

(This differs from the patch on Phabrictor because I had to add
`#include ` to get the definition of `std::atomic_flag`.)

patch by lemo

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

Modified:
lldb/trunk/tools/driver/Driver.cpp
lldb/trunk/tools/lldb-mi/MIDriverMain.cpp

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=313785&r1=313784&r2=313785&view=diff
==
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Wed Sep 20 11:09:39 2017
@@ -9,6 +9,7 @@
 
 #include "Driver.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -1177,17 +1178,16 @@ void sigwinch_handler(int signo) {
 }
 
 void sigint_handler(int signo) {
-  static bool g_interrupt_sent = false;
+  static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT;
   if (g_driver) {
-if (!g_interrupt_sent) {
-  g_interrupt_sent = true;
+if (!g_interrupt_sent.test_and_set()) {
   g_driver->GetDebugger().DispatchInputInterrupt();
-  g_interrupt_sent = false;
+  g_interrupt_sent.clear();
   return;
 }
   }
 
-  exit(signo);
+  _exit(signo);
 }
 
 void sigtstp_handler(int signo) {

Modified: lldb/trunk/tools/lldb-mi/MIDriverMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIDriverMain.cpp?rev=313785&r1=313784&r2=313785&view=diff
==
--- lldb/trunk/tools/lldb-mi/MIDriverMain.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MIDriverMain.cpp Wed Sep 20 11:09:39 2017
@@ -33,6 +33,7 @@
 
 // Third party headers:
 #include "lldb/API/SBHostOS.h"
+#include 
 #include 
 #include 
 
@@ -72,14 +73,13 @@ void sigint_handler(int vSigno) {
 #ifdef _WIN32 // Restore handler as it is not persistent on Windows
   signal(SIGINT, sigint_handler);
 #endif
-  static bool g_interrupt_sent = false;
+  static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT;
   CMIDriverMgr &rDriverMgr = CMIDriverMgr::Instance();
   lldb::SBDebugger *pDebugger = rDriverMgr.DriverGetTheDebugger();
   if (pDebugger != nullptr) {
-if (!g_interrupt_sent) {
-  g_interrupt_sent = true;
+if (!g_interrupt_sent.test_and_set()) {
   pDebugger->DispatchInputInterrupt();
-  g_interrupt_sent = false;
+  g_interrupt_sent.clear();
 }
   }
 


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


[Lldb-commits] [lldb] r313904 - [LLDB] Implement interactive command interruption

2017-09-21 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Sep 21 12:36:52 2017
New Revision: 313904

URL: http://llvm.org/viewvc/llvm-project?rev=313904&view=rev
Log:
[LLDB] Implement interactive command interruption

The core of this change is the new CommandInterpreter::m_command_state, which
models the state transitions for interactive commands, including an
"interrupted" state transition.

In general, command interruption requires cooperation from the code executing
the command, which needs to poll for interruption requests through
CommandInterpreter::WasInterrupted().

CommandInterpreter::PrintCommandOutput() implements an optionally
interruptible printing of the command output, which for large outputs was
likely the longest blocking part.  (ex. target modules dump symtab on a
complex binary could take 10+ minutes)

patch by lemo

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

Modified:
lldb/trunk/include/lldb/API/SBCommandInterpreter.h
lldb/trunk/include/lldb/Core/IOHandler.h
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/scripts/interface/SBCommandInterpreter.i
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp

Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=313904&r1=313903&r2=313904&view=diff
==
--- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Thu Sep 21 12:36:52 2017
@@ -165,6 +165,8 @@ public:
int match_start_point, int max_return_elements,
lldb::SBStringList &matches);
 
+  bool WasInterrupted() const;
+
   // Catch commands before they execute by registering a callback that will
   // get called when the command gets executed. This allows GUI or command
   // line interfaces to intercept a command and stop it from happening

Modified: lldb/trunk/include/lldb/Core/IOHandler.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOHandler.h?rev=313904&r1=313903&r2=313904&view=diff
==
--- lldb/trunk/include/lldb/Core/IOHandler.h (original)
+++ lldb/trunk/include/lldb/Core/IOHandler.h Thu Sep 21 12:36:52 2017
@@ -195,7 +195,7 @@ public:
   enum class Completion { None, LLDBCommand, Expression };
 
   IOHandlerDelegate(Completion completion = Completion::None)
-  : m_completion(completion), m_io_handler_done(false) {}
+  : m_completion(completion) {}
 
   virtual ~IOHandlerDelegate() = default;
 
@@ -296,7 +296,6 @@ public:
 
 protected:
   Completion m_completion; // Support for common builtin completions
-  bool m_io_handler_done;
 };
 
 //--

Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=313904&r1=313903&r2=313904&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Thu Sep 21 
12:36:52 2017
@@ -242,6 +242,8 @@ public:
  bool repeat_on_empty_command = true,
  bool no_context_switching = false);
 
+  bool WasInterrupted() const;
+
   //--
   /// Execute a list of commands in sequence.
   ///
@@ -522,6 +524,24 @@ private:
   StringList &commands_help,
   CommandObject::CommandMap &command_map);
 
+  // An interruptible wrapper around the stream output
+  void PrintCommandOutput(Stream &stream, llvm::StringRef str,
+  bool interruptible);
+
+  // A very simple state machine which models the command handling transitions
+  enum class CommandHandlingState {
+eIdle,
+eInProgress,
+eInterrupted,
+  };
+
+  std::atomic m_command_state{
+  CommandHandlingState::eIdle};
+
+  void StartHandlingCommand();
+  void FinishHandlingCommand();
+  bool InterruptCommand();
+
   Debugger &m_debugger; // The debugger session that this interpreter is
 // associated with
   ExecutionContextRef m_exe_ctx_ref; // The current execution context to use

Modified: lldb/trunk/scripts/interface/SBCommandInterpreter.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBCommandInterpreter.i?rev=313904&r1=313903&r2=313904&view=diff
==
--- lldb/trunk/scripts/interface/SBCommandInterpreter.i (origi

[Lldb-commits] [lldb] r355121 - Improve process launch comments for Windows

2019-02-28 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Feb 28 11:14:02 2019
New Revision: 355121

URL: http://llvm.org/viewvc/llvm-project?rev=355121&view=rev
Log:
Improve process launch comments for Windows

The existing comment about over-allocating the command line was incorrect.  The
contents of the command line may be changed, but it's not necessary to over
allocate.  The changes will be limited to the existing contents of the string
(e.g., by replacing spaces with L'\0' to tokenize the command line).

Also added a comment explaining a possible cause of failure to save the next
programmer some time when they try to debug a 64-bit process from a 32-bit
LLDB.

Modified:
lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp

Modified: lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp?rev=355121&r1=355120&r2=355121&view=diff
==
--- lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp Thu Feb 28 
11:14:02 2019
@@ -104,17 +104,21 @@ ProcessLauncherWindows::LaunchProcess(co
   llvm::ConvertUTF8toWide(commandLine, wcommandLine);
   llvm::ConvertUTF8toWide(launch_info.GetWorkingDirectory().GetCString(),
   wworkingDirectory);
+  // If the command line is empty, it's best to pass a null pointer to tell
+  // CreateProcessW to use the executable name as the command line.  If the
+  // command line is not empty, its contents may be modified by CreateProcessW.
+  WCHAR *pwcommandLine = wcommandLine.empty() ? nullptr : &wcommandLine[0];
 
-  wcommandLine.resize(PATH_MAX); // Needs to be over-allocated because
- // CreateProcessW can modify it
   BOOL result = ::CreateProcessW(
-  wexecutable.c_str(), &wcommandLine[0], NULL, NULL, TRUE, flags, 
env_block,
+  wexecutable.c_str(), pwcommandLine, NULL, NULL, TRUE, flags, env_block,
   wworkingDirectory.size() == 0 ? NULL : wworkingDirectory.c_str(),
   &startupinfo, &pi);
 
   if (!result) {
 // Call GetLastError before we make any other system calls.
 error.SetError(::GetLastError(), eErrorTypeWin32);
+// Note that error 50 ("The request is not supported") will occur if you
+// try debug a 64-bit inferior from a 32-bit LLDB.
   }
 
   if (result) {


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


[Lldb-commits] [lldb] r355943 - Correcting some comments in PdbIndex.cpp [NFC]

2019-03-12 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Tue Mar 12 10:40:51 2019
New Revision: 355943

URL: http://llvm.org/viewvc/llvm-project?rev=355943&view=rev
Log:
Correcting some comments in PdbIndex.cpp [NFC]

ICF can cause multiple symbols to start at the same virtual address.
I plan to handle this shortly, but I wanted to correct the comment for
now.

Deleted an obsolete comment about adjusting the offset for the magic
number at the beginning of the debug info stream.  This adjustment is
handled at a lower level now.

Modified:
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp?rev=355943&r1=355942&r2=355943&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp Tue Mar 12 
10:40:51 2019
@@ -132,9 +132,8 @@ void PdbIndex::BuildAddrToSymbolMap(Comp
 
 PdbCompilandSymId cu_sym_id(modi, iter.offset());
 
-// If the debug info is incorrect, we could have multiple symbols with the
-// same address.  So use try_emplace instead of insert, and the first one
-// will win.
+// It's rare, but we could have multiple symbols with the same address
+// because of identical comdat folding.  Right now, the first one will win.
 cci.m_symbols_by_va.insert(std::make_pair(va, PdbSymUid(cu_sym_id)));
   }
 }
@@ -186,8 +185,6 @@ std::vector PdbIndex::Find
 }
 
 CVSymbol PdbIndex::ReadSymbolRecord(PdbCompilandSymId cu_sym) const {
-  // We need to subtract 4 here to adjust for the codeview debug magic
-  // at the beginning of the debug info stream.
   const CompilandIndexItem *cci = compilands().GetCompiland(cu_sym.modi);
   auto iter = cci->m_debug_stream.getSymbolArray().at(cu_sym.offset);
   lldbassert(iter != cci->m_debug_stream.getSymbolArray().end());


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


[Lldb-commits] [lldb] r357626 - Fix and simplify PrepareCommandsForSourcing

2019-04-03 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Apr  3 12:49:14 2019
New Revision: 357626

URL: http://llvm.org/viewvc/llvm-project?rev=357626&view=rev
Log:
Fix and simplify PrepareCommandsForSourcing

Spotted some problems in the Driver's PrepareCommandsForSourcing while
helping a colleague track another problem.

1. One error case was not handled because there was no else clause.
Fixed by switching to llvm's early-out style instead of nested
`if (succes) { } else { }` cases.  This keeps error handling close
to the actual error.

2. One call-site failed to call the clean-up function.  I solved this
by simplifying the API.  PrepareCommandsForSourcing no longer requires
the caller to provide a buffer for the pipe's file descriptors and to
call a separate clean-up function later.  PrepareCommandsForSourcing
now ensures the file descriptors are handled before returning.
(The read end of the pipe is held open by the returned FILE * as
before.)

I also eliminated an unnecessary local, shorted the lifetime of another,
and tried to improve the comments.

I wrapped the call to open the pipe to get the `#ifdef`s out of the
mainline.  I replaced the `close`/`_close` calls with a platform-neutral
helper from `llvm::sys` for the same reason.  Per discussion on the
review, I'm leaving the `fdopen` call to use the spelling that Windows
has officially deprecated because it still works it avoids more `#ifdef`s.

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

Modified:
lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=357626&r1=357625&r2=357626&view=diff
==
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Wed Apr  3 12:49:14 2019
@@ -22,6 +22,7 @@
 #include "llvm/Support/Format.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
@@ -469,85 +470,58 @@ SBError Driver::ProcessArgs(const opt::I
   return error;
 }
 
-static ::FILE *PrepareCommandsForSourcing(const char *commands_data,
-  size_t commands_size, int fds[2]) {
-  enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
-
-  ::FILE *commands_file = nullptr;
-  fds[0] = -1;
-  fds[1] = -1;
-  int err = 0;
+static inline int OpenPipe(int fds[2], std::size_t size) {
 #ifdef _WIN32
-  err = _pipe(fds, commands_size, O_BINARY);
+  return _pipe(fds, size, O_BINARY);
 #else
-  err = pipe(fds);
+  (void) size;
+  return pipe(fds);
 #endif
-  if (err == 0) {
-ssize_t nrwr = write(fds[WRITE], commands_data, commands_size);
-if (nrwr < 0) {
-  WithColor::error()
-  << format(
- "write(%i, %p, %" PRIu64
- ") failed (errno = %i) when trying to open LLDB commands 
pipe",
- fds[WRITE], static_cast(commands_data),
- static_cast(commands_size), errno)
-  << '\n';
-} else if (static_cast(nrwr) == commands_size) {
-// Close the write end of the pipe so when we give the read end to
-// the debugger/command interpreter it will exit when it consumes all
-// of the data
-#ifdef _WIN32
-  _close(fds[WRITE]);
-  fds[WRITE] = -1;
-#else
-  close(fds[WRITE]);
-  fds[WRITE] = -1;
-#endif
-  // Now open the read file descriptor in a FILE * that we can give to
-  // the debugger as an input handle
-  commands_file = fdopen(fds[READ], "r");
-  if (commands_file != nullptr) {
-fds[READ] = -1; // The FILE * 'commands_file' now owns the read
-// descriptor Hand ownership if the FILE * over to the
-// debugger for "commands_file".
-  } else {
-WithColor::error() << format("fdopen(%i, \"r\") failed (errno = %i) "
- "when trying to open LLDB commands pipe",
- fds[READ], errno)
-   << '\n';
-  }
-}
-  } else {
+}
+
+static ::FILE *PrepareCommandsForSourcing(const char *commands_data,
+  size_t commands_size) {
+  enum PIPES { READ, WRITE }; // Indexes for the read and write fds
+  int fds[2] = {-1, -1};
+
+  if (OpenPipe(fds, commands_size) != 0) {
 WithColor::error()
 << "can't create pipe file descriptors for LLDB commands\n";
+return nullptr;
   }
 
-  return commands_file;
-}
-
-void CleanupAfterCommandSourcing(int fds[2]) {
-  enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
-
-  // Close any pipes that we still have ownership of
-  if (fds[WRITE] != -1) {
-#ifdef _WIN32
-_close(fds[WRITE]);
-fds[WRITE] = -1;
-#else
-close(fds[WRITE]);
-fds[WRITE] = -1;
-#endif
+  ssize_t nrwr =

[Lldb-commits] [PATCH] D26081: Improve ".." handling in FileSpec normalization

2016-10-28 Thread Adrian McCarthy via lldb-commits
amccarth added inline comments.



Comment at: source/Host/common/FileSpec.cpp:550
+  (m_filename.GetStringRef() != ".." && m_filename.GetStringRef() != "."))
+return *this;
 

Do we have to worry about an unnecessary single dot in the directory, like 
`/foo/./bar/`?  Are those handled when the FileSpec is constructed?



Comment at: source/Host/common/FileSpec.cpp:576
+if (component == ".")
+  continue; // Skip these.
+if (component != "..") {

Ah, here we're skipping the unnecessary single dots, but the short-circuit at 
the top would prevent us from getting here unless the directory also contained 
a `/..`.



Comment at: unittests/Host/FileSpecTest.cpp:144
   {R"(C:\bar)", R"(C:\foo\..\bar)"},
   };
 

How about a test to make sure `C:/foo/./bar` is the same as `C:/foo/bar`?



Comment at: unittests/Host/FileSpecTest.cpp:212
+  {"foo/../bar", "bar"},
+  {"../foo/..", ".."},
+  };

Here, too, I'd like to see test cases for paths with single dots.


https://reviews.llvm.org/D26081



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


[Lldb-commits] [PATCH] D25832: Minidump plugin: Adding x86_32 register context converter

2016-10-28 Thread Adrian McCarthy via lldb-commits
amccarth accepted this revision.
amccarth added a reviewer: amccarth.
amccarth added inline comments.



Comment at: unittests/Process/minidump/MinidumpParserTest.cpp:340
   std::map reg_values;
 
+  reg_values[lldb_rax_x86_64] = 0x;

It seems a shame to remove the `// clang-format off` comment for this section.  
The aligned version is easier to read.


https://reviews.llvm.org/D25832



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


[Lldb-commits] [PATCH] D25905: Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the plugin in SystemInitializerFull

2016-10-28 Thread Adrian McCarthy via lldb-commits
amccarth accepted this revision.
amccarth added a reviewer: amccarth.
amccarth added a comment.
This revision is now accepted and ready to land.

I like that this keeps the WoW64 detection and support.  That's a very 
Windows-specific thing, and I was concerned that doing generic minidump parsing 
could lose this.

This looks really good.  On Monday or Tuesday, I'll try patching it into a 
Windows build to see if it's complete enough to remove the Windows-specific 
implementation.




Comment at: 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt:16
+# Then the binaries dynamically link to that lib.
+# The other optimisation is not using the standart library (hense the _start
+# instead of main). We only link dynamically to some standart libraries.

s/hense/hence/



Comment at: 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/makefile.txt:17
+# The other optimisation is not using the standart library (hense the _start
+# instead of main). We only link dynamically to some standart libraries.
+# This way we have a tiny binary (~8K) that has debug symbols and uses breakpad

x/standart/standard/



Comment at: source/Plugins/Process/minidump/ProcessMinidump.cpp:273
+// 64 bit windows
+if (llvm::StringRef(name.getValue()).endswith_lower("wow64.dll")) {
+  m_is_wow64 = true;

This is probably fine, but it's a slightly less precise check than what we're 
doing in ProcessWinMiniDump.cpp.  The endswith check would  accept 
"bowwow64.dll".  It's probably not important, since detecting WoW64 is by 
looking at module names is a hack anyway.


https://reviews.llvm.org/D25905



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


[Lldb-commits] [PATCH] D26393: Disable windows-only minidump plugin

2016-11-08 Thread Adrian McCarthy via lldb-commits
amccarth added a comment.

I started testing the new plugin on Windows yesterday, and it doesn't work (all 
the tests fail).  I'm planning to debug today, and, once I get it working, I'd 
be happy to switch it over.


https://reviews.llvm.org/D26393



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


[Lldb-commits] [PATCH] D26393: Disable windows-only minidump plugin

2016-11-08 Thread Adrian McCarthy via lldb-commits
amccarth added a comment.

In https://reviews.llvm.org/D26393#589421, @labath wrote:

> In https://reviews.llvm.org/D26393#589363, @amccarth wrote:
>
> > I started testing the new plugin on Windows yesterday, and it doesn't work 
> > (all the tests fail).  I'm planning to debug today, and, once I get it 
> > working, I'd be happy to switch it over.
>
>
> Interesting. It seemed to work fine for me. How did you test that?


I made changes very similar to this patch and ran check-lldb.  The tests for 
the new minidump plugin passed, but the original Windows ones all failed, 
apparently because it cannot find any threads in the dumps.  I'll have more 
time to look at it this afternoon.


https://reviews.llvm.org/D26393



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


[Lldb-commits] [PATCH] D26393: Disable windows-only minidump plugin

2016-11-08 Thread Adrian McCarthy via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

Problem was at my end.  This patch works fine for me now.

I'm planning to do some more minidump work, so I'd be happy to take over with 
eliminating the old Windows-specific implementation.


https://reviews.llvm.org/D26393



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


[Lldb-commits] [lldb] r286476 - Un-XFail test on Windows. Has been in "unexpected success" mode for a while.

2016-11-10 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Nov 10 11:21:22 2016
New Revision: 286476

URL: http://llvm.org/viewvc/llvm-project?rev=286476&view=rev
Log:
Un-XFail test on Windows.  Has been in "unexpected success" mode for a while.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py?rev=286476&r1=286475&r2=286476&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py 
Thu Nov 10 11:21:22 2016
@@ -21,8 +21,6 @@ class EnumTypesTestCase(TestBase):
 # Find the line number to break inside main().
 self.line = line_number('main.c', '// Set break point at this line.')
 
-# derefing the null pointer "works" on Windows
-@expectedFailureAll(oslist=['windows'])
 def test(self):
 """Test 'image lookup -t days' and check for correct display and enum 
value printing."""
 self.build()


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


[Lldb-commits] [PATCH] D26643: Fix TestMiniDumpNew.py test for Python 2/3 issue

2016-11-14 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

On Windows, where we use Python 3 for testing, we have to be more explicit 
about converting between binary and string representations.  I believe this 
should still work for Python 2, but I don't have a convenient way to try it out.


https://reviews.llvm.org/D26643

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py


Index: 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -108,15 +108,16 @@
 /proc/PID/status which is written in the file
 """
 shutil.copyfile(core, newcore)
-with open(newcore, "r+") as f:
+with open(newcore, "rb+") as f:
 f.seek(offset)
-self.assertEqual(f.read(5), oldpid)
+currentpid = f.read(5).decode('utf-8')
+self.assertEqual(currentpid, oldpid)
 
 f.seek(offset)
 if len(newpid) < len(oldpid):
 newpid += " " * (len(oldpid) - len(newpid))
 newpid += "\n"
-f.write(newpid)
+f.write(newpid.encode('utf-8'))
 
 def test_deeper_stack_in_minidump_with_same_pid_running(self):
 """Test that we read the information from the core correctly even if we


Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -108,15 +108,16 @@
 /proc/PID/status which is written in the file
 """
 shutil.copyfile(core, newcore)
-with open(newcore, "r+") as f:
+with open(newcore, "rb+") as f:
 f.seek(offset)
-self.assertEqual(f.read(5), oldpid)
+currentpid = f.read(5).decode('utf-8')
+self.assertEqual(currentpid, oldpid)
 
 f.seek(offset)
 if len(newpid) < len(oldpid):
 newpid += " " * (len(oldpid) - len(newpid))
 newpid += "\n"
-f.write(newpid)
+f.write(newpid.encode('utf-8'))
 
 def test_deeper_stack_in_minidump_with_same_pid_running(self):
 """Test that we read the information from the core correctly even if we
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r286909 - Fix TestMiniDumpNew.py test for Python 2/3 issue

2016-11-14 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Mon Nov 14 17:53:45 2016
New Revision: 286909

URL: http://llvm.org/viewvc/llvm-project?rev=286909&view=rev
Log:
Fix TestMiniDumpNew.py test for Python 2/3 issue

On Windows, where we use Python 3 for testing, we have to be more explicit 
about converting between binary and string representations.  I believe this 
should still work for Python 2, but I don't have a convenient way to try it out.

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=286909&r1=286908&r2=286909&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Mon Nov 14 17:53:45 2016
@@ -108,15 +108,16 @@ class MiniDumpNewTestCase(TestBase):
 /proc/PID/status which is written in the file
 """
 shutil.copyfile(core, newcore)
-with open(newcore, "r+") as f:
+with open(newcore, "rb+") as f:
 f.seek(offset)
-self.assertEqual(f.read(5), oldpid)
+currentpid = f.read(5).decode('utf-8')
+self.assertEqual(currentpid, oldpid)
 
 f.seek(offset)
 if len(newpid) < len(oldpid):
 newpid += " " * (len(oldpid) - len(newpid))
 newpid += "\n"
-f.write(newpid)
+f.write(newpid.encode('utf-8'))
 
 def test_deeper_stack_in_minidump_with_same_pid_running(self):
 """Test that we read the information from the core correctly even if we


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


[Lldb-commits] [PATCH] D26643: Fix TestMiniDumpNew.py test for Python 2/3 issue

2016-11-14 Thread Adrian McCarthy via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286909: Fix TestMiniDumpNew.py test for Python 2/3 issue 
(authored by amccarth).

Changed prior to commit:
  https://reviews.llvm.org/D26643?vs=77900&id=77907#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26643

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py


Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -108,15 +108,16 @@
 /proc/PID/status which is written in the file
 """
 shutil.copyfile(core, newcore)
-with open(newcore, "r+") as f:
+with open(newcore, "rb+") as f:
 f.seek(offset)
-self.assertEqual(f.read(5), oldpid)
+currentpid = f.read(5).decode('utf-8')
+self.assertEqual(currentpid, oldpid)
 
 f.seek(offset)
 if len(newpid) < len(oldpid):
 newpid += " " * (len(oldpid) - len(newpid))
 newpid += "\n"
-f.write(newpid)
+f.write(newpid.encode('utf-8'))
 
 def test_deeper_stack_in_minidump_with_same_pid_running(self):
 """Test that we read the information from the core correctly even if we


Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -108,15 +108,16 @@
 /proc/PID/status which is written in the file
 """
 shutil.copyfile(core, newcore)
-with open(newcore, "r+") as f:
+with open(newcore, "rb+") as f:
 f.seek(offset)
-self.assertEqual(f.read(5), oldpid)
+currentpid = f.read(5).decode('utf-8')
+self.assertEqual(currentpid, oldpid)
 
 f.seek(offset)
 if len(newpid) < len(oldpid):
 newpid += " " * (len(oldpid) - len(newpid))
 newpid += "\n"
-f.write(newpid)
+f.write(newpid.encode('utf-8'))
 
 def test_deeper_stack_in_minidump_with_same_pid_running(self):
 """Test that we read the information from the core correctly even if we
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D26697: Remove Windows-specific minidump plugin

2016-11-15 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added reviewers: labath, zturner.
amccarth added a subscriber: lldb-commits.
Herald added subscribers: modocache, mgorny.

With the cross-platform minidump plugin working, the Windows-specific one is no 
longer needed.  This eliminates the unnecessary code.

This does not eliminate the Windows-specific tests, as they hit a few cases the 
general tests don't.  (The Windows-specific tests are currently passing.)  I'll 
look into a separate patch to make sure we're not doing too much duplicate 
testing.

After that I might do a little re-org in the Windows plugin, as there was some 
factoring there (Common & Live) that probably isn't necessary anymore.


https://reviews.llvm.org/D26697

Files:
  cmake/LLDBDependencies.cmake
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
  source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
  
source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
  
source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
  
source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
  
source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h

Index: source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
===
--- source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//===-- RegisterContextWindowsMiniDump_x86.h *- C++
-//-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
-#define liblldb_RegisterContextWindowsMiniDump_x86_H_
-
-#include "Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h"
-#include "lldb/lldb-forward.h"
-
-namespace lldb_private {
-
-class Thread;
-
-class RegisterContextWindowsMiniDump_x86 : public RegisterContextWindows_x86 {
-public:
-  RegisterContextWindowsMiniDump_x86(Thread &thread,
- uint32_t concrete_frame_idx,
- const CONTEXT *context);
-
-  virtual ~RegisterContextWindowsMiniDump_x86();
-
-  bool WriteRegister(const RegisterInfo *reg_info,
- const RegisterValue ®_value) override;
-
-protected:
-  bool CacheAllRegisterValues() override;
-};
-}
-
-#endif // #ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
Index: source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
===
--- source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//===-- RegisterContextWindowsMiniDump_x86.cpp --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "lldb/Host/windows/windows.h"
-#include "lldb/lldb-private-types.h"
-
-#include "RegisterContextWindowsMiniDump_x86.h"
-
-using namespace lldb;
-
-namespace lldb_private {
-
-RegisterContextWindowsMiniDump_x86::RegisterContextWindowsMiniDump_x86(
-Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
-: RegisterContextWindows_x86(thread, concrete_frame_idx) {
-  if (context) {
-m_context = *context;
-m_context_stale = false;
-  }
-}
-
-RegisterContextWindowsMiniDump_x86::~RegisterContextWindowsMiniDump_x86() {}
-
-bool RegisterContextWindowsMiniDump_x86::WriteRegister(
-const RegisterInfo * /* reg_info */,
-const RegisterValue & /* reg_value */) {
-  return false;
-}
-
-bool RegisterContextWindowsMiniDump_x86::CacheAllRegisterValues() {
-  // Since this is post-mortem debugging, we either have the context or we
-  // don't.
-  return !m_context_stale;
-}
-
-} // namespace lldb_private
Index: source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
===
--- source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//===-- RegisterContextWindowsMiniDump_x64.h *- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source

[Lldb-commits] [PATCH] D26697: Remove Windows-specific minidump plugin

2016-11-16 Thread Adrian McCarthy via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287113: Remove Windows-specific minidump plugin (authored by 
amccarth).

Changed prior to commit:
  https://reviews.llvm.org/D26697?vs=78065&id=78194#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26697

Files:
  lldb/trunk/cmake/LLDBDependencies.cmake
  lldb/trunk/source/Plugins/Process/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h

Index: lldb/trunk/source/Plugins/Process/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/Process/CMakeLists.txt
+++ lldb/trunk/source/Plugins/Process/CMakeLists.txt
@@ -8,7 +8,6 @@
   add_subdirectory(POSIX)
 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(Windows/Live)
-  add_subdirectory(Windows/MiniDump)
   add_subdirectory(Windows/Common)
 elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
   add_subdirectory(MacOSX-Kernel)
Index: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
===
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
@@ -1,37 +0,0 @@
-//===-- RegisterContextWindowsMiniDump_x86.h *- C++
-//-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
-#define liblldb_RegisterContextWindowsMiniDump_x86_H_
-
-#include "Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h"
-#include "lldb/lldb-forward.h"
-
-namespace lldb_private {
-
-class Thread;
-
-class RegisterContextWindowsMiniDump_x86 : public RegisterContextWindows_x86 {
-public:
-  RegisterContextWindowsMiniDump_x86(Thread &thread,
- uint32_t concrete_frame_idx,
- const CONTEXT *context);
-
-  virtual ~RegisterContextWindowsMiniDump_x86();
-
-  bool WriteRegister(const RegisterInfo *reg_info,
- const RegisterValue ®_value) override;
-
-protected:
-  bool CacheAllRegisterValues() override;
-};
-}
-
-#endif // #ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
Index: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
@@ -1,42 +0,0 @@
-//===-- RegisterContextWindowsMiniDump_x86.cpp --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "lldb/Host/windows/windows.h"
-#include "lldb/lldb-private-types.h"
-
-#include "RegisterContextWindowsMiniDump_x86.h"
-
-using namespace lldb;
-
-namespace lldb_private {
-
-RegisterContextWindowsMiniDump_x86::RegisterContextWindowsMiniDump_x86(
-Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
-: RegisterContextWindows_x86(thread, concrete_frame_idx) {
-  if (context) {
-m_context = *context;
-m_context_stale = false;
-  }
-}
-
-RegisterContextWindowsMiniDump_x86::~RegisterContextWindowsMiniDump_x86() {}
-
-bool RegisterContextWindowsMiniDump_x86::WriteRegister(
-const RegisterInfo * /* reg_info */,
-const RegisterValue & /* reg_value */) {
-  return false;
-}
-
-bool RegisterContextWindowsMiniDump_x86::CacheAllRegisterValues() {
-  // Since this is post-mortem debugging, we either have the context or we
-  // don't.
-  return !m_context_stale;
-}
-
-} // namespace lldb_private
Index: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindows

[Lldb-commits] [lldb] r287113 - Remove Windows-specific minidump plugin

2016-11-16 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Nov 16 10:04:14 2016
New Revision: 287113

URL: http://llvm.org/viewvc/llvm-project?rev=287113&view=rev
Log:
Remove Windows-specific minidump plugin

With the cross-platform minidump plugin working, the Windows-specific one is no 
longer needed. This eliminates the unnecessary code.

This does not eliminate the Windows-specific tests, as they hit a few cases the 
general tests don't. (The Windows-specific tests are currently passing.) I'll 
look into a separate patch to make sure we're not doing too much duplicate 
testing.

After that I might do a little re-org in the Windows plugin, as there was some 
factoring there (Common & Live) that probably isn't necessary anymore.

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

Removed:
lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h

lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp

lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h

lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp

lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
Modified:
lldb/trunk/cmake/LLDBDependencies.cmake
lldb/trunk/source/Plugins/Process/CMakeLists.txt

Modified: lldb/trunk/cmake/LLDBDependencies.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=287113&r1=287112&r2=287113&view=diff
==
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)
+++ lldb/trunk/cmake/LLDBDependencies.cmake Wed Nov 16 10:04:14 2016
@@ -21,7 +21,7 @@ set( LLDB_USED_LIBS
   lldbPluginDynamicLoaderPosixDYLD
   lldbPluginDynamicLoaderHexagonDYLD
   lldbPluginDynamicLoaderWindowsDYLD
-  
+
   lldbPluginCPlusPlusLanguage
   lldbPluginGoLanguage
   lldbPluginJavaLanguage
@@ -91,7 +91,6 @@ set( LLDB_USED_LIBS
 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
   list(APPEND LLDB_USED_LIBS
 lldbPluginProcessWindows
-lldbPluginProcessWinMiniDump
 lldbPluginProcessWindowsCommon
 Ws2_32
 Rpcrt4

Modified: lldb/trunk/source/Plugins/Process/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/CMakeLists.txt?rev=287113&r1=287112&r2=287113&view=diff
==
--- lldb/trunk/source/Plugins/Process/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/CMakeLists.txt Wed Nov 16 10:04:14 2016
@@ -8,7 +8,6 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "NetBS
   add_subdirectory(POSIX)
 elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
   add_subdirectory(Windows/Live)
-  add_subdirectory(Windows/MiniDump)
   add_subdirectory(Windows/Common)
 elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
   add_subdirectory(MacOSX-Kernel)

Removed: lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt?rev=287112&view=auto
==
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt (removed)
@@ -1,21 +0,0 @@
-include_directories(../../Utility)
-include_directories(../Common)
-
-set(PROC_WINDOWS_MINIDUMP_SOURCES
-  ProcessWinMiniDump.cpp
-  ThreadWinMiniDump.cpp
-  )
-
-if (CMAKE_SIZEOF_VOID_P EQUAL 4)
-  set(PROC_WINDOWS_MINIDUMP_SOURCES ${PROC_WINDOWS_MINIDUMP_SOURCES}
-x86/RegisterContextWindowsMiniDump_x86.cpp
-)
-elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
-  set(PROC_WINDOWS_MINIDUMP_SOURCES ${PROC_WINDOWS_MINIDUMP_SOURCES}
-x64/RegisterContextWindowsMiniDump_x64.cpp
-)
-endif()
-
-add_lldb_library(lldbPluginProcessWinMiniDump
-  ${PROC_WINDOWS_MINIDUMP_SOURCES}
-  )

Removed: 
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp?rev=287112&view=auto
==
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp 
(removed)
@@ -1,631 +0,0 @@
-//===-- ProcessWinMiniDump.cpp --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-/

[Lldb-commits] [lldb] r293336 - NFC: Improve comments in SymbolFilePDB.cpp

2017-01-27 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Fri Jan 27 15:42:28 2017
New Revision: 293336

URL: http://llvm.org/viewvc/llvm-project?rev=293336&view=rev
Log:
NFC:  Improve comments in SymbolFilePDB.cpp

Mostly this just fixes bad wrapping caused by the reformat, with tiny
changes sprinkled here and there.

Modified:
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp?rev=293336&r1=293335&r2=293336&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Fri Jan 27 
15:42:28 2017
@@ -125,9 +125,8 @@ uint32_t SymbolFilePDB::GetNumCompileUni
 m_cached_compile_unit_count = compilands->getChildCount();
 
 // The linker can inject an additional "dummy" compilation unit into the
-// PDB.
-// Ignore this special compile unit for our purposes, if it is there.  It 
is
-// always the last one.
+// PDB. Ignore this special compile unit for our purposes, if it is there.
+// It is always the last one.
 auto last_cu = compilands->getChildAtIndex(m_cached_compile_unit_count - 
1);
 std::string name = last_cu->getName();
 if (name == "* Linker *")
@@ -187,12 +186,10 @@ bool SymbolFilePDB::ParseCompileUnitSupp
 return false;
 
   // In theory this is unnecessary work for us, because all of this information
-  // is easily
-  // (and quickly) accessible from DebugInfoPDB, so caching it a second time
-  // seems like a waste.
-  // Unfortunately, there's no good way around this short of a moderate
-  // refactor, since SymbolVendor
-  // depends on being able to cache this list.
+  // is easily (and quickly) accessible from DebugInfoPDB, so caching it a
+  // second time seems like a waste.  Unfortunately, there's no good way around
+  // this short of a moderate refactor since SymbolVendor depends on being able
+  // to cache this list.
   auto cu = m_session_up->getConcreteSymbolById(
   sc.comp_unit->GetID());
   if (!cu)
@@ -269,9 +266,8 @@ lldb_private::CompilerDecl SymbolFilePDB
 lldb_private::CompilerDeclContext
 SymbolFilePDB::GetDeclContextForUID(lldb::user_id_t uid) {
   // PDB always uses the translation unit decl context for everything.  We can
-  // improve this later
-  // but it's not easy because PDB doesn't provide a high enough level of type
-  // fidelity in this area.
+  // improve this later but it's not easy because PDB doesn't provide a high
+  // enough level of type fidelity in this area.
   return *m_tu_decl_ctx_up;
 }
 
@@ -295,30 +291,25 @@ uint32_t SymbolFilePDB::ResolveSymbolCon
 uint32_t resolve_scope, lldb_private::SymbolContextList &sc_list) {
   if (resolve_scope & lldb::eSymbolContextCompUnit) {
 // Locate all compilation units with line numbers referencing the specified
-// file.  For example, if
-// `file_spec` is , then this should return all source files and
-// header files that reference
-// , either directly or indirectly.
+// file.  For example, if `file_spec` is , then this should return
+// all source files and header files that reference , either
+// directly or indirectly.
 auto compilands = m_session_up->findCompilandsForSourceFile(
 file_spec.GetPath(), PDB_NameSearchFlags::NS_CaseInsensitive);
 
-// For each one, either find get its previously parsed data, or parse it
-// afresh and add it to
-// the symbol context list.
+// For each one, either find its previously parsed data or parse it afresh
+// and add it to the symbol context list.
 while (auto compiland = compilands->getNext()) {
   // If we're not checking inlines, then don't add line information for 
this
-  // file unless the FileSpec
-  // matches.
+  // file unless the FileSpec matches.
   if (!check_inlines) {
 // `getSourceFileName` returns the basename of the original source file
-// used to generate this compiland.
-// It does not return the full path.  Currently the only way to get 
that
-// is to do a basename lookup to
-// get the IPDBSourceFile, but this is ambiguous in the case of two
-// source files with the same name
-// contributing to the same compiland.  This is a moderately extreme
-// edge case, so we consider this ok
-// for now, although we need to find a long term solution.
+// used to generate this compiland.  It does not return the full path.
+// Currently the only way to get that is to do a basename lookup to get
+// the IPDBSourceFile, but this is ambiguous in the case of two source
+// files with the same name contributing to the same compiland.  This 
is
+// a moderately extreme edge case, so we consider this OK for now

[Lldb-commits] [lldb] r248909 - Removed an unused member variable. Affects Windows only.

2015-09-30 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Sep 30 09:57:21 2015
New Revision: 248909

URL: http://llvm.org/viewvc/llvm-project?rev=248909&view=rev
Log:
Removed an unused member variable.  Affects Windows only.

Modified:
lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindows.h

Modified: lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindows.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindows.h?rev=248909&r1=248908&r2=248909&view=diff
==
--- lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindows.h 
(original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindows.h Wed 
Sep 30 09:57:21 2015
@@ -48,8 +48,6 @@ class TargetThreadWindows : public lldb_
   private:
 lldb::RegisterContextSP CreateRegisterContextForFrameIndex(uint32_t idx);
 
-lldb::StackFrameUP m_stack_frame;
-
 HostThread m_host_thread;
 };
 }


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


[Lldb-commits] [PATCH] D13312: Fix Windows build due to missing path.

2015-09-30 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added reviewers: zturner, spyffe.
amccarth added a subscriber: lldb-commits.

This fixes the Windows build break introduced by r248934.  I'm not sure why it 
didn't break other platforms.

http://reviews.llvm.org/D13312

Files:
  include/lldb/Symbol/ClangASTContext.h

Index: include/lldb/Symbol/ClangASTContext.h
===
--- include/lldb/Symbol/ClangASTContext.h
+++ include/lldb/Symbol/ClangASTContext.h
@@ -20,7 +20,7 @@
 #include 
 
 // Other libraries and framework includes
-#include "ClangPersistentVariables.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
 
 #include "llvm/ADT/SmallVector.h"
 #include "clang/AST/ASTContext.h"


Index: include/lldb/Symbol/ClangASTContext.h
===
--- include/lldb/Symbol/ClangASTContext.h
+++ include/lldb/Symbol/ClangASTContext.h
@@ -20,7 +20,7 @@
 #include 
 
 // Other libraries and framework includes
-#include "ClangPersistentVariables.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
 
 #include "llvm/ADT/SmallVector.h"
 #include "clang/AST/ASTContext.h"
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13312: Fix Windows build due to missing path.

2015-09-30 Thread Adrian McCarthy via lldb-commits
amccarth abandoned this revision.
amccarth added a comment.

Same fix was already committed to fix the Linux build.


http://reviews.llvm.org/D13312



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


[Lldb-commits] [PATCH] D13555: Cap test threads on Windows to avoid open file limit

2015-10-08 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: tfiala.
amccarth added a subscriber: lldb-commits.

Python uses stdio from the C runtime for file descriptors and pipes.  On 
Windows, by default, the CRT has a limit of 512 open file descriptors.  
https://msdn.microsoft.com/en-us/library/6e3b887c.aspx

The parent dotest process ends up with several FDs for each process running a 
test in parallel.  At about 37-38 logical cores we started hitting this limit 
regularly.

This patch works around the problem by capping the threads to 32 on Windows.

http://reviews.llvm.org/D13555

Files:
  test/dosep.py

Index: test/dosep.py
===
--- test/dosep.py
+++ test/dosep.py
@@ -1350,6 +1350,11 @@
 runner_strategies_by_name.keys()))
 test_runner_func = runner_strategies_by_name[test_runner_name]
 
+# On Windows, Python uses CRT with a low limit on the number of open files.
+# Capping the number of threads avoids "OSError: too many open files."
+if os.name == 'nt' and num_threads > 32:
+num_threads = 32
+
 summary_results = walk_and_invoke(
 test_directory, test_subdir, dotest_argv,
 num_threads, test_runner_func)


Index: test/dosep.py
===
--- test/dosep.py
+++ test/dosep.py
@@ -1350,6 +1350,11 @@
 runner_strategies_by_name.keys()))
 test_runner_func = runner_strategies_by_name[test_runner_name]
 
+# On Windows, Python uses CRT with a low limit on the number of open files.
+# Capping the number of threads avoids "OSError: too many open files."
+if os.name == 'nt' and num_threads > 32:
+num_threads = 32
+
 summary_results = walk_and_invoke(
 test_directory, test_subdir, dotest_argv,
 num_threads, test_runner_func)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13555: Cap test threads on Windows to avoid open file limit

2015-10-08 Thread Adrian McCarthy via lldb-commits
amccarth added a comment.

Hold off.  I just got a failure even at only 32 subprocesses.


http://reviews.llvm.org/D13555



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


Re: [Lldb-commits] [PATCH] D13574: [LLDB] Fix Clang-tidy misc-use-override warnings in some files in include/lldb/Core; other minor fixes.

2015-10-09 Thread Adrian McCarthy via lldb-commits
amccarth added a subscriber: amccarth.
amccarth added a comment.

There was an lldb-dev thread from February 9, where it seemed to be agreed
that lldb code should be more like llvm code, in particular with the spaces
between the function names and the opening parens.  I've been omitting the
spaces in new code since then.


Repository:
  rL LLVM

http://reviews.llvm.org/D13574



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


Re: [Lldb-commits] [PATCH] D13574: [LLDB] Fix Clang-tidy misc-use-override warnings in some files in include/lldb/Core; other minor fixes.

2015-10-09 Thread Adrian McCarthy via lldb-commits
There was an lldb-dev thread from February 9, where it seemed to be agreed
that lldb code should be more like llvm code, in particular with the spaces
between the function names and the opening parens.  I've been omitting the
spaces in new code since then.

On Fri, Oct 9, 2015 at 10:14 AM, Greg Clayton via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> clayborg accepted this revision.
> clayborg added a comment.
> This revision is now accepted and ready to land.
>
> We are pretty inconsistent with the space after a function name and before
> the ( so I don't mind.
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D13574
>
>
>
> ___
> 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] [PATCH] D13555: Cap test threads on Windows to avoid open file limit

2015-10-09 Thread Adrian McCarthy via lldb-commits
amccarth updated this revision to Diff 36993.
amccarth added a comment.

Using the multiprocessing-pool mode seems more reliable than capping 
num_threads.  I'm doing it only when the number of threads is high because of 
the loss of Ctrl+C support.


http://reviews.llvm.org/D13555

Files:
  test/dosep.py

Index: test/dosep.py
===
--- test/dosep.py
+++ test/dosep.py
@@ -1254,10 +1254,13 @@
 # Use the serial runner.
 test_runner_name = "serial"
 elif os.name == "nt":
-# Currently the multiprocessing test runner with ctrl-c
-# support isn't running correctly on nt.  Use the pool
-# support without ctrl-c.
-test_runner_name = "threading-pool"
+# On Windows, Python uses CRT with a low limit on the number of open
+# files.  If you have a lot of cores, the threading-pool runner will
+# often fail because it exceeds that limit.
+if num_threads > 32:
+test_runner_name = "multiprocessing-pool"
+else:
+test_runner_name = "threading-pool"
 elif is_darwin_version_lower_than(
 distutils.version.StrictVersion("10.10.0")):
 # OS X versions before 10.10 appear to have an issue using


Index: test/dosep.py
===
--- test/dosep.py
+++ test/dosep.py
@@ -1254,10 +1254,13 @@
 # Use the serial runner.
 test_runner_name = "serial"
 elif os.name == "nt":
-# Currently the multiprocessing test runner with ctrl-c
-# support isn't running correctly on nt.  Use the pool
-# support without ctrl-c.
-test_runner_name = "threading-pool"
+# On Windows, Python uses CRT with a low limit on the number of open
+# files.  If you have a lot of cores, the threading-pool runner will
+# often fail because it exceeds that limit.
+if num_threads > 32:
+test_runner_name = "multiprocessing-pool"
+else:
+test_runner_name = "threading-pool"
 elif is_darwin_version_lower_than(
 distutils.version.StrictVersion("10.10.0")):
 # OS X versions before 10.10 appear to have an issue using
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r250044 - Switch threading mode for tests on Windows when there are lots of cores.

2015-10-12 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Mon Oct 12 09:46:57 2015
New Revision: 250044

URL: http://llvm.org/viewvc/llvm-project?rev=250044&view=rev
Log:
Switch threading mode for tests on Windows when there are lots of cores.
This prevents a "too many files" error.

Differential Revision: http://reviews.llvm.org/D13555

Modified:
lldb/trunk/test/dosep.py

Modified: lldb/trunk/test/dosep.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.py?rev=250044&r1=250043&r2=250044&view=diff
==
--- lldb/trunk/test/dosep.py (original)
+++ lldb/trunk/test/dosep.py Mon Oct 12 09:46:57 2015
@@ -1254,10 +1254,13 @@ def default_test_runner_name(num_threads
 # Use the serial runner.
 test_runner_name = "serial"
 elif os.name == "nt":
-# Currently the multiprocessing test runner with ctrl-c
-# support isn't running correctly on nt.  Use the pool
-# support without ctrl-c.
-test_runner_name = "threading-pool"
+# On Windows, Python uses CRT with a low limit on the number of open
+# files.  If you have a lot of cores, the threading-pool runner will
+# often fail because it exceeds that limit.
+if num_threads > 32:
+test_runner_name = "multiprocessing-pool"
+else:
+test_runner_name = "threading-pool"
 elif is_darwin_version_lower_than(
 distutils.version.StrictVersion("10.10.0")):
 # OS X versions before 10.10 appear to have an issue using


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


Re: [Lldb-commits] [PATCH] D13555: Cap test threads on Windows to avoid open file limit

2015-10-12 Thread Adrian McCarthy via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250044: Switch threading mode for tests on Windows when 
there are lots of cores. (authored by amccarth).

Changed prior to commit:
  http://reviews.llvm.org/D13555?vs=36993&id=37111#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13555

Files:
  lldb/trunk/test/dosep.py

Index: lldb/trunk/test/dosep.py
===
--- lldb/trunk/test/dosep.py
+++ lldb/trunk/test/dosep.py
@@ -1254,10 +1254,13 @@
 # Use the serial runner.
 test_runner_name = "serial"
 elif os.name == "nt":
-# Currently the multiprocessing test runner with ctrl-c
-# support isn't running correctly on nt.  Use the pool
-# support without ctrl-c.
-test_runner_name = "threading-pool"
+# On Windows, Python uses CRT with a low limit on the number of open
+# files.  If you have a lot of cores, the threading-pool runner will
+# often fail because it exceeds that limit.
+if num_threads > 32:
+test_runner_name = "multiprocessing-pool"
+else:
+test_runner_name = "threading-pool"
 elif is_darwin_version_lower_than(
 distutils.version.StrictVersion("10.10.0")):
 # OS X versions before 10.10 appear to have an issue using


Index: lldb/trunk/test/dosep.py
===
--- lldb/trunk/test/dosep.py
+++ lldb/trunk/test/dosep.py
@@ -1254,10 +1254,13 @@
 # Use the serial runner.
 test_runner_name = "serial"
 elif os.name == "nt":
-# Currently the multiprocessing test runner with ctrl-c
-# support isn't running correctly on nt.  Use the pool
-# support without ctrl-c.
-test_runner_name = "threading-pool"
+# On Windows, Python uses CRT with a low limit on the number of open
+# files.  If you have a lot of cores, the threading-pool runner will
+# often fail because it exceeds that limit.
+if num_threads > 32:
+test_runner_name = "multiprocessing-pool"
+else:
+test_runner_name = "threading-pool"
 elif is_darwin_version_lower_than(
 distutils.version.StrictVersion("10.10.0")):
 # OS X versions before 10.10 appear to have an issue using
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D13679: Fix TestTargetAPI.py test for users who use Swig 3.0.5 or greater.

2015-10-12 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

How Swig handles varargs functions changed between 3.0.2 and 3.0.5, which 
causes one of our tests to fail.  This fix adds a Swig directive to the 
SBError::SetErrorSTringWithFormat method and extends a test to call it with 
various numbers of arguments.

I've tested this fix with Swig 3.0.2, 3.0.5, and 3.0.7.

In Python, there are only two calls to this method, both in the sb_error.py 
test, and one of those is the failing line.  It's unclear how many external 
scripts may be affected.

The caveat here is that, when calling from Python, all of the arguments must be 
strings.  From the Swig documentation, "Doing anything more advanced than this 
is likely to involve a serious world of pain. In order to use a library like 
libffi, you will need to know the underlying calling conventions and details of 
the C++ ABI."

Background:

The message SBError::SetErrorStringWithFormat is a varargs function.  In the 
Swig interface file, it's:

int
SetErrorStringWithFormat (const char *format, ...);

With 3.0.2, this creates a Python wrapper with this signature:

def SetErrorStringWithFormat(self, *args):
"""SetErrorStringWithFormat(SBError self, str const * format) -> int"""
return _lldb.SBError_SetErrorStringWithFormat(self, *args)

But in 3.0.5 (and later), it comes up with:

def SetErrorStringWithFormat(self, format):
"""SetErrorStringWithFormat(SBError self, str const * format) -> int"""
return _lldb.SBError_SetErrorStringWithFormat(self, format)

Note that it no longer takes a variable number of arguments.  This causes a 
test failure when the Python code attempts to invoke the method with more than 
a format string.

==
ERROR: test_SBError 
(TestDefaultConstructorForAPIObjects.APIDefaultConstructorTestCase)
--
Traceback (most recent call last):
  File "D:\src\llvm\llvm\tools\lldb\test\lldbtest.py", line 480, in wrapper
return func(self, *args, **kwargs)
  File "D:\src\llvm\llvm\tools\lldb\test\lldbtest.py", line 521, in wrapper
return func(self, *args, **kwargs)
  File 
"D:\src\llvm\llvm\tools\lldb\test\python_api\default-constructor\TestDefaultConstructorForAPIObjects.py",
 line 131, in test_SBError
sb_error.fuzz_obj(obj)
  File 
"D:\src\llvm\llvm\tools\lldb\test\python_api\default-constructor\sb_error.py", 
line 19, in fuzz_obj
obj.SetErrorStringWithFormat("%s!", "error")
TypeError: SetErrorStringWithFormat() takes exactly 2 arguments (3 given)
Config=i686-D:\src\llvm\build\ninja\bin\clang.exe
--

This is consistent with the Swig documentation on varargs functions.  See: 
http://www.swig.org/Doc3.0/Varargs.html#Varargs


http://reviews.llvm.org/D13679

Files:
  scripts/interface/SBError.i
  test/python_api/default-constructor/sb_error.py

Index: test/python_api/default-constructor/sb_error.py
===
--- test/python_api/default-constructor/sb_error.py
+++ test/python_api/default-constructor/sb_error.py
@@ -18,5 +18,8 @@
 obj.SetErrorString(None)
 obj.SetErrorStringWithFormat("%s!", "error")
 obj.SetErrorStringWithFormat(None)
+obj.SetErrorStringWithFormat("error")
+obj.SetErrorStringWithFormat("%s %s", "warning", "danger")
+obj.SetErrorStringWithFormat("%s %s %s", "danger", "will", "robinson")
 obj.GetDescription(lldb.SBStream())
 obj.Clear()
Index: scripts/interface/SBError.i
===
--- scripts/interface/SBError.i
+++ scripts/interface/SBError.i
@@ -56,6 +56,7 @@
 checks that after calling the target.Launch() method there's no error
 condition and we get back a void process object.
 ") SBError;
+
 class SBError {
 public:
 SBError ();
@@ -94,6 +95,7 @@
 void
 SetErrorString (const char *err_str);
 
+%varargs(3, char *str = NULL) SetErrorStringWithFormat;
 int
 SetErrorStringWithFormat (const char *format, ...);
 


Index: test/python_api/default-constructor/sb_error.py
===
--- test/python_api/default-constructor/sb_error.py
+++ test/python_api/default-constructor/sb_error.py
@@ -18,5 +18,8 @@
 obj.SetErrorString(None)
 obj.SetErrorStringWithFormat("%s!", "error")
 obj.SetErrorStringWithFormat(None)
+obj.SetErrorStringWithFormat("error")
+obj.SetErrorStringWithFormat("%s %s", "warning", "danger")
+obj.SetErrorStringWithFormat("%s %s %s", "danger", "will", "robinson")
 obj.GetDescription(lldb.SBStream())
 obj.Clear()
Index: scripts/interface/SBError.i

Re: [Lldb-commits] [PATCH] D13679: Fix TestTargetAPI.py test for users who use Swig 3.0.5 or greater.

2015-10-12 Thread Adrian McCarthy via lldb-commits
With Swig 3.0.2, non-string arguments work.  I'm not sure why.  Even the
Swig 1.x documentation says that what we're doing shouldn't work.

On Mon, Oct 12, 2015 at 3:49 PM, Zachary Turner  wrote:

> zturner added a comment.
>
> Prior to this patch, what was the behavior of using
> SetErrorStringWithFormat with an argument that was not a string?
>
> Can you add a test to `fuzz_obj` that calls
> `SetErrorStringWithFormat("%d", 10)` and run it against SWIG 3.0.2 and see
> what happens?
>
>
> http://reviews.llvm.org/D13679
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13679: Fix TestTargetAPI.py test for users who use Swig 3.0.5 or greater.

2015-10-12 Thread Adrian McCarthy via lldb-commits
amccarth added a subscriber: amccarth.
amccarth added a comment.

With Swig 3.0.2, non-string arguments work.  I'm not sure why.  Even the
Swig 1.x documentation says that what we're doing shouldn't work.


http://reviews.llvm.org/D13679



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


Re: [Lldb-commits] [PATCH] D13679: Fix TestTargetAPI.py test for users who use Swig 3.0.5 or greater.

2015-10-12 Thread Adrian McCarthy via lldb-commits
amccarth added a comment.

Adding Greg Clayton for advice on how to proceed.

Swig documentation talked about the peril of varargs methods:  
http://www.swig.org/Doc3.0/Varargs.html#Varargs

The fact that it appears to work with 3.0.2 seems to be a bug in 3.0.2.

My proposal is in this patch.  An alternate idea would be to remove 
SetErrorStringWithFormat from the SB API, but I know we don't like to remove 
things from the API.


http://reviews.llvm.org/D13679



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


[Lldb-commits] [lldb] r250188 - Fix TestTargetAPI.py test for users who use Swig 3.0.5 or greater.

2015-10-13 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Tue Oct 13 12:54:15 2015
New Revision: 250188

URL: http://llvm.org/viewvc/llvm-project?rev=250188&view=rev
Log:
Fix TestTargetAPI.py test for users who use Swig 3.0.5 or greater.

DifferentialRevision: http://reviews.llvm.org/D13679

Modified:
lldb/trunk/scripts/interface/SBError.i
lldb/trunk/test/python_api/default-constructor/sb_error.py

Modified: lldb/trunk/scripts/interface/SBError.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBError.i?rev=250188&r1=250187&r2=250188&view=diff
==
--- lldb/trunk/scripts/interface/SBError.i (original)
+++ lldb/trunk/scripts/interface/SBError.i Tue Oct 13 12:54:15 2015
@@ -56,6 +56,7 @@ And (from test/python_api/event/TestEven
 checks that after calling the target.Launch() method there's no error
 condition and we get back a void process object.
 ") SBError;
+
 class SBError {
 public:
 SBError ();
@@ -94,6 +95,7 @@ public:
 void
 SetErrorString (const char *err_str);
 
+%varargs(3, char *str = NULL) SetErrorStringWithFormat;
 int
 SetErrorStringWithFormat (const char *format, ...);
 

Modified: lldb/trunk/test/python_api/default-constructor/sb_error.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_error.py?rev=250188&r1=250187&r2=250188&view=diff
==
--- lldb/trunk/test/python_api/default-constructor/sb_error.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_error.py Tue Oct 13 
12:54:15 2015
@@ -18,5 +18,8 @@ def fuzz_obj(obj):
 obj.SetErrorString(None)
 obj.SetErrorStringWithFormat("%s!", "error")
 obj.SetErrorStringWithFormat(None)
+obj.SetErrorStringWithFormat("error")
+obj.SetErrorStringWithFormat("%s %s", "warning", "danger")
+obj.SetErrorStringWithFormat("%s %s %s", "danger", "will", "robinson")
 obj.GetDescription(lldb.SBStream())
 obj.Clear()


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


[Lldb-commits] [lldb] r250189 - Xfail a watchpoint test on Windows, until Windows implements watchpoints.

2015-10-13 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Tue Oct 13 12:55:58 2015
New Revision: 250189

URL: http://llvm.org/viewvc/llvm-project?rev=250189&view=rev
Log:
Xfail a watchpoint test on Windows, until Windows implements watchpoints.

Modified:

lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py

Modified: 
lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py?rev=250189&r1=250188&r2=250189&view=diff
==
--- 
lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
 (original)
+++ 
lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
 Tue Oct 13 12:55:58 2015
@@ -13,6 +13,7 @@ class TestValueOfVectorVariableTestCase(
 mydir = TestBase.compute_mydir(__file__)
 
 @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not 
supported
+@expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - 
Watchpoints not supported on Windows
 def test_value_of_vector_variable_using_watchpoint_set(self):
 """Test verify displayed value of vector variable."""
 self.build(dictionary=self.d)


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


[Lldb-commits] [PATCH] D13788: Factor the execution of a test method into its own function to ensure proper cleanup

2015-10-15 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: tfiala.
amccarth added a subscriber: lldb-commits.

This solves problems in tearDown of individual test cases, which were 
especially noticeable on Windows.

When a test throws an exception, the exception retains references to the 
functions in the stack, which in term keeps their local variables alive.  When 
those locals are SB proxy objects, cleanup doesn't proceed as it should because 
they keep LLDB objects alive that should have been orphaned.

By moving the running of the test method to a separate function, we ensure that 
the exception goes out of scope before we attempt tearDown, and the 
gc.collect() makes sure the orphaned objects are properly destroyed before the 
framework attempts to delete the target.

Without this fix, a test case that throws might cause the shared module list to 
retain an open handle to the inferior, even after the target is deleted.  This 
affects the state of subsequent test cases in the same test.  This was 
especially noticeable on Windows in tests like TestTargetAPI, because the open 
handle prevented make from deleting the inferior after the failed test case and 
the next test case from re-building the inferior.  Thus nearly all tests cases 
would fail because of a problem in just one.

http://reviews.llvm.org/D13788

Files:
  source/Target/Target.cpp
  test/lldbtest.py
  test/unittest2/case.py

Index: test/unittest2/case.py
===
--- test/unittest2/case.py
+++ test/unittest2/case.py
@@ -353,32 +353,7 @@
 except Exception:
 result.addError(self, sys.exc_info())
 else:
-try:
-testMethod()
-except self.failureException:
-result.addFailure(self, sys.exc_info())
-except _ExpectedFailure, e:
-addExpectedFailure = getattr(result, 'addExpectedFailure', None)
-if addExpectedFailure is not None:
-addExpectedFailure(self, e.exc_info, e.bugnumber)
-else: 
-warnings.warn("Use of a TestResult without an addExpectedFailure method is deprecated", 
-  DeprecationWarning)
-result.addSuccess(self)
-except _UnexpectedSuccess, x:
-addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
-if addUnexpectedSuccess is not None:
-addUnexpectedSuccess(self, x.bugnumber)
-else:
-warnings.warn("Use of a TestResult without an addUnexpectedSuccess method is deprecated", 
-  DeprecationWarning)
-result.addFailure(self, sys.exc_info())
-except SkipTest, e:
-self._addSkip(result, str(e))
-except Exception:
-result.addError(self, sys.exc_info())
-else:
-success = True
+success = self.runMethod(testMethod, result)
 
 try:
 self.tearDown()
@@ -399,6 +374,42 @@
 if stopTestRun is not None:
 stopTestRun()
 
+def runMethod(self, testMethod, result):
+"""Runs the test method and catches any exception that might be thrown.
+
+This is factored out of TestCase.run() to ensure that any exception
+thrown during the test goes out of scope before tearDown.  Otherwise, an
+exception could hold references to Python objects that are bound to
+SB objects and prevent them from being deleted in time.
+"""
+try:
+testMethod()
+except self.failureException:
+result.addFailure(self, sys.exc_info())
+except _ExpectedFailure, e:
+addExpectedFailure = getattr(result, 'addExpectedFailure', None)
+if addExpectedFailure is not None:
+addExpectedFailure(self, e.exc_info, e.bugnumber)
+else:
+warnings.warn("Use of a TestResult without an addExpectedFailure method is deprecated",
+  DeprecationWarning)
+result.addSuccess(self)
+except _UnexpectedSuccess, x:
+addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
+if addUnexpectedSuccess is not None:
+addUnexpectedSuccess(self, x.bugnumber)
+else:
+warnings.warn("Use of a TestResult without an addUnexpectedSuccess method is deprecated",
+  DeprecationWarning)
+result.addFailure(self, sys.exc_info())
+except SkipTest, e:
+self._addSkip(result, str(e))
+except Exception:
+result.addError(self, sys.exc_info())
+

[Lldb-commits] [lldb] r250467 - Factor the execution of the test method into a separate function to ensure that any exceptions that are thrown go out of scope and no longer hold references to SB objec

2015-10-15 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Oct 15 17:39:55 2015
New Revision: 250467

URL: http://llvm.org/viewvc/llvm-project?rev=250467&view=rev
Log:
Factor the execution of the test method into a separate function to ensure that 
any exceptions that are thrown go out of scope and no longer hold references to 
SB objects that need to be freed before teardown.

Differential Revision: http://reviews.llvm.org/D13788

Modified:
lldb/trunk/source/Target/Target.cpp
lldb/trunk/test/lldbtest.py
lldb/trunk/test/unittest2/case.py

Modified: lldb/trunk/source/Target/Target.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=250467&r1=250466&r2=250467&view=diff
==
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Oct 15 17:39:55 2015
@@ -1276,7 +1276,7 @@ Target::ModuleAdded (const ModuleList& m
 void
 Target::ModuleRemoved (const ModuleList& module_list, const ModuleSP 
&module_sp)
 {
-// A module is being added to this target for the first time
+// A module is being removed from this target.
 if (m_valid)
 {
 ModuleList my_module_list;

Modified: lldb/trunk/test/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=250467&r1=250466&r2=250467&view=diff
==
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Thu Oct 15 17:39:55 2015
@@ -32,6 +32,7 @@ $
 """
 
 import abc
+import gc
 import glob
 import os, sys, traceback
 import os.path
@@ -2544,6 +2545,11 @@ class TestBase(Base):
 #import traceback
 #traceback.print_stack()
 
+# Ensure all the references to SB objects have gone away so that we can
+# be sure that all test-specific resources have been freed before we
+# attempt to delete the targets.
+gc.collect()
+
 # Delete the target(s) from the debugger as a general cleanup step.
 # This includes terminating the process for each target, if any.
 # We'd like to reuse the debugger for our next test without incurring

Modified: lldb/trunk/test/unittest2/case.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unittest2/case.py?rev=250467&r1=250466&r2=250467&view=diff
==
--- lldb/trunk/test/unittest2/case.py (original)
+++ lldb/trunk/test/unittest2/case.py Thu Oct 15 17:39:55 2015
@@ -353,32 +353,7 @@ class TestCase(unittest.TestCase):
 except Exception:
 result.addError(self, sys.exc_info())
 else:
-try:
-testMethod()
-except self.failureException:
-result.addFailure(self, sys.exc_info())
-except _ExpectedFailure, e:
-addExpectedFailure = getattr(result, 'addExpectedFailure', 
None)
-if addExpectedFailure is not None:
-addExpectedFailure(self, e.exc_info, e.bugnumber)
-else: 
-warnings.warn("Use of a TestResult without an 
addExpectedFailure method is deprecated", 
-  DeprecationWarning)
-result.addSuccess(self)
-except _UnexpectedSuccess, x:
-addUnexpectedSuccess = getattr(result, 
'addUnexpectedSuccess', None)
-if addUnexpectedSuccess is not None:
-addUnexpectedSuccess(self, x.bugnumber)
-else:
-warnings.warn("Use of a TestResult without an 
addUnexpectedSuccess method is deprecated", 
-  DeprecationWarning)
-result.addFailure(self, sys.exc_info())
-except SkipTest, e:
-self._addSkip(result, str(e))
-except Exception:
-result.addError(self, sys.exc_info())
-else:
-success = True
+success = self.runMethod(testMethod, result)
 
 try:
 self.tearDown()
@@ -399,6 +374,42 @@ class TestCase(unittest.TestCase):
 if stopTestRun is not None:
 stopTestRun()
 
+def runMethod(self, testMethod, result):
+"""Runs the test method and catches any exception that might be thrown.
+
+This is factored out of TestCase.run() to ensure that any exception
+thrown during the test goes out of scope before tearDown.  Otherwise, 
an
+exception could hold references to Python objects that are bound to
+SB objects and prevent them from being deleted in time.
+"""
+try:
+testMethod()
+except self.failureException:
+result.addFailure(self,

Re: [Lldb-commits] [PATCH] D13788: Factor the execution of a test method into its own function to ensure proper cleanup

2015-10-15 Thread Adrian McCarthy via lldb-commits
amccarth added a comment.

Nice catch on the comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D13788



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


Re: [Lldb-commits] [PATCH] D13788: Factor the execution of a test method into its own function to ensure proper cleanup

2015-10-15 Thread Adrian McCarthy via lldb-commits
This revision was automatically updated to reflect the committed changes.
amccarth marked an inline comment as done.
Closed by commit rL250467: Factor the execution of the test method into a 
separate function to ensure… (authored by amccarth).

Changed prior to commit:
  http://reviews.llvm.org/D13788?vs=37523&id=37531#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13788

Files:
  lldb/trunk/source/Target/Target.cpp
  lldb/trunk/test/lldbtest.py
  lldb/trunk/test/unittest2/case.py

Index: lldb/trunk/test/lldbtest.py
===
--- lldb/trunk/test/lldbtest.py
+++ lldb/trunk/test/lldbtest.py
@@ -32,6 +32,7 @@
 """
 
 import abc
+import gc
 import glob
 import os, sys, traceback
 import os.path
@@ -2544,6 +2545,11 @@
 #import traceback
 #traceback.print_stack()
 
+# Ensure all the references to SB objects have gone away so that we can
+# be sure that all test-specific resources have been freed before we
+# attempt to delete the targets.
+gc.collect()
+
 # Delete the target(s) from the debugger as a general cleanup step.
 # This includes terminating the process for each target, if any.
 # We'd like to reuse the debugger for our next test without incurring
Index: lldb/trunk/test/unittest2/case.py
===
--- lldb/trunk/test/unittest2/case.py
+++ lldb/trunk/test/unittest2/case.py
@@ -353,32 +353,7 @@
 except Exception:
 result.addError(self, sys.exc_info())
 else:
-try:
-testMethod()
-except self.failureException:
-result.addFailure(self, sys.exc_info())
-except _ExpectedFailure, e:
-addExpectedFailure = getattr(result, 'addExpectedFailure', None)
-if addExpectedFailure is not None:
-addExpectedFailure(self, e.exc_info, e.bugnumber)
-else: 
-warnings.warn("Use of a TestResult without an addExpectedFailure method is deprecated", 
-  DeprecationWarning)
-result.addSuccess(self)
-except _UnexpectedSuccess, x:
-addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
-if addUnexpectedSuccess is not None:
-addUnexpectedSuccess(self, x.bugnumber)
-else:
-warnings.warn("Use of a TestResult without an addUnexpectedSuccess method is deprecated", 
-  DeprecationWarning)
-result.addFailure(self, sys.exc_info())
-except SkipTest, e:
-self._addSkip(result, str(e))
-except Exception:
-result.addError(self, sys.exc_info())
-else:
-success = True
+success = self.runMethod(testMethod, result)
 
 try:
 self.tearDown()
@@ -399,6 +374,42 @@
 if stopTestRun is not None:
 stopTestRun()
 
+def runMethod(self, testMethod, result):
+"""Runs the test method and catches any exception that might be thrown.
+
+This is factored out of TestCase.run() to ensure that any exception
+thrown during the test goes out of scope before tearDown.  Otherwise, an
+exception could hold references to Python objects that are bound to
+SB objects and prevent them from being deleted in time.
+"""
+try:
+testMethod()
+except self.failureException:
+result.addFailure(self, sys.exc_info())
+except _ExpectedFailure, e:
+addExpectedFailure = getattr(result, 'addExpectedFailure', None)
+if addExpectedFailure is not None:
+addExpectedFailure(self, e.exc_info, e.bugnumber)
+else:
+warnings.warn("Use of a TestResult without an addExpectedFailure method is deprecated",
+  DeprecationWarning)
+result.addSuccess(self)
+except _UnexpectedSuccess, x:
+addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
+if addUnexpectedSuccess is not None:
+addUnexpectedSuccess(self, x.bugnumber)
+else:
+warnings.warn("Use of a TestResult without an addUnexpectedSuccess method is deprecated",
+  DeprecationWarning)
+result.addFailure(self, sys.exc_info())
+except SkipTest, e:
+self._addSkip(result, str(e))
+except Exception:
+result.addError(self, sys.exc_info())
+else:
+return True
+return False
+
 def doClea

[Lldb-commits] [lldb] r250576 - Skip hanging watchpoint test on Windows (rather than just xfailing).

2015-10-16 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Fri Oct 16 18:19:22 2015
New Revision: 250576

URL: http://llvm.org/viewvc/llvm-project?rev=250576&view=rev
Log:
Skip hanging watchpoint test on Windows (rather than just xfailing).

Modified:

lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py

Modified: 
lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py?rev=250576&r1=250575&r2=250576&view=diff
==
--- 
lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py 
(original)
+++ 
lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py 
Fri Oct 16 18:19:22 2015
@@ -26,7 +26,7 @@ class WatchpointConditionAPITestCase(Tes
 self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
 
 @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not 
supported
-@expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - 
Watchpoints not supported on Windows
+@skipIfWindows # Watchpoints not supported on Windows, and this test hangs
 def test_watchpoint_cond_api(self):
 """Test watchpoint condition API."""
 self.build(dictionary=self.d)


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


[Lldb-commits] [PATCH] D13923: Skip TestMultithread.py on Windows because it times out (and they'd fail anyway)

2015-10-20 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

I'm not sure why this was timing out when running on my machine, since it took 
only 45 second for the tests to fail and the timeout seem to be set to 240 
seconds.

Simply skipping these cases wasn't enough because the inferior was being built 
12 times (once for each call to setUp).  So I moved the setUp work into the 
tests themselves.  Skipping stops wasting time building and rebuilding the 
inferiors.  It also seems to avoid the last lingering intermittent GNU Make 
crash.

Before going this route, I spent a lot of time trying to get the inferior to 
build on Windows.  I had to fix some POSIX assumptions in common.h and enable 
exceptions (which have been disabled on Windows because clang-cl exception 
support on Windows was lagging).  Enabling exceptions caused four other tests 
to fail, so we have that to look forward to.  And I wasn't able to figure out 
the linking problem where it complained that the -L option was ignored and then 
complained that it couldn't find liblldb.lib (because it ignored the -L option).

I'm open to other ideas, but this is the best way I can see to get unblocked.

http://reviews.llvm.org/D13923

Files:
  test/api/multithreaded/TestMultithreaded.py

Index: test/api/multithreaded/TestMultithreaded.py
===
--- test/api/multithreaded/TestMultithreaded.py
+++ test/api/multithreaded/TestMultithreaded.py
@@ -1,4 +1,4 @@
-"""Test the lldb public C++ api breakpoint callbacks.  """
+"""Test the lldb public C++ api breakpoint callbacks."""
 
 import os, re, StringIO
 import unittest2
@@ -10,41 +10,32 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-TestBase.setUp(self)
-self.lib_dir = os.environ["LLDB_LIB_DIR"]
-self.implib_dir = os.environ["LLDB_IMPLIB_DIR"]
-self.inferior = 'inferior_program'
-if self.getLldbArchitecture() == self.getArchitecture():
-self.buildProgram('inferior.cpp', self.inferior)
-self.addTearDownHook(lambda: os.remove(self.inferior))
-
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_breakpoint_callback(self):
 """Test the that SBBreakpoint callback is invoked when a breakpoint is 
hit. """
 self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
 'test_breakpoint_callback')
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_event_description(self):
 """ Test the description of an SBListener breakpoint event is valid."""
 self.build_and_test('driver.cpp listener_test.cpp 
test_listener_event_description.cpp',
 'test_listener_event_description')
 pass
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFlakeyLinux # Driver occasionally returns '1' as exit status
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_event_process_state(self):
 """ Test that a registered SBListener receives events when a process
 changes state.
@@ -56,9 +47,9 @@
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.8"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_resume(self):
 """ Test that a process can be resumed from a non-main thread. """
 self.build_and_test('driver.cpp listener_test.cpp 
test_listener_resume.cpp',
@@ -75,6 +66,12 @@
 if self.getLldbArchitecture() != self.getArchitecture():
 self.skipTest("This test is only run if the target arch is the 
same as the lldb binary arch")
 
+self.lib_dir = os.environ["LLDB_LIB_DIR"]
+self.implib_dir = os.environ["LLDB_IMPLIB_DIR"

[Lldb-commits] [lldb] r250899 - Skip TestMultithreaded on Windows.

2015-10-21 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Oct 21 09:42:10 2015
New Revision: 250899

URL: http://llvm.org/viewvc/llvm-project?rev=250899&view=rev
Log:
Skip TestMultithreaded on Windows.

Differential Revision: http://reviews.llvm.org/D13923

Modified:
lldb/trunk/test/api/multithreaded/TestMultithreaded.py

Modified: lldb/trunk/test/api/multithreaded/TestMultithreaded.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/api/multithreaded/TestMultithreaded.py?rev=250899&r1=250898&r2=250899&view=diff
==
--- lldb/trunk/test/api/multithreaded/TestMultithreaded.py (original)
+++ lldb/trunk/test/api/multithreaded/TestMultithreaded.py Wed Oct 21 09:42:10 
2015
@@ -1,4 +1,4 @@
-"""Test the lldb public C++ api breakpoint callbacks.  """
+"""Test the lldb public C++ api breakpoint callbacks."""
 
 import os, re, StringIO
 import unittest2
@@ -10,19 +10,10 @@ class SBBreakpointCallbackCase(TestBase)
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-TestBase.setUp(self)
-self.lib_dir = os.environ["LLDB_LIB_DIR"]
-self.implib_dir = os.environ["LLDB_IMPLIB_DIR"]
-self.inferior = 'inferior_program'
-if self.getLldbArchitecture() == self.getArchitecture():
-self.buildProgram('inferior.cpp', self.inferior)
-self.addTearDownHook(lambda: os.remove(self.inferior))
-
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_breakpoint_callback(self):
 """Test the that SBBreakpoint callback is invoked when a breakpoint is 
hit. """
 self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
@@ -30,9 +21,9 @@ class SBBreakpointCallbackCase(TestBase)
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_event_description(self):
 """ Test the description of an SBListener breakpoint event is valid."""
 self.build_and_test('driver.cpp listener_test.cpp 
test_listener_event_description.cpp',
@@ -41,10 +32,10 @@ class SBBreakpointCallbackCase(TestBase)
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFlakeyLinux # Driver occasionally returns '1' as exit status
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_event_process_state(self):
 """ Test that a registered SBListener receives events when a process
 changes state.
@@ -56,9 +47,9 @@ class SBBreakpointCallbackCase(TestBase)
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.8"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_resume(self):
 """ Test that a process can be resumed from a non-main thread. """
 self.build_and_test('driver.cpp listener_test.cpp 
test_listener_resume.cpp',
@@ -75,6 +66,12 @@ class SBBreakpointCallbackCase(TestBase)
 if self.getLldbArchitecture() != self.getArchitecture():
 self.skipTest("This test is only run if the target arch is the 
same as the lldb binary arch")
 
+self.lib_dir = os.environ["LLDB_LIB_DIR"]
+self.implib_dir = os.environ["LLDB_IMPLIB_DIR"]
+self.inferior = 'inferior_program'
+self.buildProgram('inferior.cpp', self.inferior)
+self.addTearDownHook(lambda: os.remove(self.inferior))
+
 self.buildDriver(sources, test_name)
 self.addTearDownHook(lambda: os.remove(test_name))
 


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


Re: [Lldb-commits] [PATCH] D13923: Skip TestMultithread.py on Windows because it times out (and they'd fail anyway)

2015-10-21 Thread Adrian McCarthy via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250899: Skip TestMultithreaded on Windows. (authored by 
amccarth).

Changed prior to commit:
  http://reviews.llvm.org/D13923?vs=37953&id=38012#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13923

Files:
  lldb/trunk/test/api/multithreaded/TestMultithreaded.py

Index: lldb/trunk/test/api/multithreaded/TestMultithreaded.py
===
--- lldb/trunk/test/api/multithreaded/TestMultithreaded.py
+++ lldb/trunk/test/api/multithreaded/TestMultithreaded.py
@@ -1,4 +1,4 @@
-"""Test the lldb public C++ api breakpoint callbacks.  """
+"""Test the lldb public C++ api breakpoint callbacks."""
 
 import os, re, StringIO
 import unittest2
@@ -10,41 +10,32 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-TestBase.setUp(self)
-self.lib_dir = os.environ["LLDB_LIB_DIR"]
-self.implib_dir = os.environ["LLDB_IMPLIB_DIR"]
-self.inferior = 'inferior_program'
-if self.getLldbArchitecture() == self.getArchitecture():
-self.buildProgram('inferior.cpp', self.inferior)
-self.addTearDownHook(lambda: os.remove(self.inferior))
-
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_breakpoint_callback(self):
 """Test the that SBBreakpoint callback is invoked when a breakpoint is 
hit. """
 self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
 'test_breakpoint_callback')
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_event_description(self):
 """ Test the description of an SBListener breakpoint event is valid."""
 self.build_and_test('driver.cpp listener_test.cpp 
test_listener_event_description.cpp',
 'test_listener_event_description')
 pass
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFlakeyLinux # Driver occasionally returns '1' as exit status
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.9"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_event_process_state(self):
 """ Test that a registered SBListener receives events when a process
 changes state.
@@ -56,9 +47,9 @@
 
 @skipIfRemote
 @skipIfNoSBHeaders
+@skipIfWindows # clang-cl does not support throw or catch 
(llvm.org/pr24538)
 @expectedFlakeyFreeBSD
 @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", 
compiler_version=[">=","4.8"], archs=["x86_64"])
-@expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support 
throw or catch
 def test_sb_api_listener_resume(self):
 """ Test that a process can be resumed from a non-main thread. """
 self.build_and_test('driver.cpp listener_test.cpp 
test_listener_resume.cpp',
@@ -75,6 +66,12 @@
 if self.getLldbArchitecture() != self.getArchitecture():
 self.skipTest("This test is only run if the target arch is the 
same as the lldb binary arch")
 
+self.lib_dir = os.environ["LLDB_LIB_DIR"]
+self.implib_dir = os.environ["LLDB_IMPLIB_DIR"]
+self.inferior = 'inferior_program'
+self.buildProgram('inferior.cpp', self.inferior)
+self.addTearDownHook(lambda: os.remove(self.inferior))
+
 self.buildDriver(sources, test_name)
 self.addTearDownHook(lambda: os.remove(test_name))
 


Index: lldb/trunk/test/api/multithreaded/TestMultithreaded.py
===
--- lldb/trunk/test/api/multithreaded/TestMultithreaded.py
+++ lldb/trunk/test/api/multithreaded/TestMultithreaded.py
@@ -1,4 +1,4 @@
-"""Test the lldb public C++ api breakpoint callbacks.  """
+"""Test the lldb public C++ api breakpoint callbacks."""
 
 import os, re, StringIO
 import unittest2
@@ -10,41 +10,32 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-TestBase.setUp(self)
-self.lib_dir = os.environ["LLDB_LIB_DIR"]
-self.implib_dir = os.environ["

[Lldb-commits] [lldb] r251354 - Revert "Clang module compilation options need to be per-platform."

2015-10-26 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Mon Oct 26 16:38:41 2015
New Revision: 251354

URL: http://llvm.org/viewvc/llvm-project?rev=251354&view=rev
Log:
Revert "Clang module compilation options need to be per-platform."

This reverts commit r251340.

Breaks the Windows build because Windows doesn't have getuid.  The fix is not 
obvious.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h
lldb/trunk/source/Target/Platform.cpp

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp?rev=251354&r1=251353&r2=251354&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
Mon Oct 26 16:38:41 2015
@@ -641,7 +641,18 @@ ClangModulesDeclVendor::Create(Target &t
 compiler_invocation_arguments.push_back(ModuleImportBufferName);
 
 // Add additional search paths with { "-I", path } or { "-F", path } here.
-   
+   
+{
+llvm::SmallString<128> DefaultModuleCache;
+const bool erased_on_reboot = false;
+llvm::sys::path::system_temp_directory(erased_on_reboot, 
DefaultModuleCache);
+llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang");
+llvm::sys::path::append(DefaultModuleCache, "ModuleCache");
+std::string module_cache_argument("-fmodules-cache-path=");
+module_cache_argument.append(DefaultModuleCache.str().str());
+compiler_invocation_arguments.push_back(module_cache_argument);
+}
+
 FileSpecList &module_search_paths = target.GetClangModuleSearchPaths();
 
 for (size_t spi = 0, spe = module_search_paths.GetSize(); spi < spe; ++spi)

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=251354&r1=251353&r2=251354&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Oct 26 
16:38:41 2015
@@ -35,10 +35,6 @@
 #include "lldb/Target/Target.h"
 #include "llvm/ADT/STLExtras.h"
 
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/Path.h"
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -1480,17 +1476,6 @@ PlatformDarwin::AddClangModuleCompilatio
apple_arguments.begin(),
apple_arguments.end());
 
-{
-llvm::SmallString<128> DefaultModuleCache;
-const bool erased_on_reboot = false;
-llvm::sys::path::system_temp_directory(erased_on_reboot, 
DefaultModuleCache);
-llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang");
-llvm::sys::path::append(DefaultModuleCache, "ModuleCache");
-std::string module_cache_argument("-fmodules-cache-path=");
-module_cache_argument.append(DefaultModuleCache.str().str());
-options.push_back(module_cache_argument);
-}
-
 StreamString minimum_version_option;
 uint32_t versions[3] = { 0, 0, 0 };
 bool use_current_os_version = false;

Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=251354&r1=251353&r2=251354&view=diff
==
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Mon Oct 26 
16:38:41 2015
@@ -27,10 +27,6 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/ProcessLaunchInfo.h"
 
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/Path.h"
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -852,64 +848,4 @@ void
 PlatformPOSIX::CalculateTrapHandlerSymbolNames ()
 {   
 m_trap_handlers.push_back (ConstString ("_sigtramp"));
-}
-
-static bool isAlphanumeric(const char c)
-{
-return ((c >= '0' && c <= '9') ||
-(c >= 'a' && c <= 'z') ||
-(c >= 'A' && c <= 'Z'));
-}
-
-static void appendUserToPath(llvm::SmallVectorImpl &Result)
-{
-const char *username = getenv("LOGNAME");
-
-if (username)
-{
-// Validate that LoginName can be used in a path, and get its length.
-size_t Len = 0;
-for (const char *P = username; *P; ++P, ++Len) {
-i

Re: [Lldb-commits] [lldb] r251340 - Clang module compilation options need to be per-platform.

2015-10-26 Thread Adrian McCarthy via lldb-commits
FYI:  This broke the Windows build (which doesn't have getuid), and the fix
wasn't immediately obvious, so I reverted the change.

Adrian.

On Mon, Oct 26, 2015 at 1:33 PM, Sean Callanan via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: spyffe
> Date: Mon Oct 26 15:33:24 2015
> New Revision: 251340
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251340&view=rev
> Log:
> Clang module compilation options need to be per-platform.
>
> On UNIX (but not Darwin) the username needs to be respected when creating a
> temporary module directory, so that different users don't pollute each
> others'
> module caches.
>
> Modified:
>
> lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
> lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
> lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
> lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h
> lldb/trunk/source/Target/Platform.cpp
>
> Modified:
> lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp?rev=251340&r1=251339&r2=251340&view=diff
>
> ==
> ---
> lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
> (original)
> +++
> lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
> Mon Oct 26 15:33:24 2015
> @@ -641,18 +641,7 @@ ClangModulesDeclVendor::Create(Target &t
>  compiler_invocation_arguments.push_back(ModuleImportBufferName);
>
>  // Add additional search paths with { "-I", path } or { "-F", path }
> here.
> -
> -{
> -llvm::SmallString<128> DefaultModuleCache;
> -const bool erased_on_reboot = false;
> -llvm::sys::path::system_temp_directory(erased_on_reboot,
> DefaultModuleCache);
> -llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang");
> -llvm::sys::path::append(DefaultModuleCache, "ModuleCache");
> -std::string module_cache_argument("-fmodules-cache-path=");
> -module_cache_argument.append(DefaultModuleCache.str().str());
> -compiler_invocation_arguments.push_back(module_cache_argument);
> -}
> -
> +
>  FileSpecList &module_search_paths =
> target.GetClangModuleSearchPaths();
>
>  for (size_t spi = 0, spe = module_search_paths.GetSize(); spi < spe;
> ++spi)
>
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=251340&r1=251339&r2=251340&view=diff
>
> ==
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Oct
> 26 15:33:24 2015
> @@ -35,6 +35,10 @@
>  #include "lldb/Target/Target.h"
>  #include "llvm/ADT/STLExtras.h"
>
> +#include "llvm/ADT/StringExtras.h"
> +#include "llvm/ADT/SmallString.h"
> +#include "llvm/Support/Path.h"
> +
>  using namespace lldb;
>  using namespace lldb_private;
>
> @@ -1476,6 +1480,17 @@ PlatformDarwin::AddClangModuleCompilatio
> apple_arguments.begin(),
> apple_arguments.end());
>
> +{
> +llvm::SmallString<128> DefaultModuleCache;
> +const bool erased_on_reboot = false;
> +llvm::sys::path::system_temp_directory(erased_on_reboot,
> DefaultModuleCache);
> +llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang");
> +llvm::sys::path::append(DefaultModuleCache, "ModuleCache");
> +std::string module_cache_argument("-fmodules-cache-path=");
> +module_cache_argument.append(DefaultModuleCache.str().str());
> +options.push_back(module_cache_argument);
> +}
> +
>  StreamString minimum_version_option;
>  uint32_t versions[3] = { 0, 0, 0 };
>  bool use_current_os_version = false;
>
> Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=251340&r1=251339&r2=251340&view=diff
>
> ==
> --- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Mon Oct 26
> 15:33:24 2015
> @@ -27,6 +27,10 @@
>  #include "lldb/Target/Process.h"
>  #include "lldb/Target/ProcessLaunchInfo.h"
>
> +#include "llvm/ADT/StringExtras.h"
> +#include "llvm/ADT/SmallString.h"
> +#include "llvm/Support/Path.h"
> +
>  using namespace lldb;
>  using namespace lldb_private;
>
> @@ -848,4 +852,64 @@ void
>  PlatformPOSIX::CalculateTrapHandlerSymbolNames ()
>  {
>  m_trap_handlers.push_back (ConstString ("_sigtramp"));
> -}
> +}
> +
> +static bool 

Re: [Lldb-commits] [PATCH] D14136: Refactor Windows process plugin to enable sharing of code between live and post-mortem debugging

2015-10-28 Thread Adrian McCarthy via lldb-commits
amccarth added inline comments.


Comment at: source/Plugins/Process/Windows/Common/ProcessWindowsForward.h:20
@@ +19,1 @@
+#endif
\ No newline at end of file


zturner wrote:
> Put a newline here
Actually, this file is obsolete, so I'm deleting it instead.  It was included 
only from LocalDebugDelegate.cpp, which no longer needs it.


Comment at: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h:22
@@ -21,3 +21,3 @@
 
 class ProcessWinMiniDump : public lldb_private::Process
 {

zturner wrote:
> I was expecting this to also derive from `ProcessWindows`, because I thought 
> that was the whole point of moving `ProcessWindows` to common and then making 
> `ProcessWindowsLive` inherit from it.  Is there goign to be some work on this 
> in a followup patch or did I misunderstand the purpose of raising that up to 
> the common area?
Good eye!  Fixed.

The intent of this patch was to make it possible to start sharing code between 
the live and mini dump versions of the RegisterContextWindows classes.  (The 
next patch will actually do that.)  The other classes (Process, TargetThread) 
came along because of tight cooperation among them and the RegisterContext 
classes.  I wasn't really focused on making the mini dump versions deal with 
those (yet).  But this was trivial to fix now.


http://reviews.llvm.org/D14136



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


[Lldb-commits] [lldb] r251549 - Add check for __main__ in dotest.py to ensure problems with multiprocessing on some Windows machines.

2015-10-28 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Oct 28 14:59:18 2015
New Revision: 251549

URL: http://llvm.org/viewvc/llvm-project?rev=251549&view=rev
Log:
Add check for __main__ in dotest.py to ensure problems with multiprocessing on 
some Windows machines.

Modified:
lldb/trunk/test/dotest.py

Modified: lldb/trunk/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=251549&r1=251548&r2=251549&view=diff
==
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Wed Oct 28 14:59:18 2015
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 
-import use_lldb_suite
+if __name__ == "__main__":
+import use_lldb_suite
 
-import lldbsuite.test
-lldbsuite.test.run_suite()
+import lldbsuite.test
+lldbsuite.test.run_suite()


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


[Lldb-commits] [PATCH] D14163: Address another race condition running tests on Windows

2015-10-28 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

Another case where sleep-and-retry avoids file access errors on Windows.

http://reviews.llvm.org/D14163

Files:
  packages/Python/lldbsuite/test/lldbtest.py

Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1820,7 +1820,14 @@
 # destination first if it already exists.
 os.remove(dst)
 
-os.rename(src, dst)
+try:
+os.rename(src, dst)
+except:
+# We've seen consistent rename failures on Windows, 
perhaps because the
+# just-created log file is being scanned by 
anti-virus.  Empirically, this
+# sleep-and-retry approach allows tests to succeed 
much more reliably.
+time.sleep(0.5)
+os.rename(src, dst)
 else:
 # success!  (and we don't want log files) delete log files
 for log_file in log_files_for_this_test:


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1820,7 +1820,14 @@
 # destination first if it already exists.
 os.remove(dst)
 
-os.rename(src, dst)
+try:
+os.rename(src, dst)
+except:
+# We've seen consistent rename failures on Windows, perhaps because the
+# just-created log file is being scanned by anti-virus.  Empirically, this
+# sleep-and-retry approach allows tests to succeed much more reliably.
+time.sleep(0.5)
+os.rename(src, dst)
 else:
 # success!  (and we don't want log files) delete log files
 for log_file in log_files_for_this_test:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D14163: Address another race condition running tests on Windows

2015-10-28 Thread Adrian McCarthy via lldb-commits
amccarth added inline comments.


Comment at: packages/Python/lldbsuite/test/lldbtest.py:1823-1830
@@ -1822,3 +1822,10 @@
 
-os.rename(src, dst)
+try:
+os.rename(src, dst)
+except:
+# We've seen consistent rename failures on Windows, 
perhaps because the
+# just-created log file is being scanned by 
anti-virus.  Empirically, this
+# sleep-and-retry approach allows tests to succeed 
much more reliably.
+time.sleep(0.5)
+os.rename(src, dst)
 else:

zturner wrote:
> I have a patch pending to create an `lldbsuite.support` package.  I wonder if 
> it would be worth sinking this "rename with retry" (and similar for 
> delete-with-retry) into this library.  Then you could call this as:
> 
> lldbsuite.support.filesystem.rename_with_retry(src, dst, 1)  # Retry up 
> to 1 time
> 
> I only mention this because this is now the second time we've had to do this 
> (other time right below), so perhaps we might need this again in the future 
> too.
> 
> I don't feel too strongly, so up to you.  If you think it's a good idea 
> though, you'll probably need to wait until my CL goes in first so that you 
> can add this method to the package (which doesn't exist yet)
I'm happy to wait.  I just glad I found the root cause.


http://reviews.llvm.org/D14163



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


[Lldb-commits] [lldb] r252100 - Fix x64 build on Windows, which was broken by my refactor from last week.

2015-11-04 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Nov  4 17:47:55 2015
New Revision: 252100

URL: http://llvm.org/viewvc/llvm-project?rev=252100&view=rev
Log:
Fix x64 build on Windows, which was broken by my refactor from last week.

No build bots build x64 on Windows yet, but this was spotted by another 
developer who emailed me directly.

Added:

lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp

lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h
  - copied, changed from r252058, 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h
Modified:

lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h

Modified: 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h?rev=252100&r1=252099&r2=252100&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h
 (original)
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h
 Wed Nov  4 17:47:55 2015
@@ -45,4 +45,4 @@ class RegisterContextWindows_x64 : publi
 };
 }
 
-#endif // #ifndef liblldb_RegisterContextPOSIX_x64_H_
+#endif // #ifndef liblldb_RegisterContextWindows_x64_H_

Added: 
lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp?rev=252100&view=auto
==
--- 
lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp
 (added)
+++ 
lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp
 Wed Nov  4 17:47:55 2015
@@ -0,0 +1,171 @@
+//===-- RegisterContextWindowsLive_x64.cpp --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/lldb-private-types.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Host/windows/HostThreadWindows.h"
+#include "lldb/Host/windows/windows.h"
+
+#include "lldb-x86-register-enums.h"
+#include "RegisterContextWindowsLive_x64.h"
+#include "TargetThreadWindows.h"
+
+#include "llvm/ADT/STLExtras.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+RegisterContextWindowsLive_x64::RegisterContextWindowsLive_x64(Thread &thread, 
uint32_t concrete_frame_idx)
+: RegisterContextWindows_x64(thread, concrete_frame_idx)
+{
+}
+
+RegisterContextWindowsLive_x64::~RegisterContextWindowsLive_x64()
+{
+}
+
+
+bool
+RegisterContextWindowsLive_x64::ReadRegister(const RegisterInfo *reg_info, 
RegisterValue ®_value)
+{
+if (!CacheAllRegisterValues())
+return false;
+
+switch (reg_info->kinds[eRegisterKindLLDB])
+{
+case lldb_rax_x86_64:
+reg_value.SetUInt64(m_context.Rax);
+break;
+case lldb_rbx_x86_64:
+reg_value.SetUInt64(m_context.Rbx);
+break;
+case lldb_rcx_x86_64:
+reg_value.SetUInt64(m_context.Rcx);
+break;
+case lldb_rdx_x86_64:
+reg_value.SetUInt64(m_context.Rdx);
+break;
+case lldb_rdi_x86_64:
+reg_value.SetUInt64(m_context.Rdi);
+break;
+case lldb_rsi_x86_64:
+reg_value.SetUInt64(m_context.Rsi);
+break;
+case lldb_r8_x86_64:
+reg_value.SetUInt64(m_context.R8);
+break;
+case lldb_r9_x86_64:
+reg_value.SetUInt64(m_context.R9);
+break;
+case lldb_r10_x86_64:
+reg_value.SetUInt64(m_context.R10);
+break;
+case lldb_r11_x86_64:
+reg_value.SetUInt64(m_context.R11);
+break;
+case lldb_r12_x86_64:
+reg_value.SetUInt64(m_context.R12);
+break;
+case lldb_r13_x86_64:
+reg_value.SetUInt64(m_context.R13);
+break;
+case lldb_r14_x86_64:
+reg_value.SetUInt64(m_context.R14);
+break;
+case lldb_r15_x86_64:
+reg_value.SetUInt64(m_context.R15);
+break;
+case lldb_rbp_x86_64:
+reg_value.SetUInt64(m_context.Rbp);
+break;
+case lldb_rsp_x86_64:
+reg_value.SetUInt64(m_context.Rsp);
+break;
+case lldb_rip_x86_64:
+reg_value.SetUInt64(m_context.Rip);
+break;
+case lldb_rflags_x86_64:
+

Re: [Lldb-commits] [PATCH] D14163: Address another race condition running tests on Windows

2015-11-06 Thread Adrian McCarthy via lldb-commits
amccarth added a comment.

I'm not seeing this problem now that many of the other changes are in.  I'm 
going to hold off until I see it again.


http://reviews.llvm.org/D14163



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


[Lldb-commits] [PATCH] D14591: Implement register context for mini dump debugging

2015-11-11 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

The old RegisterContextWinMiniDump stub is replaced with x86 and x64 
implementations that derive from the common windows register contexts.

ProcessWindowsMiniDump grabs the WinAPI CONTEXT for each thread and stashes it 
in the thread object when building the thread list.  The threads create the 
register context, stuffing in the saved CONTEXT.

New test ensures we can see the stack and registers for the (single) frame in 
the fizzbuzz minidump.  (No variables or function names, since that inferior 
doesn't have DWARF information.)

You might also notice that I remove the thread names for MiniDump threads.  
Thread names are unavailable when port-mortem debugging Windows apps (since 
naming the thread requires having the debugger catch a special exception raised 
while the inferior is running).

http://reviews.llvm.org/D14591

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
  source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
  source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h
  source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp
  source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
  source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h
  source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
  
source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
  
source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
  
source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
  
source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h

Index: source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
===
--- /dev/null
+++ source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
@@ -0,0 +1,36 @@
+//===-- RegisterContextWindowsMiniDump_x86.h *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
+#define liblldb_RegisterContextWindowsMiniDump_x86_H_
+
+#include "lldb/lldb-forward.h"
+#include "../../Common/x86/RegisterContextWindows_x86.h"
+
+namespace lldb_private
+{
+
+class Thread;
+
+class RegisterContextWindowsMiniDump_x86 : public RegisterContextWindows_x86
+{
+  public:
+RegisterContextWindowsMiniDump_x86(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context);
+
+virtual ~RegisterContextWindowsMiniDump_x86();
+
+bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value) override;
+
+  protected:
+bool CacheAllRegisterValues() override;
+};
+
+}
+
+#endif // #ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
Index: source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
===
--- /dev/null
+++ source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
@@ -0,0 +1,47 @@
+//===-- RegisterContextWindowsMiniDump_x86.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/lldb-private-types.h"
+#include "lldb/Host/windows/windows.h"
+
+#include "RegisterContextWindowsMiniDump_x86.h"
+
+using namespace lldb;
+
+namespace lldb_private
+{
+
+RegisterContextWindowsMiniDump_x86::RegisterContextWindowsMiniDump_x86(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
+: RegisterContextWindows_x86(thread, concrete_frame_idx)
+{
+if (context)
+{
+m_context = *context;
+m_context_stale = false;
+}
+}
+
+RegisterContextWindowsMiniDump_x86::~RegisterContextWindowsMiniDump_x86()
+{
+}
+
+bool
+RegisterContextWindowsMiniDump_x86::WriteRegister(const RegisterInfo * /* reg_info */, const RegisterValue & /* reg_value */)
+{
+return false;
+}
+
+bool
+RegisterContextWindowsMiniDump_x86::CacheAllRegisterValues()
+{
+// Since this is post-mortem debugging, we e

Re: [Lldb-commits] [PATCH] D14591: Implement register context for mini dump debugging

2015-11-12 Thread Adrian McCarthy via lldb-commits
amccarth marked 3 inline comments as done.


Comment at: 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py:40
@@ +39,3 @@
+thread = self.process.GetThreadAtIndex(0)
+# The crash is in main, so there should be one frame on the stack.
+self.assertEqual(thread.GetNumFrames(), 1)

zturner wrote:
> I remember us being able to get call stacks higher than main.  But now that I 
> think about it I guess that's only true for live debugging since you have a 
> physical copy of the module loaded in your process, and you can read it's 
> EAT.  In any case, this assumption probably won't be true anymore once we 
> understand PDBs and symbol servers.  Although at that point hopefully we'll 
> have many more tests covering different scenarios.
Yes, I recognize that this will need to change when we have more debug info 
available. but it's sufficient for testing at this point.


Comment at: 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py:45
@@ +44,3 @@
+pc = frame.GetPC()
+eip = frame.FindRegister("eip")
+self.assertTrue(eip.IsValid())

zturner wrote:
> Does this work if you change `eip` to `pc`?  If so that would allow this test 
> to work in the presence of 64 bit.
Indeed, "pc" works, so I'll use that.


Comment at: source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h:42-44
@@ -44,4 +41,5 @@
 protected:
-std::string m_thread_name;
 lldb::RegisterContextSP m_reg_context_sp;
+class Data;
+std::unique_ptr m_data;  // for WinAPI-specific data
 

zturner wrote:
> Why does this class need a separate `CONTEXT` than the one that is already 
> stored in `m_reg_context_sp`?  It seems like now we're storing the `CONTEXT` 
> twice.
Because the register context isn't created right away.  It's lazily created 
later by this object, so this object needs a handle to it.  Note that the 
CONTEXT in the Data is just a pointer, so it's not actually a second copy.

The process object pulls the original CONTEXT from the mini dump, and it 
creates this thread object.  This thread object will later be called to create 
the register context object, so it has to keep track of the CONTEXT in order to 
do that.


http://reviews.llvm.org/D14591



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


[Lldb-commits] [lldb] r252950 - Implement RegisterContext for Mini Dumps.

2015-11-12 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Nov 12 15:16:15 2015
New Revision: 252950

URL: http://llvm.org/viewvc/llvm-project?rev=252950&view=rev
Log:
Implement RegisterContext for Mini Dumps.

Differential Revision: http://reviews.llvm.org/D14591

Added:
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/

lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp

lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/

lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp

lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
Removed:

lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp

lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h

lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h

lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp

lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py?rev=252950&r1=252949&r2=252950&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
 Thu Nov 12 15:16:15 2015
@@ -32,6 +32,20 @@ class MiniDumpTestCase(TestBase):
 stop_description = thread.GetStopDescription(256);
 self.assertTrue("0xc005" in stop_description);
 
+@no_debug_info_test
+def test_stack_info_in_mini_dump(self):
+"""Test that we can see the stack."""
+self.assertEqual(self.process.GetNumThreads(), 1)
+thread = self.process.GetThreadAtIndex(0)
+# The crash is in main, so there should be one frame on the stack.
+self.assertEqual(thread.GetNumFrames(), 1)
+frame = thread.GetFrameAtIndex(0)
+self.assertTrue(frame.IsValid())
+pc = frame.GetPC()
+eip = frame.FindRegister("pc")
+self.assertTrue(eip.IsValid())
+self.assertEqual(pc, eip.GetValueAsUnsigned())
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)

Modified: 
lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h?rev=252950&r1=252949&r2=252950&view=diff
==
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h 
(original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h 
Thu Nov 12 15:16:15 2015
@@ -60,8 +60,6 @@ class RegisterContextWindows : public ll
 virtual bool CacheAllRegisterValues();
 
 CONTEXT m_context;
-
-  private:
 bool m_context_stale;
 };
 }

Modified: 
lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp?rev=252950&r1=252949&r2=252950&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
 Thu Nov 12 15:16:15 2015
@@ -121,3 +121,58 @@ RegisterContextWindows_x86::GetRegisterS
 return &g_register_sets[reg_set];
 }
 
+bool
+RegisterContextWindows_x86::ReadRegister(const RegisterInfo *reg_info, 
RegisterValue ®_value)
+{
+if (!CacheAllRegisterValues())
+return false;
+
+uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+switch (reg)
+{
+case lldb_eax_i386:
+WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EAX", 
m_context.Eax);
+reg_value.

Re: [Lldb-commits] [PATCH] D14591: Implement register context for mini dump debugging

2015-11-12 Thread Adrian McCarthy via lldb-commits
This revision was automatically updated to reflect the committed changes.
amccarth marked an inline comment as done.
Closed by commit rL252950: Implement RegisterContext for Mini Dumps. (authored 
by amccarth).

Changed prior to commit:
  http://reviews.llvm.org/D14591?vs=39978&id=40082#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14591

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
  lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  
lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
  
lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h
  
lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp
  
lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
  lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
  
lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
@@ -32,6 +32,20 @@
 stop_description = thread.GetStopDescription(256);
 self.assertTrue("0xc005" in stop_description);
 
+@no_debug_info_test
+def test_stack_info_in_mini_dump(self):
+"""Test that we can see the stack."""
+self.assertEqual(self.process.GetNumThreads(), 1)
+thread = self.process.GetThreadAtIndex(0)
+# The crash is in main, so there should be one frame on the stack.
+self.assertEqual(thread.GetNumFrames(), 1)
+frame = thread.GetFrameAtIndex(0)
+self.assertTrue(frame.IsValid())
+pc = frame.GetPC()
+eip = frame.FindRegister("pc")
+self.assertTrue(eip.IsValid())
+self.assertEqual(pc, eip.GetValueAsUnsigned())
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
Index: lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
@@ -60,8 +60,6 @@
 virtual bool CacheAllRegisterValues();
 
 CONTEXT m_context;
-
-  private:
 bool m_context_stale;
 };
 }
Index: lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
@@ -121,3 +121,58 @@
 return &g_register_sets[reg_set];
 }
 
+bool
+RegisterContextWindows_x86::ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value)
+{
+if (!CacheAllRegisterValues())
+return false;
+
+uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+switch (reg)
+{
+case lldb_eax_i386:
+WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EAX", m_context.Eax);
+reg_value.SetUInt32(m_context.Eax);
+break;
+case lldb_ebx_i386:
+WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EBX", m_context.Ebx);
+reg_value.SetUInt32(m_context.Ebx);
+break;
+case lldb_ecx_i386:
+WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from ECX", m_context.Ecx);
+reg_value.SetUInt32(m_context.Ecx);
+break;
+case lldb_edx_i386:
+WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EDX", m_context.Edx);
+reg_value.SetUInt32(m_context.Edx);
+break;
+case lldb_edi_i386:
+WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EDI", m_context.Edi);
+reg_value.SetUInt32(m_context.Edi);
+break;
+case lldb_esi_i386:
+ 

[Lldb-commits] [PATCH] D14793: Enable saving of mini dumps with lldb process save-core.

2015-11-18 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

Enable the saving of a mini dump (on Windows) using the existing lldb save-core 
command.

Also plumbs a new method into SBProcess, and adds a very basic test to make 
sure it produces a file.

Future tests will open the mini dump in LLDB and make sure that it has the 
right information.

http://reviews.llvm.org/D14793

Files:
  include/lldb/API/SBProcess.h
  packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
  
packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
  packages/Python/lldbsuite/test/functionalities/process_save_core/main.cpp
  scripts/interface/SBProcess.i
  source/API/SBProcess.cpp
  source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.h
===
--- /dev/null
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.h
@@ -0,0 +1,24 @@
+//===-- ObjectFilePECOFFMiniDump.h --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ObjectFilePECOFFMiniDump_h_
+#define liblldb_ObjectFilePECOFFMiniDump_h_
+
+#include "lldb/Target/Process.h"
+
+namespace lldb_private {
+
+bool
+SaveMiniDump(const lldb::ProcessSP &process_sp,
+ const lldb_private::FileSpec &outfile,
+ lldb_private::Error &error);
+
+}  // namespace lldb_private
+
+#endif
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp
===
--- /dev/null
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp
@@ -0,0 +1,55 @@
+//===-- ObjectFilePECOFFMiniDump.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// This function is separated out from ObjectFilePECOFF.cpp to name avoid name
+// collisions with WinAPI preprocessor macros.
+
+#include "ObjectFilePECOFFMiniDump.h"
+#include "lldb/Host/FileSpec.h"
+#include "llvm/Support/ConvertUTF.h"
+
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#include   // for MiniDumpWriteDump
+#endif
+
+namespace lldb_private {
+
+bool
+SaveMiniDump(const lldb::ProcessSP &process_sp,
+ const lldb_private::FileSpec &outfile,
+ lldb_private::Error &error)
+{
+if (!process_sp) return false;
+#ifdef _WIN32
+HANDLE process_handle = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_sp->GetID());
+const std::string file_name = outfile.GetCString();
+std::wstring wide_name;
+wide_name.resize(file_name.size() + 1);
+char * result_ptr = reinterpret_cast(&wide_name[0]);
+const UTF8 *error_ptr = nullptr;
+if (!llvm::ConvertUTF8toWide(sizeof(wchar_t), file_name, result_ptr, error_ptr)) {
+error.SetErrorString("cannot convert file name");
+return false;
+}
+HANDLE file_handle = ::CreateFileW(wide_name.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+const auto result = ::MiniDumpWriteDump(process_handle, process_sp->GetID(), file_handle, MiniDumpNormal, NULL, NULL, NULL);
+::CloseHandle(file_handle);
+::CloseHandle(process_handle);
+if (!result)
+{
+error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+return false;
+}
+return true;
+#endif
+return false;
+}
+
+}  // namesapce lldb_private
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -95,6 +95,11 @@
  lldb_private::ModuleSpecList &specs);
 
 static bool
+SaveCore (const lldb::ProcessSP &process_sp,
+  const lldb_private::FileSpec &outfile,
+  lldb_private::Error &error);
+
+static bool
 MagicBytesMatch (lldb::DataBufferSP& data_sp);
 
 bool
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugin

[Lldb-commits] [lldb] r253623 - Make skipIf support the not_in function.

2015-11-19 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Thu Nov 19 18:11:38 2015
New Revision: 253623

URL: http://llvm.org/viewvc/llvm-project?rev=253623&view=rev
Log:
Make skipIf support the not_in function.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=253623&r1=253622&r2=253623&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Nov 19 18:11:38 
2015
@@ -1100,10 +1100,10 @@ def skipIfLinuxClang(func):
 # TODO: refactor current code, to make skipIfxxx functions to call this 
function
 def skipIf(bugnumber=None, oslist=None, compiler=None, compiler_version=None, 
archs=None, debug_info=None, swig_version=None, py_version=None):
 def fn(self):
-oslist_passes = oslist is None or self.getPlatform() in oslist
-compiler_passes = compiler is None or (compiler in self.getCompiler() 
and self.expectedCompilerVersion(compiler_version))
+oslist_passes = check_list_or_lambda(oslist, self.getPlatform())
+compiler_passes = check_list_or_lambda(compiler, self.getCompiler()) 
and self.expectedCompilerVersion(compiler_version)
 arch_passes = self.expectedArch(archs)
-debug_info_passes = debug_info is None or self.debug_info in debug_info
+debug_info_passes = check_list_or_lambda(debug_info, self.debug_info)
 swig_version_passes = (swig_version is None) or (not hasattr(lldb, 
'swig_version')) or (check_expected_version(swig_version[0], swig_version[1], 
lldb.swig_version))
 py_version_passes = (py_version is None) or 
check_expected_version(py_version[0], py_version[1], sys.version_info)
 


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


Re: [Lldb-commits] [PATCH] D14793: Enable saving of mini dumps with lldb process save-core.

2015-11-19 Thread Adrian McCarthy via lldb-commits
amccarth marked 5 inline comments as done.


Comment at: include/lldb/API/SBProcess.h:344-346
@@ -343,1 +343,5 @@
 
+// Save the state of the process in a core file (or mini dump on Windows).
+lldb::SBError
+SaveCore(const char *file_name);
+

clayborg wrote:
> I don't want any llvm in our public API. Especially llvm::StringRef as it 
> likes to assert when people use it incorrectly (construct one with nullptr 
> and it will assert). So no llvm or clang in our public API.
Acknowledged.


Comment at: 
packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py:20
@@ +19,3 @@
+@not_remote_testsuite_ready
+@skipUnlessWindows
+def test_windows_mini_dump (self):

zturner wrote:
> How do you feel about `@skipIf(oslist=not_in(['windows']))`?
> 
> The generic skipIf and expectedFailure decorators were extended recently and 
> are now flexible enough to handle unless cases, so I'm partial to the idea of 
> eventually killing off the rest of the decorators, and just having a single 
> one that handles everything.  But I want to dogfood the idea first and see 
> what people think about it :)
Where is not_in defined?


Comment at: source/API/SBProcess.cpp:1433-1437
@@ +1432,7 @@
+{
+ProcessSP process_sp(GetSP());
+lldb::SBFileSpec core_file(file_name);
+lldb::SBError error;
+error.SetError(PluginManager::SaveCore(process_sp, core_file.get()));
+return error;
+}

zturner wrote:
> clayborg wrote:
> > clayborg wrote:
> > > You need to check your process_sp before using it since it comes from a 
> > > std::weak_ptr<>. You also need to take the process run lock. You also 
> > > don't need to create a lldb::SBFileSpec since you actually need a 
> > > lldb_private::FileSpec. The code should be:
> > > 
> > > ```
> > > lldb::SBError
> > > SBProcess::SaveCore(const char *file_name)
> > > {
> > > lldb::SBError error;
> > > if (process_sp)
> > > {
> > > Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
> > > FileSpec core_file(file_name, false);
> > > error.ref() = PluginManager::SaveCore(process_sp, 
> > > core_file.get());
> > > }
> > > else
> > > error.SetErrorString ("SBProcess is invalid");
> > > return error;
> > > }
> > > ```
> > Code correction:
> > ```
> > lldb::SBError
> > SBProcess::SaveCore(const char *file_name)
> > {
> > lldb::SBError error;
> > if (process_sp)
> > {
> > Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
> > FileSpec core_file(file_name, false);
> > error.ref() = PluginManager::SaveCore(process_sp, core_file);
> > }
> > else
> > error.SetErrorString ("SBProcess is invalid");
> > return error;
> > }
> > ```
> > 
> > We might also want to check to make sure the process is alive (the 
> > "save-core" command makes sure the process has been launched) and we should 
> > also make sure it does the right thing if the process is running (stop the 
> > process, make a core file, then resume if the process was running, or just 
> > fail if the process is running).
> I actually wonder if it should just generate an error if the process is not 
> stopped.  Putting a bunch of extra logic in the implementation of 
> `SaveCore()` seems counter to the "thin" nature of the wrapping.  Seems to me 
> like the person using the SB API should stop it themselves before calling 
> `SaveCore`.  
> 
> What do you think?
OK, I check process_sp, I take the mutex, and I ensure that the process is 
already stopped.

I also added another test to make sure SaveCore fails if the process is not 
stopped.


Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp:17
@@ +16,3 @@
+
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"

zturner wrote:
> I think it would be better to just not even compile this file on non-Windows. 
>  Exclude it at the CMake level, and have `SaveCore()` return false directly.  
> In the future we may add a way to deal with mini dumps outside of the Windows 
> API, and then we can add that as a separate file like 
> `ObjectFilePECOFFMiniDumpRaw.cpp` which can be used always, and then delete 
> this one.
But if I pull this file out, then I have to have special casing in both the 
CMake and ObjectFilePECOFF file, which seems a violation of DRY.

If we make a general mini dump writer for any platform, then this just replaces 
this implementation.


Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp:52
@@ +51,3 @@
+#endif
+return false;
+}

clayborg wrote:
> You should fill in the error and probably use a #else clause:
> 
> #else
> error.SetErrorString("windows mini dumps are only supported on native 
> windows machines");
> return false;
> #endif
Setting the error here would create a subtl

Re: [Lldb-commits] [PATCH] D14793: Enable saving of mini dumps with lldb process save-core.

2015-11-19 Thread Adrian McCarthy via lldb-commits
amccarth updated this revision to Diff 40716.
amccarth marked an inline comment as done.
amccarth added a comment.

Addresses some of the comments.


http://reviews.llvm.org/D14793

Files:
  include/lldb/API/SBProcess.h
  include/lldb/API/SBTarget.h
  packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
  
packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
  packages/Python/lldbsuite/test/functionalities/process_save_core/main.cpp
  scripts/interface/SBProcess.i
  source/API/SBProcess.cpp
  source/Commands/CommandObjectTarget.cpp
  source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.h

Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.h
===
--- /dev/null
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.h
@@ -0,0 +1,24 @@
+//===-- ObjectFilePECOFFMiniDump.h --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ObjectFilePECOFFMiniDump_h_
+#define liblldb_ObjectFilePECOFFMiniDump_h_
+
+#include "lldb/Target/Process.h"
+
+namespace lldb_private {
+
+bool
+SaveMiniDump(const lldb::ProcessSP &process_sp,
+ const lldb_private::FileSpec &outfile,
+ lldb_private::Error &error);
+
+}  // namespace lldb_private
+
+#endif
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp
===
--- /dev/null
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp
@@ -0,0 +1,55 @@
+//===-- ObjectFilePECOFFMiniDump.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// This function is separated out from ObjectFilePECOFF.cpp to name avoid name
+// collisions with WinAPI preprocessor macros.
+
+#include "ObjectFilePECOFFMiniDump.h"
+#include "lldb/Host/FileSpec.h"
+#include "llvm/Support/ConvertUTF.h"
+
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#include   // for MiniDumpWriteDump
+#endif
+
+namespace lldb_private {
+
+bool
+SaveMiniDump(const lldb::ProcessSP &process_sp,
+ const lldb_private::FileSpec &outfile,
+ lldb_private::Error &error)
+{
+if (!process_sp) return false;
+#ifdef _WIN32
+HANDLE process_handle = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_sp->GetID());
+const std::string file_name = outfile.GetCString();
+std::wstring wide_name;
+wide_name.resize(file_name.size() + 1);
+char * result_ptr = reinterpret_cast(&wide_name[0]);
+const UTF8 *error_ptr = nullptr;
+if (!llvm::ConvertUTF8toWide(sizeof(wchar_t), file_name, result_ptr, error_ptr)) {
+error.SetErrorString("cannot convert file name");
+return false;
+}
+HANDLE file_handle = ::CreateFileW(wide_name.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+const auto result = ::MiniDumpWriteDump(process_handle, process_sp->GetID(), file_handle, MiniDumpNormal, NULL, NULL, NULL);
+::CloseHandle(file_handle);
+::CloseHandle(process_handle);
+if (!result)
+{
+error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+return false;
+}
+return true;
+#endif
+return false;
+}
+
+}  // namesapce lldb_private
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -95,6 +95,11 @@
  lldb_private::ModuleSpecList &specs);
 
 static bool
+SaveCore (const lldb::ProcessSP &process_sp,
+  const lldb_private::FileSpec &outfile,
+  lldb_private::Error &error);
+
+static bool
 MagicBytesMatch (lldb::DataBufferSP& data_sp);
 
 bool
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "ObjectFilePECOFF.h"
+#includ

Re: [Lldb-commits] [PATCH] D14793: Enable saving of mini dumps with lldb process save-core.

2015-11-19 Thread Adrian McCarthy via lldb-commits
amccarth marked an inline comment as done.


Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:159
@@ +158,3 @@
+{
+return SaveMiniDump(process_sp, outfile, error);
+}

clayborg wrote:
> I would rather just have the code from SaveMiniDump inlined in this file, no 
> need for a new file just for one function.
I would prefer that too, but it's not possible.

This implementation depends on Windows headers which create conflicts with 
identifiers used in the main file.  (I had a note about that somewhere.  If I 
can't find it, I'll add a comment explanining that.)


Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.cpp:53-55
@@ +52,4 @@
+return false;
+}
+
+}  // namesapce lldb_private

clayborg wrote:
> Remove this file and inline the code into ObjectFilePECOFF::SaveCore().
Can't do, as explained.


Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFMiniDump.h:1-24
@@ +1,24 @@
+//===-- ObjectFilePECOFFMiniDump.h --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ObjectFilePECOFFMiniDump_h_
+#define liblldb_ObjectFilePECOFFMiniDump_h_
+
+#include "lldb/Target/Process.h"
+
+namespace lldb_private {
+
+bool
+SaveMiniDump(const lldb::ProcessSP &process_sp,
+ const lldb_private::FileSpec &outfile,
+ lldb_private::Error &error);
+
+}  // namespace lldb_private
+
+#endif

clayborg wrote:
> Remove this file and inline the code into ObjectFilePECOFF::SaveCore().
Can't do as explained in previous response.


http://reviews.llvm.org/D14793



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


Re: [Lldb-commits] [lldb] r253623 - Make skipIf support the not_in function.

2015-11-20 Thread Adrian McCarthy via lldb-commits
OK, I think this works now.  I tested it a few different ways.  I'll commit
momentarily.

Thanks.

On Thu, Nov 19, 2015 at 6:16 PM, Zachary Turner  wrote:

> Adrian:
>
> I think the check_list_or_lambda function needs to be renamed to
> `check_decorator_attribute`, and it needs to handle values that are neither
> lists nor functions.  i.e. it needs to handle single values.  So I believe
> right now check_list_or_lambda does something like this:
>
> def check_list_or_lambda(list_or_lambda, value):
> if six.callable(list_or_lambda):
> return list_or_lambda(value)
> else:
> return list_or_lambda is None or value in list_or_lambda
>
> and maybe it needs to look more like this:
>
> def check_decorator_attribute(item, value):
> if attr is None:
> return True
> if six.callable(item):
> return item(value)
> elif isinstance(item, (list, tuple)):
> return value in attr
> else:
> return value == attr
>
> On Thu, Nov 19, 2015 at 5:29 PM Siva Chandra via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
>> This make the test TestVectorTypesFormatting, which is annotated with
>> @skipIf(compiler='gcc'), run when using GCC:
>>
>> http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/8661/steps/test5/logs/stdio
>>
>> On Thu, Nov 19, 2015 at 4:11 PM, Adrian McCarthy via lldb-commits
>>  wrote:
>> > Author: amccarth
>> > Date: Thu Nov 19 18:11:38 2015
>> > New Revision: 253623
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=253623&view=rev
>> > Log:
>> > Make skipIf support the not_in function.
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
>> >
>> > Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
>> > URL:
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=253623&r1=253622&r2=253623&view=diff
>> >
>> ==
>> > --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
>> > +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Nov 19
>> 18:11:38 2015
>> > @@ -1100,10 +1100,10 @@ def skipIfLinuxClang(func):
>> >  # TODO: refactor current code, to make skipIfxxx functions to call
>> this function
>> >  def skipIf(bugnumber=None, oslist=None, compiler=None,
>> compiler_version=None, archs=None, debug_info=None, swig_version=None,
>> py_version=None):
>> >  def fn(self):
>> > -oslist_passes = oslist is None or self.getPlatform() in oslist
>> > -compiler_passes = compiler is None or (compiler in
>> self.getCompiler() and self.expectedCompilerVersion(compiler_version))
>> > +oslist_passes = check_list_or_lambda(oslist,
>> self.getPlatform())
>> > +compiler_passes = check_list_or_lambda(compiler,
>> self.getCompiler()) and self.expectedCompilerVersion(compiler_version)
>> >  arch_passes = self.expectedArch(archs)
>> > -debug_info_passes = debug_info is None or self.debug_info in
>> debug_info
>> > +debug_info_passes = check_list_or_lambda(debug_info,
>> self.debug_info)
>> >  swig_version_passes = (swig_version is None) or (not
>> hasattr(lldb, 'swig_version')) or (check_expected_version(swig_version[0],
>> swig_version[1], lldb.swig_version))
>> >  py_version_passes = (py_version is None) or
>> check_expected_version(py_version[0], py_version[1], sys.version_info)
>> >
>> >
>> >
>> > ___
>> > 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 mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r253683 - Make skipIf support the not_in function (second attempt).

2015-11-20 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Fri Nov 20 12:14:24 2015
New Revision: 253683

URL: http://llvm.org/viewvc/llvm-project?rev=253683&view=rev
Log:
Make skipIf support the not_in function (second attempt).

Modified:
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=253683&r1=253682&r2=253683&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Fri Nov 20 12:14:24 
2015
@@ -648,11 +648,15 @@ def expectedFailure(expected_fn, bugnumb
 def not_in (iterable):
 return lambda x : x not in iterable
 
-def check_list_or_lambda (list_or_lambda, value):
-if six.callable(list_or_lambda):
-return list_or_lambda(value)
-else:
-return list_or_lambda is None or value is None or value in 
list_or_lambda
+def check_decorator_attribute(attr, value):
+if attr is None:
+return True
+if six.callable(attr):
+return attr(value)
+elif isinstance(attr, (list, tuple)):
+return value in attr
+else:
+return value == attr
 
 # provide a function to xfail on defined oslist, compiler version, and archs
 # if none is specified for any argument, that argument won't be checked and 
thus means for all
@@ -662,11 +666,11 @@ def check_list_or_lambda (list_or_lambda
 # @expectedFailureAll(bugnumber, ["linux"], "gcc", ['>=', '4.9'], ['i386']), 
xfail for gcc>=4.9 on linux with i386
 def expectedFailureAll(bugnumber=None, oslist=None, compiler=None, 
compiler_version=None, archs=None, triple=None, debug_info=None, 
swig_version=None, py_version=None):
 def fn(self):
-oslist_passes = check_list_or_lambda(oslist, self.getPlatform())
-compiler_passes = check_list_or_lambda(self.getCompiler(), compiler) 
and self.expectedCompilerVersion(compiler_version)
+oslist_passes = check_decorator_attribute(oslist, self.getPlatform())
+compiler_passes = check_decorator_attribute(self.getCompiler(), 
compiler) and self.expectedCompilerVersion(compiler_version)
 arch_passes = self.expectedArch(archs)
 triple_passes = triple is None or re.match(triple, 
lldb.DBG.GetSelectedPlatform().GetTriple())
-debug_info_passes = check_list_or_lambda(debug_info, self.debug_info)
+debug_info_passes = check_decorator_attribute(debug_info, 
self.debug_info)
 swig_version_passes = (swig_version is None) or (not hasattr(lldb, 
'swig_version')) or (check_expected_version(swig_version[0], swig_version[1], 
lldb.swig_version))
 py_version_passes = (py_version is None) or 
check_expected_version(py_version[0], py_version[1], sys.version_info)
 
@@ -1100,10 +1104,10 @@ def skipIfLinuxClang(func):
 # TODO: refactor current code, to make skipIfxxx functions to call this 
function
 def skipIf(bugnumber=None, oslist=None, compiler=None, compiler_version=None, 
archs=None, debug_info=None, swig_version=None, py_version=None):
 def fn(self):
-oslist_passes = oslist is None or self.getPlatform() in oslist
-compiler_passes = compiler is None or (compiler in self.getCompiler() 
and self.expectedCompilerVersion(compiler_version))
+oslist_passes = check_decorator_attribute(oslist, self.getPlatform())
+compiler_passes = check_decorator_attribute(compiler, 
self.getCompiler()) and self.expectedCompilerVersion(compiler_version)
 arch_passes = self.expectedArch(archs)
-debug_info_passes = debug_info is None or self.debug_info in debug_info
+debug_info_passes = check_decorator_attribute(debug_info, 
self.debug_info)
 swig_version_passes = (swig_version is None) or (not hasattr(lldb, 
'swig_version')) or (check_expected_version(swig_version[0], swig_version[1], 
lldb.swig_version))
 py_version_passes = (py_version is None) or 
check_expected_version(py_version[0], py_version[1], sys.version_info)
 


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


[Lldb-commits] [lldb] r253684 - FOO

2015-11-20 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Fri Nov 20 12:15:14 2015
New Revision: 253684

URL: http://llvm.org/viewvc/llvm-project?rev=253684&view=rev
Log:
FOO

Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/main.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
Modified:
lldb/trunk/include/lldb/API/SBProcess.h
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/scripts/interface/SBProcess.i
lldb/trunk/source/API/SBProcess.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=253684&r1=253683&r2=253684&view=diff
==
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Fri Nov 20 12:15:14 2015
@@ -341,6 +341,10 @@ public:
 bool
 IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
 
+// Save the state of the process in a core file (or mini dump on Windows).
+lldb::SBError
+SaveCore(const char *file_name);
+
 protected:
 friend class SBAddress;
 friend class SBBreakpoint;

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=253684&r1=253683&r2=253684&view=diff
==
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Fri Nov 20 12:15:14 2015
@@ -180,6 +180,9 @@ public:
 bool stop_at_entry,
 lldb::SBError& error);
 
+SBProcess
+LoadCore (const char *core_file);
+
 //--
 /// Launch a new process with sensible defaults.
 ///
@@ -215,9 +218,6 @@ public:
 Launch (SBLaunchInfo &launch_info, SBError& error);
 
 SBProcess
-LoadCore (const char *core_file);
-
-SBProcess
 Attach (SBAttachInfo &attach_info, SBError& error);
 
 //--

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile?rev=253684&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
 Fri Nov 20 12:15:14 2015
@@ -0,0 +1,6 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
+

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py?rev=253684&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
 Fri Nov 20 12:15:14 2015
@@ -0,0 +1,58 @@
+"""
+Test saving a core file (or mini dump).
+"""
+
+from __future__ import print_function
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+
+class ProcessSaveCoreTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@not_remote_testsuite_ready
+@skipIf(oslist=not_in(['windows']))
+def test_cannot_save_core_unless_process_stopped(self):
+"""Test that SaveCore fails if the process isn't stopped."""
+self.build()
+exe = os.path.join(os.getcwd(), "a.out")
+core = os.path.join(os.getcwd(), "core.dmp")
+target = self.dbg.CreateTarget(exe)
+process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
+self.assertNotEqual(process.GetState(), lldb.eStateStopped)
+error = process.SaveCore(core)
+self.assertTrue(error.Fail())
+
+@not_remote_testsuite_ready
+@skipIf(oslist=not_in(['windows']))
+def test_save_windows_mini_dump(self):
+"""Test th

[Lldb-commits] [lldb] r253685 - Revert "FOO"

2015-11-20 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Fri Nov 20 12:18:21 2015
New Revision: 253685

URL: http://llvm.org/viewvc/llvm-project?rev=253685&view=rev
Log:
Revert "FOO"

Accidentally commited before I was done.

This reverts commit 2ec2da4ee52780582d5e9c88b2e982a688fbdbe1.

Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/main.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
Modified:
lldb/trunk/include/lldb/API/SBProcess.h
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/scripts/interface/SBProcess.i
lldb/trunk/source/API/SBProcess.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=253685&r1=253684&r2=253685&view=diff
==
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Fri Nov 20 12:18:21 2015
@@ -341,10 +341,6 @@ public:
 bool
 IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
 
-// Save the state of the process in a core file (or mini dump on Windows).
-lldb::SBError
-SaveCore(const char *file_name);
-
 protected:
 friend class SBAddress;
 friend class SBBreakpoint;

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=253685&r1=253684&r2=253685&view=diff
==
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Fri Nov 20 12:18:21 2015
@@ -180,9 +180,6 @@ public:
 bool stop_at_entry,
 lldb::SBError& error);
 
-SBProcess
-LoadCore (const char *core_file);
-
 //--
 /// Launch a new process with sensible defaults.
 ///
@@ -218,6 +215,9 @@ public:
 Launch (SBLaunchInfo &launch_info, SBError& error);
 
 SBProcess
+LoadCore (const char *core_file);
+
+SBProcess
 Attach (SBAttachInfo &attach_info, SBError& error);
 
 //--

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile?rev=253684&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
 (removed)
@@ -1,6 +0,0 @@
-LEVEL = ../../make
-
-CXX_SOURCES := main.cpp
-
-include $(LEVEL)/Makefile.rules
-

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py?rev=253684&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
 (removed)
@@ -1,58 +0,0 @@
-"""
-Test saving a core file (or mini dump).
-"""
-
-from __future__ import print_function
-
-import os, time
-import lldb
-from lldbsuite.test.lldbtest import *
-
-class ProcessSaveCoreTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-@not_remote_testsuite_ready
-@skipIf(oslist=not_in(['windows']))
-def test_cannot_save_core_unless_process_stopped(self):
-"""Test that SaveCore fails if the process isn't stopped."""
-self.build()
-exe = os.path.join(os.getcwd(), "a.out")
-core = os.path.join(os.getcwd(), "core.dmp")
-target = self.dbg.CreateTarget(exe)
-process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
-self.assertNotEqual(process.GetState(), lldb.eStateStopped)
-error = process.SaveCore(core)
-self.assertTrue(error.Fail())
-
-@not_remote_testsuite_ready
-@skipIf(oslist=not_in(['windows']))
-def test_save_windows_mini_dump(self):
-   

Re: [Lldb-commits] [lldb] r253704 - Revert "Make skipIf support the not_in function (second attempt)."

2015-11-20 Thread Adrian McCarthy via lldb-commits
Siva did include a link in a separate thread:
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/8688

Sorry about breaking this twice.  I guess I'm going to have to get a Linux
box.


On Fri, Nov 20, 2015 at 1:14 PM, Zachary Turner via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> When you revert a commit, can you please include a log to the buildbot?
> Otherwise we have no easy way of diagnosing the failure.
>
> On Fri, Nov 20, 2015 at 12:33 PM Siva Chandra via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
>> Author: sivachandra
>> Date: Fri Nov 20 14:30:36 2015
>> New Revision: 253704
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=253704&view=rev
>> Log:
>> Revert "Make skipIf support the not_in function (second attempt)."
>>
>> Summary: This reverts commit 70dca28976ee8137acce2cc203dd394f4d761276.
>>
>> Reviewers: amccarth, zturner
>>
>> Subscribers: lldb-commits
>>
>> Differential Revision: http://reviews.llvm.org/D14881
>>
>> Modified:
>> lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
>>
>> Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
>> URL:
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=253704&r1=253703&r2=253704&view=diff
>>
>> ==
>> --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
>> +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Fri Nov 20
>> 14:30:36 2015
>> @@ -648,15 +648,11 @@ def expectedFailure(expected_fn, bugnumb
>>  def not_in (iterable):
>>  return lambda x : x not in iterable
>>
>> -def check_decorator_attribute(attr, value):
>> -if attr is None:
>> -return True
>> -if six.callable(attr):
>> -return attr(value)
>> -elif isinstance(attr, (list, tuple)):
>> -return value in attr
>> -else:
>> -return value == attr
>> +def check_list_or_lambda (list_or_lambda, value):
>> +if six.callable(list_or_lambda):
>> +return list_or_lambda(value)
>> +else:
>> +return list_or_lambda is None or value is None or value in
>> list_or_lambda
>>
>>  # provide a function to xfail on defined oslist, compiler version, and
>> archs
>>  # if none is specified for any argument, that argument won't be checked
>> and thus means for all
>> @@ -666,11 +662,11 @@ def check_decorator_attribute(attr, valu
>>  # @expectedFailureAll(bugnumber, ["linux"], "gcc", ['>=', '4.9'],
>> ['i386']), xfail for gcc>=4.9 on linux with i386
>>  def expectedFailureAll(bugnumber=None, oslist=None, compiler=None,
>> compiler_version=None, archs=None, triple=None, debug_info=None,
>> swig_version=None, py_version=None):
>>  def fn(self):
>> -oslist_passes = check_decorator_attribute(oslist,
>> self.getPlatform())
>> -compiler_passes = check_decorator_attribute(self.getCompiler(),
>> compiler) and self.expectedCompilerVersion(compiler_version)
>> +oslist_passes = check_list_or_lambda(oslist, self.getPlatform())
>> +compiler_passes = check_list_or_lambda(self.getCompiler(),
>> compiler) and self.expectedCompilerVersion(compiler_version)
>>  arch_passes = self.expectedArch(archs)
>>  triple_passes = triple is None or re.match(triple,
>> lldb.DBG.GetSelectedPlatform().GetTriple())
>> -debug_info_passes = check_decorator_attribute(debug_info,
>> self.debug_info)
>> +debug_info_passes = check_list_or_lambda(debug_info,
>> self.debug_info)
>>  swig_version_passes = (swig_version is None) or (not
>> hasattr(lldb, 'swig_version')) or (check_expected_version(swig_version[0],
>> swig_version[1], lldb.swig_version))
>>  py_version_passes = (py_version is None) or
>> check_expected_version(py_version[0], py_version[1], sys.version_info)
>>
>> @@ -1104,10 +1100,10 @@ def skipIfLinuxClang(func):
>>  # TODO: refactor current code, to make skipIfxxx functions to call this
>> function
>>  def skipIf(bugnumber=None, oslist=None, compiler=None,
>> compiler_version=None, archs=None, debug_info=None, swig_version=None,
>> py_version=None):
>>  def fn(self):
>> -oslist_passes = check_decorator_attribute(oslist,
>> self.getPlatform())
>> -compiler_passes = check_decorator_attribute(compiler,
>> self.getCompiler()) and self.expectedCompilerVersion(compiler_version)
>> +oslist_passes = oslist is None or self.getPlatform() in oslist
>> +compiler_passes = compiler is None or (compiler in
>> self.getCompiler() and self.expectedCompilerVersion(compiler_version))
>>  arch_passes = self.expectedArch(archs)
>> -debug_info_passes = check_decorator_attribute(debug_info,
>> self.debug_info)
>> +debug_info_passes = debug_info is None or self.debug_info in
>> debug_info
>>  swig_version_passes = (swig_version is None) or (not
>> hasattr(lldb, 'swig_version')) or (check_expected_version(swig_version[0],
>> swig_version[1], lldb

Re: [Lldb-commits] [PATCH] D14793: Enable saving of mini dumps with lldb process save-core.

2015-11-20 Thread Adrian McCarthy via lldb-commits
amccarth marked an inline comment as not done.
amccarth added a comment.

The new files are renamed per clayborg's suggestion.



Comment at: 
packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py:21
@@ +20,3 @@
+exe = os.path.join(os.getcwd(), "a.out")
+core = os.path.join(os.getcwd(), "core.dmp")
+target = self.dbg.CreateTarget(exe)

Given that this is proving to be a diversion right now, I'm going back to 
skipUnlessWindows.


http://reviews.llvm.org/D14793



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


Re: [Lldb-commits] [PATCH] D14793: Enable saving of mini dumps with lldb process save-core.

2015-11-20 Thread Adrian McCarthy via lldb-commits
amccarth updated this revision to Diff 40835.
amccarth added a comment.

Renames the files per the suggestion and switches back to the @skipIfWindows 
decorator on the tests (for now).


http://reviews.llvm.org/D14793

Files:
  include/lldb/API/SBProcess.h
  include/lldb/API/SBTarget.h
  packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
  
packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
  packages/Python/lldbsuite/test/functionalities/process_save_core/main.cpp
  scripts/interface/SBProcess.i
  source/API/SBProcess.cpp
  source/Commands/CommandObjectTarget.cpp
  source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
  source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h

Index: source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
===
--- /dev/null
+++ source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
@@ -0,0 +1,24 @@
+//===-- WindowsMiniDump.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_WindowsMiniDump_h_
+#define liblldb_WindowsMiniDump_h_
+
+#include "lldb/Target/Process.h"
+
+namespace lldb_private {
+
+bool
+SaveMiniDump(const lldb::ProcessSP &process_sp,
+ const lldb_private::FileSpec &outfile,
+ lldb_private::Error &error);
+
+}  // namespace lldb_private
+
+#endif
Index: source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
===
--- /dev/null
+++ source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
@@ -0,0 +1,55 @@
+//===-- WindowsMiniDump.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// This function is separated out from ObjectFilePECOFF.cpp to name avoid name
+// collisions with WinAPI preprocessor macros.
+
+#include "WindowsMiniDump.h"
+#include "lldb/Host/FileSpec.h"
+#include "llvm/Support/ConvertUTF.h"
+
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#include   // for MiniDumpWriteDump
+#endif
+
+namespace lldb_private {
+
+bool
+SaveMiniDump(const lldb::ProcessSP &process_sp,
+ const lldb_private::FileSpec &outfile,
+ lldb_private::Error &error)
+{
+if (!process_sp) return false;
+#ifdef _WIN32
+HANDLE process_handle = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_sp->GetID());
+const std::string file_name = outfile.GetCString();
+std::wstring wide_name;
+wide_name.resize(file_name.size() + 1);
+char * result_ptr = reinterpret_cast(&wide_name[0]);
+const UTF8 *error_ptr = nullptr;
+if (!llvm::ConvertUTF8toWide(sizeof(wchar_t), file_name, result_ptr, error_ptr)) {
+error.SetErrorString("cannot convert file name");
+return false;
+}
+HANDLE file_handle = ::CreateFileW(wide_name.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+const auto result = ::MiniDumpWriteDump(process_handle, process_sp->GetID(), file_handle, MiniDumpNormal, NULL, NULL, NULL);
+::CloseHandle(file_handle);
+::CloseHandle(process_handle);
+if (!result)
+{
+error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+return false;
+}
+return true;
+#endif
+return false;
+}
+
+}  // namesapce lldb_private
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -95,6 +95,11 @@
  lldb_private::ModuleSpecList &specs);
 
 static bool
+SaveCore (const lldb::ProcessSP &process_sp,
+  const lldb_private::FileSpec &outfile,
+  lldb_private::Error &error);
+
+static bool
 MagicBytesMatch (lldb::DataBufferSP& data_sp);
 
 bool
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "ObjectFilePECOFF.h"
+#include "WindowsMiniDump.h"
 
 #include "llvm/Supp

[Lldb-commits] [lldb] r253734 - Enable saving of mini dumps with lldb process save-core.

2015-11-20 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Fri Nov 20 17:09:11 2015
New Revision: 253734

URL: http://llvm.org/viewvc/llvm-project?rev=253734&view=rev
Log:
Enable saving of mini dumps with lldb process save-core.

Also adds SB API to save a core and tests that use it.

Differential Revision: http://reviews.llvm.org/D14793

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/main.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
Modified:
lldb/trunk/include/lldb/API/SBProcess.h
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/scripts/interface/SBProcess.i
lldb/trunk/source/API/SBProcess.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=253734&r1=253733&r2=253734&view=diff
==
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Fri Nov 20 17:09:11 2015
@@ -341,6 +341,10 @@ public:
 bool
 IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
 
+// Save the state of the process in a core file (or mini dump on Windows).
+lldb::SBError
+SaveCore(const char *file_name);
+
 protected:
 friend class SBAddress;
 friend class SBBreakpoint;

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=253734&r1=253733&r2=253734&view=diff
==
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Fri Nov 20 17:09:11 2015
@@ -180,6 +180,9 @@ public:
 bool stop_at_entry,
 lldb::SBError& error);
 
+SBProcess
+LoadCore (const char *core_file);
+
 //--
 /// Launch a new process with sensible defaults.
 ///
@@ -215,9 +218,6 @@ public:
 Launch (SBLaunchInfo &launch_info, SBError& error);
 
 SBProcess
-LoadCore (const char *core_file);
-
-SBProcess
 Attach (SBAttachInfo &attach_info, SBError& error);
 
 //--

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile?rev=253734&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
 Fri Nov 20 17:09:11 2015
@@ -0,0 +1,6 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
+

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py?rev=253734&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
 Fri Nov 20 17:09:11 2015
@@ -0,0 +1,58 @@
+"""
+Test saving a core file (or mini dump).
+"""
+
+from __future__ import print_function
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+
+class ProcessSaveCoreTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@not_remote_testsuite_ready
+@skipUnlessWindows
+def test_cannot_save_core_unless_process_stopped(self):
+"""Test that SaveCore fails if the process isn't stopped."""
+self.build()
+exe = os.path.join(os.getcwd(), "a.out")
+core = os.path.join(os.getcwd(), "core.dmp")
+target = self.dbg.CreateTarget(exe)
+process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
+self.assertNotEqual(process.GetState(), lldb.eStateStopped)
+error = process.SaveCore(core)
+self.assertTrue(error.Fail())
+
+@not_remote_testsuite_ready
+@skipUnlessWindows
+def test_

Re: [Lldb-commits] [PATCH] D14793: Enable saving of mini dumps with lldb process save-core.

2015-11-20 Thread Adrian McCarthy via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253734: Enable saving of mini dumps with lldb process 
save-core. (authored by amccarth).

Changed prior to commit:
  http://reviews.llvm.org/D14793?vs=40835&id=40837#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14793

Files:
  lldb/trunk/include/lldb/API/SBProcess.h
  lldb/trunk/include/lldb/API/SBTarget.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/main.cpp
  lldb/trunk/scripts/interface/SBProcess.i
  lldb/trunk/source/API/SBProcess.cpp
  lldb/trunk/source/Commands/CommandObjectTarget.cpp
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h

Index: lldb/trunk/source/API/SBProcess.cpp
===
--- lldb/trunk/source/API/SBProcess.cpp
+++ lldb/trunk/source/API/SBProcess.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamFile.h"
@@ -1425,3 +1426,27 @@
 
 return runtime_sp->IsActive();
 }
+
+lldb::SBError
+SBProcess::SaveCore(const char *file_name)
+{
+lldb::SBError error;
+ProcessSP process_sp(GetSP());
+if (!process_sp)
+{
+error.SetErrorString("SBProcess is invalid");
+return error;
+}
+
+Mutex::Locker api_locker(process_sp->GetTarget().GetAPIMutex());
+
+if (process_sp->GetState() != eStateStopped)
+{
+error.SetErrorString("the process is not stopped");
+return error;
+}
+
+FileSpec core_file(file_name, false);
+error.ref() = PluginManager::SaveCore(process_sp, core_file);
+return error;
+}
Index: lldb/trunk/source/Commands/CommandObjectTarget.cpp
===
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp
@@ -256,7 +256,7 @@
 {
 if (!symfile.Readable())
 {
-result.AppendErrorWithFormat("symbol file '%s' is not readable", core_file.GetPath().c_str());
+result.AppendErrorWithFormat("symbol file '%s' is not readable", symfile.GetPath().c_str());
 result.SetStatus (eReturnStatusFailed);
 return false;
 }
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
@@ -0,0 +1,24 @@
+//===-- WindowsMiniDump.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_WindowsMiniDump_h_
+#define liblldb_WindowsMiniDump_h_
+
+#include "lldb/Target/Process.h"
+
+namespace lldb_private {
+
+bool
+SaveMiniDump(const lldb::ProcessSP &process_sp,
+ const lldb_private::FileSpec &outfile,
+ lldb_private::Error &error);
+
+}  // namespace lldb_private
+
+#endif
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -95,6 +95,11 @@
  lldb_private::ModuleSpecList &specs);
 
 static bool
+SaveCore (const lldb::ProcessSP &process_sp,
+  const lldb_private::FileSpec &outfile,
+  lldb_private::Error &error);
+
+static bool
 MagicBytesMatch (lldb::DataBufferSP& data_sp);
 
 bool
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
@@ -0,0 +1,55 @@
+//===-- WindowsMiniDump.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distribu

Re: [Lldb-commits] [PATCH] D14793: Enable saving of mini dumps with lldb process save-core.

2015-11-20 Thread Adrian McCarthy via lldb-commits
Greg:  Since this adds a new file and I don't have a Mac, can you update
the Xcode project?

On Fri, Nov 20, 2015 at 3:11 PM, Adrian McCarthy 
wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL253734: Enable saving of mini dumps with lldb process
> save-core. (authored by amccarth).
>
> Changed prior to commit:
>   http://reviews.llvm.org/D14793?vs=40835&id=40837#toc
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D14793
>
> Files:
>   lldb/trunk/include/lldb/API/SBProcess.h
>   lldb/trunk/include/lldb/API/SBTarget.h
>
> lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/Makefile
>
> lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py
>
> lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_save_core/main.cpp
>   lldb/trunk/scripts/interface/SBProcess.i
>   lldb/trunk/source/API/SBProcess.cpp
>   lldb/trunk/source/Commands/CommandObjectTarget.cpp
>   lldb/trunk/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
>   lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
>   lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
>   lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
>   lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D14989: Fix race during process interruption

2015-11-25 Thread Adrian McCarthy via lldb-commits
amccarth added a subscriber: amccarth.
amccarth added a comment.

Nice detective work.



Comment at: include/lldb/Target/Process.h:1372
@@ +1371,3 @@
+/// @param[in] use_run_lock
+/// Whether the release the run lock after the stop.
+///

Did you mean "Whether to release ..."?


http://reviews.llvm.org/D14989



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


Re: [Lldb-commits] [lldb] r254294 - [RS] Support RenderScript struct allocations

2015-11-30 Thread Adrian McCarthy via lldb-commits
This revision seems to have created a hang on startup on Windows.  LLDB now
hangs during global static initialization on this line:

const ConstString
RenderScriptRuntime::Element::FallbackStructName("struct");

Perhaps its an initialization order problem?

Adrian.

On Mon, Nov 30, 2015 at 2:29 AM, Ewan Crawford via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: ewancrawford
> Date: Mon Nov 30 04:29:49 2015
> New Revision: 254294
>
> URL: http://llvm.org/viewvc/llvm-project?rev=254294&view=rev
> Log:
> [RS] Support RenderScript struct allocations
>
> This patch adds functionality for dumping allocations of struct elements.
> This involves:
>
> + Jitting the runtime for details on all the struct fields.
>
> + Finding the name of the struct type by looking for a global variable
> of the same type, which will have been reflected back to the java host code.
>
> + Using this struct type name to pass into expression evaluation for
> pretty printing the data for the dump command.
>
> Modified:
>
> lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
>
> lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
>
> Modified:
> lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=254294&r1=254293&r2=254294&view=diff
>
> ==
> ---
> lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
> (original)
> +++
> lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
> Mon Nov 30 04:29:49 2015
> @@ -18,7 +18,9 @@
>  #include "lldb/Core/Error.h"
>  #include "lldb/Core/Log.h"
>  #include "lldb/Core/PluginManager.h"
> +#include "lldb/Core/ValueObjectVariable.h"
>  #include "lldb/Core/RegularExpression.h"
> +#include "lldb/DataFormatters/DumpValueObjectOptions.h"
>  #include "lldb/Host/StringConvert.h"
>  #include "lldb/Symbol/Symbol.h"
>  #include "lldb/Symbol/Type.h"
> @@ -133,42 +135,61 @@ struct RenderScriptRuntime::ScriptDetail
>  empirical_type script;
>  };
>
> +// This Element class represents the Element object in RS,
> +// defining the type associated with an Allocation.
> +struct RenderScriptRuntime::Element
> +{
> +// Taken from rsDefines.h
> +enum DataKind
> +{
> +RS_KIND_USER,
> +RS_KIND_PIXEL_L = 7,
> +RS_KIND_PIXEL_A,
> +RS_KIND_PIXEL_LA,
> +RS_KIND_PIXEL_RGB,
> +RS_KIND_PIXEL_RGBA,
> +RS_KIND_PIXEL_DEPTH,
> +RS_KIND_PIXEL_YUV,
> +RS_KIND_INVALID = 100
> +};
> +
> +// Taken from rsDefines.h
> +enum DataType
> +{
> +RS_TYPE_NONE = 0,
> +RS_TYPE_FLOAT_16,
> +RS_TYPE_FLOAT_32,
> +RS_TYPE_FLOAT_64,
> +RS_TYPE_SIGNED_8,
> +RS_TYPE_SIGNED_16,
> +RS_TYPE_SIGNED_32,
> +RS_TYPE_SIGNED_64,
> +RS_TYPE_UNSIGNED_8,
> +RS_TYPE_UNSIGNED_16,
> +RS_TYPE_UNSIGNED_32,
> +RS_TYPE_UNSIGNED_64,
> +RS_TYPE_BOOLEAN
> +};
> +
> +std::vector children;   // Child Element
> fields for structs
> +empirical_type element_ptr;// Pointer to
> the RS Element of the Type
> +empirical_type type;   // Type of each
> data pointer stored by the allocation
> +empirical_type type_kind;  // Defines pixel
> type if Allocation is created from an image
> +empirical_type type_vec_size;  // Vector size
> of each data point, e.g '4' for uchar4
> +empirical_type field_count;// Number of
> Subelements
> +empirical_type datum_size; // Size of a
> single Element with padding
> +empirical_type padding;// Number of
> padding bytes
> +empirical_type array_size; // Number of
> items in array, only needed for strucrs
> +ConstString type_name;   // Name of type,
> only needed for structs
> +
> +static const ConstString FallbackStructName; // Print this as
> the type name of a struct Element
> + // If we can't
> resolve the actual struct name
> +};
> +
>  // This AllocationDetails class collects data associated with a single
>  // allocation instance.
>  struct RenderScriptRuntime::AllocationDetails
>  {
> -   // Taken from rsDefines.h
> -   enum DataKind
> -   {
> -   RS_KIND_USER,
> -   RS_KIND_PIXEL_L = 7,
> -   RS_KIND_PIXEL_A,
> -   RS_KIND_PIXEL_LA,
> -   RS_KIND_PIXEL_RGB,
> -   RS_KIND_PIXEL_RGBA,
> -   RS_KIND_PIXEL_DEPTH,
> -   RS_KIND_PIXEL_YUV,
> -   RS_KIND_INVALID = 100
> 

[Lldb-commits] [PATCH] D15092: Fix hang in global static initialization

2015-11-30 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added reviewers: EwanCrawford, zturner.
amccarth added a subscriber: lldb-commits.

A previous patch introduced a global static ConstString instance.  On Windows, 
this results in a hang because constructing the string pool appears to depend 
on other globals which haven't yet been initialized.

All other instances of static ConstStrings I could find were function static, 
so I modified the code to use a static function.

http://reviews.llvm.org/D15092

Files:
  
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Index: 
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- 
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ 
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -182,7 +182,7 @@
 empirical_type array_size; // Number of items in 
array, only needed for strucrs
 ConstString type_name;   // Name of type, only 
needed for structs
 
-static const ConstString FallbackStructName; // Print this as the 
type name of a struct Element
+static const ConstString &GetFallbackStructName();   // Print this as the 
type name of a struct Element
  // If we can't 
resolve the actual struct name
 };
 
@@ -250,7 +250,13 @@
 }
 };
 
-const ConstString RenderScriptRuntime::Element::FallbackStructName("struct");
+
+const ConstString &
+RenderScriptRuntime::Element::GetFallbackStructName()
+{
+static const ConstString FallbackStructName("struct");
+return FallbackStructName;
+}
 
 unsigned int RenderScriptRuntime::AllocationDetails::ID = 1;
 
@@ -1629,7 +1635,7 @@
 if (!elem.type_name.IsEmpty()) // Name already set
 return;
 else
-elem.type_name = Element::FallbackStructName; // Default type name if 
we don't succeed
+elem.type_name = Element::GetFallbackStructName(); // Default type 
name if we don't succeed
 
 // Find all the global variables from the script rs modules
 VariableList variable_list;
@@ -2428,7 +2434,7 @@
 {
 strm.Printf("\n(%u, %u, %u) = ", x, y, z);
 if ((type == Element::RS_TYPE_NONE) && 
(alloc->element.children.size() > 0) &&
-(alloc->element.type_name != Element::FallbackStructName))
+(alloc->element.type_name != 
Element::GetFallbackStructName()))
 {
 // Here we are dumping an Element of struct type.
 // This is done using expression evaluation with the name 
of the struct type and pointer to element.


Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -182,7 +182,7 @@
 empirical_type array_size; // Number of items in array, only needed for strucrs
 ConstString type_name;   // Name of type, only needed for structs
 
-static const ConstString FallbackStructName; // Print this as the type name of a struct Element
+static const ConstString &GetFallbackStructName();   // Print this as the type name of a struct Element
  // If we can't resolve the actual struct name
 };
 
@@ -250,7 +250,13 @@
 }
 };
 
-const ConstString RenderScriptRuntime::Element::FallbackStructName("struct");
+
+const ConstString &
+RenderScriptRuntime::Element::GetFallbackStructName()
+{
+static const ConstString FallbackStructName("struct");
+return FallbackStructName;
+}
 
 unsigned int RenderScriptRuntime::AllocationDetails::ID = 1;
 
@@ -1629,7 +1635,7 @@
 if (!elem.type_name.IsEmpty()) // Name already set
 return;
 else
-elem.type_name = Element::FallbackStructName; // Default type name if we don't succeed
+elem.type_name = Element::GetFallbackStructName(); // Default type name if we don't succeed
 
 // Find all the global variables from the script rs modules
 VariableList variable_list;
@@ -2428,7 +2434,7 @@
 {
 strm.Printf("\n(%u, %u, %u) = ", x, y, z);
 if ((type == Element::RS_TYPE_NONE) && (alloc->element.children.size() > 0) &&
-(alloc->element.type_name != Element::FallbackStructName))
+(alloc->element.type_name != Element::GetFallbackStructName()))
 {
 // Here we are dumping an Element of struct type.
 // This is done using expression evalua

Re: [Lldb-commits] [PATCH] D15092: Fix hang in global static initialization

2015-11-30 Thread Adrian McCarthy via lldb-commits
amccarth added inline comments.


Comment at: 
source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp:185
@@ -184,3 +184,3 @@
 
-static const ConstString FallbackStructName; // Print this as the 
type name of a struct Element
  // If we can't 
resolve the actual struct name

zturner wrote:
> I wonder about returning this by reference.  It seems like by convention we 
> usually pass `ConstString`s around by value.
I was following the pattern used elsewhere, like 
Breakpoint::BreakpointEventData::GetFlavorString.


http://reviews.llvm.org/D15092



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


[Lldb-commits] [lldb] r254338 - Fix hang in global static initialization

2015-11-30 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Mon Nov 30 16:18:43 2015
New Revision: 254338

URL: http://llvm.org/viewvc/llvm-project?rev=254338&view=rev
Log:
Fix hang in global static initialization

Differential Revision: http://reviews.llvm.org/D15092

Modified:

lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=254338&r1=254337&r2=254338&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
 Mon Nov 30 16:18:43 2015
@@ -182,7 +182,7 @@ struct RenderScriptRuntime::Element
 empirical_type array_size; // Number of items in 
array, only needed for strucrs
 ConstString type_name;   // Name of type, only 
needed for structs
 
-static const ConstString FallbackStructName; // Print this as the 
type name of a struct Element
+static const ConstString &GetFallbackStructName();   // Print this as the 
type name of a struct Element
  // If we can't 
resolve the actual struct name
 };
 
@@ -250,7 +250,13 @@ struct RenderScriptRuntime::AllocationDe
 }
 };
 
-const ConstString RenderScriptRuntime::Element::FallbackStructName("struct");
+
+const ConstString &
+RenderScriptRuntime::Element::GetFallbackStructName()
+{
+static const ConstString FallbackStructName("struct");
+return FallbackStructName;
+}
 
 unsigned int RenderScriptRuntime::AllocationDetails::ID = 1;
 
@@ -1629,7 +1635,7 @@ RenderScriptRuntime::FindStructTypeName(
 if (!elem.type_name.IsEmpty()) // Name already set
 return;
 else
-elem.type_name = Element::FallbackStructName; // Default type name if 
we don't succeed
+elem.type_name = Element::GetFallbackStructName(); // Default type 
name if we don't succeed
 
 // Find all the global variables from the script rs modules
 VariableList variable_list;
@@ -2428,7 +2434,7 @@ RenderScriptRuntime::DumpAllocation(Stre
 {
 strm.Printf("\n(%u, %u, %u) = ", x, y, z);
 if ((type == Element::RS_TYPE_NONE) && 
(alloc->element.children.size() > 0) &&
-(alloc->element.type_name != Element::FallbackStructName))
+(alloc->element.type_name != 
Element::GetFallbackStructName()))
 {
 // Here we are dumping an Element of struct type.
 // This is done using expression evaluation with the name 
of the struct type and pointer to element.


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


Re: [Lldb-commits] [PATCH] D15092: Fix hang in global static initialization

2015-11-30 Thread Adrian McCarthy via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254338: Fix hang in global static initialization (authored 
by amccarth).

Changed prior to commit:
  http://reviews.llvm.org/D15092?vs=41433&id=41435#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15092

Files:
  
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Index: 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -182,7 +182,7 @@
 empirical_type array_size; // Number of items in 
array, only needed for strucrs
 ConstString type_name;   // Name of type, only 
needed for structs
 
-static const ConstString FallbackStructName; // Print this as the 
type name of a struct Element
+static const ConstString &GetFallbackStructName();   // Print this as the 
type name of a struct Element
  // If we can't 
resolve the actual struct name
 };
 
@@ -250,7 +250,13 @@
 }
 };
 
-const ConstString RenderScriptRuntime::Element::FallbackStructName("struct");
+
+const ConstString &
+RenderScriptRuntime::Element::GetFallbackStructName()
+{
+static const ConstString FallbackStructName("struct");
+return FallbackStructName;
+}
 
 unsigned int RenderScriptRuntime::AllocationDetails::ID = 1;
 
@@ -1629,7 +1635,7 @@
 if (!elem.type_name.IsEmpty()) // Name already set
 return;
 else
-elem.type_name = Element::FallbackStructName; // Default type name if 
we don't succeed
+elem.type_name = Element::GetFallbackStructName(); // Default type 
name if we don't succeed
 
 // Find all the global variables from the script rs modules
 VariableList variable_list;
@@ -2428,7 +2434,7 @@
 {
 strm.Printf("\n(%u, %u, %u) = ", x, y, z);
 if ((type == Element::RS_TYPE_NONE) && 
(alloc->element.children.size() > 0) &&
-(alloc->element.type_name != Element::FallbackStructName))
+(alloc->element.type_name != 
Element::GetFallbackStructName()))
 {
 // Here we are dumping an Element of struct type.
 // This is done using expression evaluation with the name 
of the struct type and pointer to element.


Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -182,7 +182,7 @@
 empirical_type array_size; // Number of items in array, only needed for strucrs
 ConstString type_name;   // Name of type, only needed for structs
 
-static const ConstString FallbackStructName; // Print this as the type name of a struct Element
+static const ConstString &GetFallbackStructName();   // Print this as the type name of a struct Element
  // If we can't resolve the actual struct name
 };
 
@@ -250,7 +250,13 @@
 }
 };
 
-const ConstString RenderScriptRuntime::Element::FallbackStructName("struct");
+
+const ConstString &
+RenderScriptRuntime::Element::GetFallbackStructName()
+{
+static const ConstString FallbackStructName("struct");
+return FallbackStructName;
+}
 
 unsigned int RenderScriptRuntime::AllocationDetails::ID = 1;
 
@@ -1629,7 +1635,7 @@
 if (!elem.type_name.IsEmpty()) // Name already set
 return;
 else
-elem.type_name = Element::FallbackStructName; // Default type name if we don't succeed
+elem.type_name = Element::GetFallbackStructName(); // Default type name if we don't succeed
 
 // Find all the global variables from the script rs modules
 VariableList variable_list;
@@ -2428,7 +2434,7 @@
 {
 strm.Printf("\n(%u, %u, %u) = ", x, y, z);
 if ((type == Element::RS_TYPE_NONE) && (alloc->element.children.size() > 0) &&
-(alloc->element.type_name != Element::FallbackStructName))
+(alloc->element.type_name != Element::GetFallbackStructName()))
 {
 // Here we are dumping an Element of struct type.
 // This is done using expression evaluation with the name of the struct type and pointer to element.
___
lldb-com

[Lldb-commits] [PATCH] D15218: Implement GetMemoryRegionInfo for mini dumps.

2015-12-03 Thread Adrian McCarthy via lldb-commits
amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

Also tweaked process save-core to include the memory info list so that we can 
see the regions in the list.

There are no commands or SBInterfaces yet that make it possible to test this 
directly, but I'll look for an opportunity to do so as I continue to work 
toward working backtraces from mini dumps.

http://reviews.llvm.org/D15218

Files:
  source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h

Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
===
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
@@ -84,6 +84,9 @@
 lldb_private::ArchSpec
 GetArchitecture();
 
+lldb_private::Error
+GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo 
&range_info) override;
+
 protected:
 void
 Clear();
Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
===
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
@@ -27,6 +27,7 @@
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/DynamicLoader.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/UnixSignals.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
@@ -272,6 +273,60 @@
 return overlap;
 }
 
+
+Error
+ProcessWinMiniDump::GetMemoryRegionInfo(lldb::addr_t load_addr, 
lldb_private::MemoryRegionInfo &info)
+{
+Error error;
+size_t size;
+const auto list = reinterpret_cast(FindDumpStream(MemoryInfoListStream, &size));
+if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST))
+{
+error.SetErrorString("the mini dump contains no memory range 
information");
+return error;
+}
+
+if (list->SizeOfEntry < sizeof(MINIDUMP_MEMORY_INFO))
+{
+error.SetErrorString("the entries in the mini dump memory info list 
are smaller than expected");
+return error;
+}
+
+if (size < list->SizeOfHeader + list->SizeOfEntry * list->NumberOfEntries)
+{
+error.SetErrorString("the mini dump memory info list is incomplete");
+return error;
+}
+
+const auto entries = reinterpret_cast(reinterpret_cast(list) + list->SizeOfHeader);
+
+for (int i = 0; i < list->NumberOfEntries; ++i)
+{
+const auto entry = reinterpret_cast(reinterpret_cast(list) + list->SizeOfHeader + 
i*list->SizeOfEntry);
+const auto head = entry->BaseAddress;
+const auto tail = head + entry->RegionSize;
+if (head <= load_addr && load_addr < tail)
+{
+// The Windows page protection bits are not independent masks that 
can
+// be bitwise-ORed together.  For example, PAGE_EXECUTE_READ is not
+// (PAGE_EXECUTE | PAGE_READ).  To test for an access type, it's
+// necessary to test for any of the bits that provide that access 
type.
+const bool readable = entry->Protect & (PAGE_EXECUTE_READ | 
PAGE_EXECUTE_READWRITE | PAGE_READONLY | PAGE_READWRITE);
+info.SetReadable(readable ? MemoryRegionInfo::eYes : 
MemoryRegionInfo::eNo);
+const bool writable = entry->Protect & (PAGE_EXECUTE_READWRITE | 
PAGE_EXECUTE_WRITECOPY | PAGE_READWRITE | PAGE_WRITECOPY);
+info.SetWritable(writable ? MemoryRegionInfo::eYes : 
MemoryRegionInfo::eNo);
+const bool executable = entry->Protect & (PAGE_EXECUTE | 
PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY);
+info.SetExecutable(executable ? MemoryRegionInfo::eYes : 
MemoryRegionInfo::eNo);
+return error;
+}
+}
+// Note that the memory info list doesn't seem to contain ranges in kernel 
space,
+// so if you're walking a stack that has kernel frames, the stack may 
appear
+// truncated.
+error.SetErrorString("address is not in a known range");
+return error;
+}
+
 void
 ProcessWinMiniDump::Clear()
 {
Index: source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
===
--- source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
+++ source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
@@ -39,7 +39,7 @@
 return false;
 }
 HANDLE file_handle = ::CreateFileW(wide_name.c_str(), GENERIC_WRITE, 
FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-const auto result = ::MiniDumpWriteDump(process_handle, 
process_sp->GetID(), file_handle, MiniDumpNormal, NULL, NULL, NULL);
+const auto result = ::MiniDumpWriteDump(proc

Re: [Lldb-commits] [PATCH] D15218: Implement GetMemoryRegionInfo for mini dumps.

2015-12-03 Thread Adrian McCarthy via lldb-commits
amccarth updated this revision to Diff 41828.
amccarth added a comment.

Ran clang-format and removed initialization of a local variable that was no 
longer used.

Note that clang-format re-ordered the include because the change added one 
include.


http://reviews.llvm.org/D15218

Files:
  source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h

Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
===
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
@@ -84,7 +84,10 @@
 lldb_private::ArchSpec
 GetArchitecture();
 
-protected:
+lldb_private::Error GetMemoryRegionInfo(lldb::addr_t load_addr,
+lldb_private::MemoryRegionInfo &range_info) override;
+
+  protected:
 void
 Clear();
 
Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
===
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
@@ -17,21 +17,22 @@
 #include 
 #include 
 
-#include "lldb/Core/PluginManager.h"
+#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Core/State.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Target/DynamicLoader.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/Target.h"
-#include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/UnixSignals.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/ConvertUTF.h"
-#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
 
 #include "ExceptionRecord.h"
 #include "ThreadWinMiniDump.h"
@@ -272,6 +273,61 @@
 return overlap;
 }
 
+Error
+ProcessWinMiniDump::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info)
+{
+Error error;
+size_t size;
+const auto list = reinterpret_cast(FindDumpStream(MemoryInfoListStream, &size));
+if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST))
+{
+error.SetErrorString("the mini dump contains no memory range information");
+return error;
+}
+
+if (list->SizeOfEntry < sizeof(MINIDUMP_MEMORY_INFO))
+{
+error.SetErrorString("the entries in the mini dump memory info list are smaller than expected");
+return error;
+}
+
+if (size < list->SizeOfHeader + list->SizeOfEntry * list->NumberOfEntries)
+{
+error.SetErrorString("the mini dump memory info list is incomplete");
+return error;
+}
+
+for (int i = 0; i < list->NumberOfEntries; ++i)
+{
+const auto entry = reinterpret_cast(reinterpret_cast(list) +
+  list->SizeOfHeader + i * list->SizeOfEntry);
+const auto head = entry->BaseAddress;
+const auto tail = head + entry->RegionSize;
+if (head <= load_addr && load_addr < tail)
+{
+// The Windows page protection bits are not independent masks that can
+// be bitwise-ORed together.  For example, PAGE_EXECUTE_READ is not
+// (PAGE_EXECUTE | PAGE_READ).  To test for an access type, it's
+// necessary to test for any of the bits that provide that access type.
+const bool readable =
+entry->Protect & (PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_READONLY | PAGE_READWRITE);
+info.SetReadable(readable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+const bool writable =
+entry->Protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | PAGE_READWRITE | PAGE_WRITECOPY);
+info.SetWritable(writable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+const bool executable =
+entry->Protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY);
+info.SetExecutable(executable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+return error;
+}
+}
+// Note that the memory info list doesn't seem to contain ranges in kernel space,
+// so if you're walking a stack that has kernel frames, the stack may appear
+// truncated.
+error.SetErrorString("address is not in a known range");
+return error;
+}
+
 void
 ProcessWinMiniDump::Clear()
 {
Index: sour

Re: [Lldb-commits] [PATCH] D15218: Implement GetMemoryRegionInfo for mini dumps.

2015-12-04 Thread Adrian McCarthy via lldb-commits
amccarth marked 2 inline comments as done.
amccarth added a comment.

Addressed comments.


http://reviews.llvm.org/D15218



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


Re: [Lldb-commits] [PATCH] D15218: Implement GetMemoryRegionInfo for mini dumps.

2015-12-04 Thread Adrian McCarthy via lldb-commits
amccarth updated this revision to Diff 41884.
amccarth added a comment.

Address comments.

Factored the decoding of the page protection bits to share that logic between 
the live and mini dump debugging.


http://reviews.llvm.org/D15218

Files:
  source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
  source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  source/Plugins/Process/Windows/Common/ProcessWindows.h
  source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h

Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
===
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
@@ -23,7 +23,7 @@
 
 class ProcessWinMiniDump : public lldb_private::ProcessWindows
 {
-public:
+  public:
 static lldb::ProcessSP
 CreateInstance (lldb::TargetSP target_sp,
 lldb_private::Listener &listener,
@@ -84,15 +84,18 @@
 lldb_private::ArchSpec
 GetArchitecture();
 
-protected:
+lldb_private::Error
+GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &range_info) override;
+
+  protected:
 void
 Clear();
 
 bool
 UpdateThreadList(lldb_private::ThreadList &old_thread_list,
  lldb_private::ThreadList &new_thread_list) override;
 
-private:
+  private:
 // Describes a range of memory captured in the mini dump.
 struct Range {
   lldb::addr_t start;  // virtual address of the beginning of the range
Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
===
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
@@ -17,21 +17,22 @@
 #include 
 #include 
 
-#include "lldb/Core/PluginManager.h"
+#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Core/State.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Target/DynamicLoader.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/Target.h"
-#include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/UnixSignals.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/ConvertUTF.h"
-#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
 
 #include "ExceptionRecord.h"
 #include "ThreadWinMiniDump.h"
@@ -272,6 +273,51 @@
 return overlap;
 }
 
+Error
+ProcessWinMiniDump::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info)
+{
+Error error;
+size_t size;
+const auto list = reinterpret_cast(FindDumpStream(MemoryInfoListStream, &size));
+if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST))
+{
+error.SetErrorString("the mini dump contains no memory range information");
+return error;
+}
+
+if (list->SizeOfEntry < sizeof(MINIDUMP_MEMORY_INFO))
+{
+error.SetErrorString("the entries in the mini dump memory info list are smaller than expected");
+return error;
+}
+
+if (size < list->SizeOfHeader + list->SizeOfEntry * list->NumberOfEntries)
+{
+error.SetErrorString("the mini dump memory info list is incomplete");
+return error;
+}
+
+for (int i = 0; i < list->NumberOfEntries; ++i)
+{
+const auto entry = reinterpret_cast(reinterpret_cast(list) +
+  list->SizeOfHeader + i * list->SizeOfEntry);
+const auto head = entry->BaseAddress;
+const auto tail = head + entry->RegionSize;
+if (head <= load_addr && load_addr < tail)
+{
+info.SetReadable(IsPageReadable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+info.SetWritable(IsPageWritable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+info.SetExecutable(IsPageExecutable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+return error;
+}
+}
+// Note that the memory info list doesn't seem to contain ranges in kernel space,
+// so if you're walking a stack that has kernel frames, the stack may appear
+// truncated.
+error.SetErrorString("address is not in a known range");
+return error;
+}
+
 void
 ProcessWinMiniDump::Clear()
 {
Index: source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp
=

Re: [Lldb-commits] [PATCH] D15218: Implement GetMemoryRegionInfo for mini dumps.

2015-12-04 Thread Adrian McCarthy via lldb-commits
amccarth updated this revision to Diff 41898.
amccarth added a comment.

After discussion with Zach, we concluded that his original logic for 
IsPageReadable was better.


http://reviews.llvm.org/D15218

Files:
  source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
  source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  source/Plugins/Process/Windows/Common/ProcessWindows.h
  source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h

Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
===
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
@@ -23,7 +23,7 @@
 
 class ProcessWinMiniDump : public lldb_private::ProcessWindows
 {
-public:
+  public:
 static lldb::ProcessSP
 CreateInstance (lldb::TargetSP target_sp,
 lldb_private::Listener &listener,
@@ -84,15 +84,18 @@
 lldb_private::ArchSpec
 GetArchitecture();
 
-protected:
+lldb_private::Error
+GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &range_info) override;
+
+  protected:
 void
 Clear();
 
 bool
 UpdateThreadList(lldb_private::ThreadList &old_thread_list,
  lldb_private::ThreadList &new_thread_list) override;
 
-private:
+  private:
 // Describes a range of memory captured in the mini dump.
 struct Range {
   lldb::addr_t start;  // virtual address of the beginning of the range
Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
===
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
@@ -17,21 +17,22 @@
 #include 
 #include 
 
-#include "lldb/Core/PluginManager.h"
+#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Core/State.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Target/DynamicLoader.h"
+#include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/Target.h"
-#include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/UnixSignals.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/ConvertUTF.h"
-#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
 
 #include "ExceptionRecord.h"
 #include "ThreadWinMiniDump.h"
@@ -272,6 +273,51 @@
 return overlap;
 }
 
+Error
+ProcessWinMiniDump::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info)
+{
+Error error;
+size_t size;
+const auto list = reinterpret_cast(FindDumpStream(MemoryInfoListStream, &size));
+if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST))
+{
+error.SetErrorString("the mini dump contains no memory range information");
+return error;
+}
+
+if (list->SizeOfEntry < sizeof(MINIDUMP_MEMORY_INFO))
+{
+error.SetErrorString("the entries in the mini dump memory info list are smaller than expected");
+return error;
+}
+
+if (size < list->SizeOfHeader + list->SizeOfEntry * list->NumberOfEntries)
+{
+error.SetErrorString("the mini dump memory info list is incomplete");
+return error;
+}
+
+for (int i = 0; i < list->NumberOfEntries; ++i)
+{
+const auto entry = reinterpret_cast(reinterpret_cast(list) +
+  list->SizeOfHeader + i * list->SizeOfEntry);
+const auto head = entry->BaseAddress;
+const auto tail = head + entry->RegionSize;
+if (head <= load_addr && load_addr < tail)
+{
+info.SetReadable(IsPageReadable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+info.SetWritable(IsPageWritable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+info.SetExecutable(IsPageExecutable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+return error;
+}
+}
+// Note that the memory info list doesn't seem to contain ranges in kernel space,
+// so if you're walking a stack that has kernel frames, the stack may appear
+// truncated.
+error.SetErrorString("address is not in a known range");
+return error;
+}
+
 void
 ProcessWinMiniDump::Clear()
 {
Index: source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp

[Lldb-commits] [lldb] r254780 - Implement GetMemoryRegionInfo for mini dumps.

2015-12-04 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Fri Dec  4 16:22:15 2015
New Revision: 254780

URL: http://llvm.org/viewvc/llvm-project?rev=254780&view=rev
Log:
Implement GetMemoryRegionInfo for mini dumps.

Differential Revision: http://reviews.llvm.org/D15218

Modified:
lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h
lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp?rev=254780&r1=254779&r2=254780&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp Fri Dec  4 
16:22:15 2015
@@ -39,7 +39,8 @@ SaveMiniDump(const lldb::ProcessSP &proc
 return false;
 }
 HANDLE file_handle = ::CreateFileW(wide_name.c_str(), GENERIC_WRITE, 
FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-const auto result = ::MiniDumpWriteDump(process_handle, 
process_sp->GetID(), file_handle, MiniDumpNormal, NULL, NULL, NULL);
+const auto result = ::MiniDumpWriteDump(process_handle, 
process_sp->GetID(), file_handle,
+MiniDumpWithFullMemoryInfo, NULL, 
NULL, NULL);
 ::CloseHandle(file_handle);
 ::CloseHandle(process_handle);
 if (!result)

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp?rev=254780&r1=254779&r2=254780&view=diff
==
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp Fri Dec 
 4 16:22:15 2015
@@ -15,6 +15,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Core/State.h"
+#include "lldb/Host/windows/windows.h"
 #include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/Target.h"
@@ -74,4 +75,26 @@ ProcessWindows::GetImageInfoAddress()
 return LLDB_INVALID_ADDRESS;
 }
 
+// The Windows page protection bits are NOT independent masks that can be 
bitwise-ORed
+// together.  For example, PAGE_EXECUTE_READ is not (PAGE_EXECUTE | PAGE_READ).
+// To test for an access type, it's necessary to test for any of the bits that 
provide
+// that access type.
+bool
+ProcessWindows::IsPageReadable(uint32_t protect)
+{
+return (protect & PAGE_NOACCESS) == 0;
+}
+
+bool
+ProcessWindows::IsPageWritable(uint32_t protect)
+{
+return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | 
PAGE_READWRITE | PAGE_WRITECOPY)) != 0;
+}
+
+bool
+ProcessWindows::IsPageExecutable(uint32_t protect)
+{
+return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | 
PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)) != 0;
+}
+
 }

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h?rev=254780&r1=254779&r2=254780&view=diff
==
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h Fri Dec  
4 16:22:15 2015
@@ -34,6 +34,17 @@ public:
 size_t PutSTDIN(const char *buf, size_t buf_size, lldb_private::Error 
&error) override;
 
 lldb::addr_t GetImageInfoAddress() override;
+
+protected:
+// These decode the page protection bits.
+static bool
+IsPageReadable(uint32_t protect);
+
+static bool
+IsPageWritable(uint32_t protect);
+
+static bool
+IsPageExecutable(uint32_t protect);
 };
 
 }

Modified: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp?rev=254780&r1=254779&r2=254780&view=diff
==
--- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp Fri 
Dec  4 16:22:15 2015
@@ -743,12 +743,13 @@ ProcessWindowsLive::GetMemoryRegionInfo(
  error.GetError(), vm_addr);
 return error;
 }
-bool readable = !(mem_info.Protect &

  1   2   3   4   >