[Lldb-commits] [lldb] r365390 - [Windows] Convert GetLastError to std::error_code

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 8 15:40:43 PDT 2019


Why is the thread ID getting checked against -1L? Did Windows not define LLDB_INVALID_HOST_THREAD?

Jim

> On Jul 8, 2019, at 3:06 PM, Pavel Labath via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Are you sure this will actually produce something meaningful? I know
> llvm usually uses llvm::mapWindowsError for this kind of thing...
> 
> On Mon, 8 Jul 2019 at 14:18, Jonas Devlieghere via lldb-commits
> <lldb-commits at lists.llvm.org> wrote:
>> 
>> Author: jdevlieghere
>> Date: Mon Jul  8 14:19:02 2019
>> New Revision: 365390
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=365390&view=rev
>> Log:
>> [Windows] Convert GetLastError to std::error_code
>> 
>> Create a std::error_code from the result of GetLastError, which in turn
>> we can use to return an llvm::Error.
>> 
>> Modified:
>>    lldb/trunk/source/Host/common/ThreadLauncher.cpp
>> 
>> Modified: lldb/trunk/source/Host/common/ThreadLauncher.cpp
>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/ThreadLauncher.cpp?rev=365390&r1=365389&r2=365390&view=diff
>> ==============================================================================
>> --- lldb/trunk/source/Host/common/ThreadLauncher.cpp (original)
>> +++ lldb/trunk/source/Host/common/ThreadLauncher.cpp Mon Jul  8 14:19:02 2019
>> @@ -31,8 +31,10 @@ llvm::Expected<HostThread> ThreadLaunche
>>   thread = (lldb::thread_t)::_beginthreadex(
>>       0, (unsigned)min_stack_byte_size,
>>       HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL);
>> -  if (thread == (lldb::thread_t)(-1L))
>> -    return llvm::errorCodeToError(::GetLastError());
>> +  if (thread == (lldb::thread_t)(-1L)) {
>> +    DWORD err = GetLastError();
>> +    return llvm::errorCodeToError(std::error_code(err, std::system_category()));
>> +  }
>> #else
>> 
>> // ASAN instrumentation adds a lot of bookkeeping overhead on stack frames.
>> 
>> 
>> _______________________________________________
>> lldb-commits mailing list
>> lldb-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list