[Lldb-commits] [lldb] r339920 - Fix lldb-vscode build on Windows

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 16 13:13:07 PDT 2018


It would be interesting to have some sort of warning or static analyzer to avoid platform specific name conflicts like CreateEvent. People always use "id" as a variable name and that can cause problems when a header is included in objective C. 

Thanks for the windows fixes. 

> On Aug 16, 2018, at 11:24 AM, Reid Kleckner via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Author: rnk
> Date: Thu Aug 16 11:24:59 2018
> New Revision: 339920
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=339920&view=rev
> Log:
> Fix lldb-vscode build on Windows
> 
> Include PosixAPI.h to get a PATH_MAX definition and replace CreateEvent
> with CreateEventObject to avoid conflicts with the windows.h definition
> of CreateEvent to CreateEventW.
> 
> Modified:
>    lldb/trunk/tools/lldb-vscode/JSONUtils.cpp
>    lldb/trunk/tools/lldb-vscode/JSONUtils.h
>    lldb/trunk/tools/lldb-vscode/VSCode.cpp
>    lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
> 
> Modified: lldb/trunk/tools/lldb-vscode/JSONUtils.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/JSONUtils.cpp?rev=339920&r1=339919&r2=339920&view=diff
> ==============================================================================
> --- lldb/trunk/tools/lldb-vscode/JSONUtils.cpp (original)
> +++ lldb/trunk/tools/lldb-vscode/JSONUtils.cpp Thu Aug 16 11:24:59 2018
> @@ -12,6 +12,7 @@
> #include "lldb/API/SBBreakpoint.h"
> #include "lldb/API/SBBreakpointLocation.h"
> #include "lldb/API/SBValue.h"
> +#include "lldb/Host/PosixApi.h"
> 
> #include "ExceptionBreakpoint.h"
> #include "JSONUtils.h"
> @@ -351,7 +352,7 @@ void AppendBreakpoint(lldb::SBBreakpoint
> //   "required": [ "seq", "type" ]
> // }
> //----------------------------------------------------------------------
> -llvm::json::Object CreateEvent(const llvm::StringRef event_name) {
> +llvm::json::Object CreateEventObject(const llvm::StringRef event_name) {
>   llvm::json::Object event;
>   event.try_emplace("seq", 0);
>   event.try_emplace("type", "event");
> @@ -734,7 +735,7 @@ llvm::json::Value CreateThread(lldb::SBT
> //----------------------------------------------------------------------
> llvm::json::Value CreateThreadStopped(lldb::SBThread &thread,
>                                       uint32_t stop_id) {
> -  llvm::json::Object event(CreateEvent("stopped"));
> +  llvm::json::Object event(CreateEventObject("stopped"));
>   llvm::json::Object body;
>   switch (thread.GetStopReason()) {
>   case lldb::eStopReasonTrace:
> 
> Modified: lldb/trunk/tools/lldb-vscode/JSONUtils.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/JSONUtils.h?rev=339920&r1=339919&r2=339920&view=diff
> ==============================================================================
> --- lldb/trunk/tools/lldb-vscode/JSONUtils.h (original)
> +++ lldb/trunk/tools/lldb-vscode/JSONUtils.h Thu Aug 16 11:24:59 2018
> @@ -225,7 +225,7 @@ llvm::json::Value CreateBreakpoint(lldb:
> ///     A "Event" JSON object with that follows the formal JSON
> ///     definition outlined by Microsoft.
> //----------------------------------------------------------------------
> -llvm::json::Object CreateEvent(const llvm::StringRef event_name);
> +llvm::json::Object CreateEventObject(const llvm::StringRef event_name);
> 
> //----------------------------------------------------------------------
> /// Create a "ExceptionBreakpointsFilter" JSON object as described in
> 
> Modified: lldb/trunk/tools/lldb-vscode/VSCode.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/VSCode.cpp?rev=339920&r1=339919&r2=339920&view=diff
> ==============================================================================
> --- lldb/trunk/tools/lldb-vscode/VSCode.cpp (original)
> +++ lldb/trunk/tools/lldb-vscode/VSCode.cpp Thu Aug 16 11:24:59 2018
> @@ -226,7 +226,7 @@ void VSCode::SendOutput(OutputType o, co
>   if (output.empty())
>     return;
> 
> -  llvm::json::Object event(CreateEvent("output"));
> +  llvm::json::Object event(CreateEventObject("output"));
>   llvm::json::Object body;
>   const char *category = nullptr;
>   switch (o) {
> 
> Modified: lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp?rev=339920&r1=339919&r2=339920&view=diff
> ==============================================================================
> --- lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp (original)
> +++ lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp Thu Aug 16 11:24:59 2018
> @@ -122,7 +122,7 @@ std::vector<const char *> MakeArgv(const
> // Send a "exited" event to indicate the process has exited.
> //----------------------------------------------------------------------
> void SendProcessExitedEvent(lldb::SBProcess &process) {
> -  llvm::json::Object event(CreateEvent("exited"));
> +  llvm::json::Object event(CreateEventObject("exited"));
>   llvm::json::Object body;
>   body.try_emplace("exitCode", (int64_t)process.GetExitStatus());
>   event.try_emplace("body", std::move(body));
> @@ -130,7 +130,7 @@ void SendProcessExitedEvent(lldb::SBProc
> }
> 
> void SendThreadExitedEvent(lldb::tid_t tid) {
> -  llvm::json::Object event(CreateEvent("thread"));
> +  llvm::json::Object event(CreateEventObject("thread"));
>   llvm::json::Object body;
>   body.try_emplace("reason", "exited");
>   body.try_emplace("threadId", (int64_t)tid);
> @@ -146,7 +146,7 @@ void SendTerminatedEvent() {
>   if (!g_vsc.sent_terminated_event) {
>     g_vsc.sent_terminated_event = true;
>     // Send a "terminated" event
> -    llvm::json::Object event(CreateEvent("terminated"));
> +    llvm::json::Object event(CreateEventObject("terminated"));
>     g_vsc.SendJSON(llvm::json::Value(std::move(event)));
>   }
> }
> @@ -287,7 +287,7 @@ void SendProcessEvent(LaunchMethod launc
>   lldb::SBFileSpec exe_fspec = g_vsc.target.GetExecutable();
>   char exe_path[PATH_MAX];
>   exe_fspec.GetPath(exe_path, sizeof(exe_path));
> -  llvm::json::Object event(CreateEvent("process"));
> +  llvm::json::Object event(CreateEventObject("process"));
>   llvm::json::Object body;
>   body.try_emplace("name", std::string(exe_path));
>   const auto pid = g_vsc.target.GetProcess().GetProcessID();
> @@ -398,7 +398,7 @@ void EventThreadFunction() {
>               auto bp_loc =
>                   lldb::SBBreakpoint::GetBreakpointLocationAtIndexFromEvent(
>                       event, i);
> -              auto bp_event = CreateEvent("breakpoint");
> +              auto bp_event = CreateEventObject("breakpoint");
>               llvm::json::Object body;
>               body.try_emplace("breakpoint", CreateBreakpoint(bp_loc));
>               if (added)
> @@ -596,7 +596,7 @@ void request_attach(const llvm::json::Ob
>   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
>   if (error.Success()) {
>     SendProcessEvent(Attach);
> -    g_vsc.SendJSON(CreateEvent("initialized"));
> +    g_vsc.SendJSON(CreateEventObject("initialized"));
>     // SendThreadStoppedEvent();
>   }
> }
> @@ -1284,7 +1284,7 @@ void request_launch(const llvm::json::Ob
>   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
> 
>   SendProcessEvent(Launch);
> -  g_vsc.SendJSON(llvm::json::Value(CreateEvent("initialized")));
> +  g_vsc.SendJSON(llvm::json::Value(CreateEventObject("initialized")));
>   // Reenable async events and start the event thread to catch async events.
>   g_vsc.debugger.SetAsync(true);
> }
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list