[Lldb-commits] Inconsistency in cmakefile vs code

2019-07-10 Thread Carlo Kok via lldb-commits

In:
lldb\source\Plugins\Process\Windows\Common\CMakeLists.txt

these files are built based on the SYSTEM Architecture:

if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
  target_sources(lldbPluginProcessWindowsCommon PRIVATE
x64/RegisterContextWindows_x64.cpp)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i?86|X86")
  target_sources(lldbPluginProcessWindowsCommon PRIVATE
x86/RegisterContextWindows_x86.cpp)
endif()


but later they're used based on the defines (which will the target arch, it's 
not uncommon to compile on x86_64 for i386, since the engine has to match 
exactly on Windows)
#if defined(_M_AMD64)
...
#if defined(_M_IX86)
...

Locally I've changed this to unconditionally include the files and use ifdefs 
in the context files. but that is less than ideal.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r365295 - Change LaunchThread interface to return an Expected for non-Apple-non-Windows

2019-07-08 Thread Carlo Kok via lldb-commits
This looks to be broken on Windows: 

SeverityCodeDescription Project FileLineSuppression 
State
Error   C2555   'lldb_private::HostProcessWindows::StartMonitoring': overriding 
virtual function return type differs and is not covariant from 
'lldb_private::HostNativeProcessBase::StartMonitoring'   
lldbPluginProcessWindowsCommon  
C:\p\llvm\llvm\tools\lldb\include\lldb\Host\windows\HostProcessWindows.h
33  
Error   C2664   'llvm::Expected 
lldb_private::ThreadLauncher::LaunchThread(llvm::StringRef,lldb::thread_func_t,lldb::thread_arg_t,size_t)':
 cannot convert argument 4 from 'lldb_private::Status *' to 'size_t'   
lldbPluginProcessWindowsCommon  
C:\p\llvm\llvm\tools\lldb\source\Plugins\Process\Windows\Common\DebuggerThread.cpp
  68  
Error   C2664   'llvm::Expected 
lldb_private::ThreadLauncher::LaunchThread(llvm::StringRef,lldb::thread_func_t,lldb::thread_arg_t,size_t)':
 cannot convert argument 4 from 'lldb_private::Status *' to 'size_t'   
lldbPluginProcessWindowsCommon  
C:\p\llvm\llvm\tools\lldb\source\Plugins\Process\Windows\Common\DebuggerThread.cpp
  85  

On Mon, Jul 8, 2019, at 09:06, Fangrui Song via lldb-commits wrote:
> Author: maskray
> Date: Mon Jul  8 00:07:05 2019
> New Revision: 365295
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=365295&view=rev
> Log:
> Change LaunchThread interface to return an Expected for non-Apple-non-Windows
> 
> Fixes Linux build errors after D64163/r365226
> 
> Modified:
> lldb/trunk/include/lldb/Host/Host.h
> lldb/trunk/include/lldb/Host/HostNativeProcessBase.h
> lldb/trunk/include/lldb/Host/HostProcess.h
> lldb/trunk/include/lldb/Host/posix/HostProcessPosix.h
> lldb/trunk/source/Host/common/Host.cpp
> lldb/trunk/source/Host/common/HostProcess.cpp
> lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp
> lldb/trunk/source/Host/common/ProcessLaunchInfo.cpp
> lldb/trunk/source/Host/posix/HostProcessPosix.cpp
> 
> Modified: lldb/trunk/include/lldb/Host/Host.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=365295&r1=365294&r2=365295&view=diff
> ==
> --- lldb/trunk/include/lldb/Host/Host.h (original)
> +++ lldb/trunk/include/lldb/Host/Host.h Mon Jul  8 00:07:05 2019
> @@ -99,7 +99,7 @@ public:
>/// was spawned to monitor \a pid.
>///
>/// \see static void Host::StopMonitoringChildProcess (uint32_t)
> -  static HostThread
> +  static llvm::Expected
>StartMonitoringChildProcess(const MonitorChildProcessCallback 
> &callback,
>lldb::pid_t pid, bool monitor_signals);
>  
> 
> Modified: lldb/trunk/include/lldb/Host/HostNativeProcessBase.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostNativeProcessBase.h?rev=365295&r1=365294&r2=365295&view=diff
> ==
> --- lldb/trunk/include/lldb/Host/HostNativeProcessBase.h (original)
> +++ lldb/trunk/include/lldb/Host/HostNativeProcessBase.h Mon Jul  8 
> 00:07:05 2019
> @@ -35,7 +35,7 @@ public:
>  
>lldb::process_t GetSystemHandle() const { return m_process; }
>  
> -  virtual HostThread
> +  virtual llvm::Expected
>StartMonitoring(const Host::MonitorChildProcessCallback &callback,
>bool monitor_signals) = 0;
>  
> 
> Modified: lldb/trunk/include/lldb/Host/HostProcess.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostProcess.h?rev=365295&r1=365294&r2=365295&view=diff
> ==
> --- lldb/trunk/include/lldb/Host/HostProcess.h (original)
> +++ lldb/trunk/include/lldb/Host/HostProcess.h Mon Jul  8 00:07:05 2019
> @@ -43,8 +43,9 @@ public:
>lldb::pid_t GetProcessId() const;
>bool IsRunning() const;
>  
> -  HostThread StartMonitoring(const Host::MonitorChildProcessCallback 
> &callback,
> - bool monitor_signals);
> +  llvm::Expected
> +  StartMonitoring(const Host::MonitorChildProcessCallback &callback,
> +  bool monitor_signals);
>  
>HostNativeProcessBase &GetNativeProcess();
>const HostNativeProcessBase &GetNativeProcess() const;
> 
> Modified: lldb/trunk/include/lldb/Host/posix/HostProcessPosix.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/HostProcessPosix.h?rev=365295&r1=365294&r2=365295&view=diff
> ==
> --- lldb/trunk/include/lldb/Host/posix/HostProcessPosix.h (original)
> +++ lldb/trunk/include/lldb/Host/posix/HostProcessPosix.h Mon Jul  8 
> 00:07:05 2019
> @@ -32,8 +32,9 @@ public:
>lldb::pid_t GetProcessId() const override;
>bool IsRunning() const override;
>  
> -  HostThread StartMonitoring(const Host::MonitorChildProcessCallback 
> &callback,
> 

Re: [Lldb-commits] [PATCH] D25681: [PseudoTerminal] Fix PseudoTerminal MSVC release crash

2016-10-18 Thread Carlo Kok via lldb-commits
fwiw this looks good to me, a much better fix than I had. but it'z 
zturner who objected to my approach.


On 2016-10-17 17:51, Rudy Pons via lldb-commits wrote:

Ilod created this revision.
Ilod added reviewers: zturner, carlokok.
Ilod added a subscriber: lldb-commits.

Since r278177, the Posix functions in PseudoTerminal::OpenFirstAvailableMaster 
on windows are now inlined LLVM_UNREACHABLE instead of return 0.
This causes __assume(0) to be inlined in OpenFirstAvailableMaster, allowing the 
optimizer to change code because this function should never be executed. In 
particular, on Visual 2015 Update 3 Win32 Release builds, the optimizer skips 
the if (error_str) test, causing a crash if error_str is nullptr.
The added #if !defined(LLDB_DISABLE_POSIX) restore the previous behaviour 
(which was doing nothing and returning true, as every function was returning 0, 
and prevent crashes.
The crash was 100% when launching a test x86 executable (built with clang, 
linked with lld-link) in lldb.
I don't know if there is another fix in progress (not calling the function on 
Win32?), but it seems to be called from several places, so it may be simpler to 
fix it in PseudoTerminal.


https://reviews.llvm.org/D25681

Files:
  source/Utility/PseudoTerminal.cpp


Index: source/Utility/PseudoTerminal.cpp
===
--- source/Utility/PseudoTerminal.cpp
+++ source/Utility/PseudoTerminal.cpp
@@ -88,6 +88,7 @@
   if (error_str)
 error_str[0] = '\0';

+#if !defined(LLDB_DISABLE_POSIX)
   // Open the master side of a pseudo terminal
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
@@ -111,6 +112,7 @@
 CloseMasterFileDescriptor();
 return false;
   }
+#endif

   return true;
 }




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



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


[Lldb-commits] [PATCH] D24960: Remove unreachable from apis in posix terminal compat windows and return 0

2016-09-27 Thread Carlo Kok via lldb-commits
carlokok created this revision.
carlokok added a subscriber: LLDB.
carlokok set the repository for this revision to rL LLVM.
carlokok added a project: LLDB.

These apis are called by lldb process launching but the unreachable causes them 
to fail on Windows. However, they don't have to do anything because Windows has 
implied support for terminals.

Repository:
  rL LLVM

https://reviews.llvm.org/D24960

Files:
  /lldb/trunk/include/lldb/Host/windows/PosixApi.h

Index: /lldb/trunk/include/lldb/Host/windows/PosixApi.h
===
--- /lldb/trunk/include/lldb/Host/windows/PosixApi.h
+++ /lldb/trunk/include/lldb/Host/windows/PosixApi.h
@@ -98,19 +98,19 @@
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
 // empty functions
-inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; }
+inline int posix_openpt(int flag) { return 0; }
 
 inline int strerror_r(int errnum, char *buf, size_t buflen) {
-  LLVM_BUILTIN_UNREACHABLE;
+  return 0;
 }
 
-inline int unlockpt(int fd) { LLVM_BUILTIN_UNREACHABLE; }
-inline int grantpt(int fd) { LLVM_BUILTIN_UNREACHABLE; }
-inline char *ptsname(int fd) { LLVM_BUILTIN_UNREACHABLE; }
 
-inline pid_t fork(void) { LLVM_BUILTIN_UNREACHABLE; }
-inline pid_t setsid(void) { LLVM_BUILTIN_UNREACHABLE; }
+inline int unlockpt(int fd) { return 0; }
+inline int grantpt(int fd) { return 0; }
+inline char *ptsname(int fd) { return 0; }
 
+inline pid_t fork(void) { return 0; }
+inline pid_t setsid(void) { return 0; }
 // vsnprintf and snprintf are provided in MSVC 2015 and higher.
 #if _MSC_VER < 1900
 namespace lldb_private {


Index: /lldb/trunk/include/lldb/Host/windows/PosixApi.h
===
--- /lldb/trunk/include/lldb/Host/windows/PosixApi.h
+++ /lldb/trunk/include/lldb/Host/windows/PosixApi.h
@@ -98,19 +98,19 @@
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
 // empty functions
-inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; }
+inline int posix_openpt(int flag) { return 0; }
 
 inline int strerror_r(int errnum, char *buf, size_t buflen) {
-  LLVM_BUILTIN_UNREACHABLE;
+  return 0;
 }
 
-inline int unlockpt(int fd) { LLVM_BUILTIN_UNREACHABLE; }
-inline int grantpt(int fd) { LLVM_BUILTIN_UNREACHABLE; }
-inline char *ptsname(int fd) { LLVM_BUILTIN_UNREACHABLE; }
 
-inline pid_t fork(void) { LLVM_BUILTIN_UNREACHABLE; }
-inline pid_t setsid(void) { LLVM_BUILTIN_UNREACHABLE; }
+inline int unlockpt(int fd) { return 0; }
+inline int grantpt(int fd) { return 0; }
+inline char *ptsname(int fd) { return 0; }
 
+inline pid_t fork(void) { return 0; }
+inline pid_t setsid(void) { return 0; }
 // vsnprintf and snprintf are provided in MSVC 2015 and higher.
 #if _MSC_VER < 1900
 namespace lldb_private {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r271876 - (Minor tweak) Make RegisterContextWindows_x86/x64::GetRegisterInfoAtIndex

2016-06-06 Thread Carlo Kok via lldb-commits
Author: carlokok
Date: Mon Jun  6 04:40:27 2016
New Revision: 271876

URL: http://llvm.org/viewvc/llvm-project?rev=271876&view=rev
Log:
(Minor tweak) Make RegisterContextWindows_x86/x64::GetRegisterInfoAtIndex 
return NULL for an invalid register.

The unwind logic asks for the "return address register" which doesn't exist
on x86/x86_64, returns -1 and calls this with -1 as a parameter, ends up 
out of scope of the array bounds for g_register_infos and later SIGSEGVs 
on accessing. This now matches the other GetRegisterInfoAtIndex for
other platforms.


Modified:

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

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

Modified: 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp?rev=271876&r1=271875&r2=271876&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
 Mon Jun  6 04:40:27 2016
@@ -136,6 +136,8 @@ RegisterInfo g_register_infos[] = {
  nullptr},
 };
 
+static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
+
 // Array of lldb register numbers used to define the set of all General 
Purpose Registers
 uint32_t g_gpr_reg_indices[] = {eRegisterIndexRax, eRegisterIndexRbx,   
eRegisterIndexRcx, eRegisterIndexRdx,
 eRegisterIndexRdi, eRegisterIndexRsi,   
eRegisterIndexR8,  eRegisterIndexR9,
@@ -169,7 +171,9 @@ RegisterContextWindows_x64::GetRegisterC
 const RegisterInfo *
 RegisterContextWindows_x64::GetRegisterInfoAtIndex(size_t reg)
 {
-return &g_register_infos[reg];
+if (reg < k_num_register_infos)
+return &g_register_infos[reg];
+return NULL;
 }
 
 size_t

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=271876&r1=271875&r2=271876&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
 Mon Jun  6 04:40:27 2016
@@ -64,6 +64,7 @@ RegisterInfo g_register_infos[] =
 { DEFINE_GPR(eip,"pc"), { ehframe_eip_i386, dwarf_eip_i386,
  LLDB_REGNUM_GENERIC_PC,LLDB_INVALID_REGNUM,  lldb_eip_i386   },  nullptr, 
 nullptr},
 { DEFINE_GPR_BIN(eflags, "flags"), { ehframe_eflags_i386, 
dwarf_eflags_i386,   LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM,  
lldb_eflags_i386},  nullptr,  nullptr},
 };
+static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
 
 // Array of lldb register numbers used to define the set of all General 
Purpose Registers
 uint32_t g_gpr_reg_indices[] =
@@ -106,7 +107,9 @@ RegisterContextWindows_x86::GetRegisterC
 const RegisterInfo *
 RegisterContextWindows_x86::GetRegisterInfoAtIndex(size_t reg)
 {
-return &g_register_infos[reg];
+if (reg < k_num_register_infos)
+return &g_register_infos[reg];
+return NULL;
 }
 
 size_t


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