@@ -863,42 +863,35 @@ int64_t Variables::InsertExpandableVariable(lldb::SBValue variable,
863863bool StartDebuggingRequestHandler::DoExecute (
864864 lldb::SBDebugger debugger, char **command,
865865 lldb::SBCommandReturnObject &result) {
866- // Command format like: `startDebugging <launch|attach> <configuration>`
866+ // Command format like: `start-debugging <launch|attach> <configuration>`
867867 if (!command) {
868- result.SetError (" Invalid use of startDebugging " );
869- result. SetStatus (lldb::eReturnStatusFailed );
868+ result.SetError (" Invalid use of start-debugging, expected format "
869+ " `start-debugging <launch|attach> <configuration>`. " );
870870 return false ;
871871 }
872872
873873 if (!command[0 ] || llvm::StringRef (command[0 ]).empty ()) {
874- result.SetError (" startDebugging request type missing." );
875- result.SetStatus (lldb::eReturnStatusFailed);
874+ result.SetError (" start-debugging request type missing." );
876875 return false ;
877876 }
878877
879878 if (!command[1 ] || llvm::StringRef (command[1 ]).empty ()) {
880- result.SetError (" configuration missing." );
881- result.SetStatus (lldb::eReturnStatusFailed);
879+ result.SetError (" start-debugging debug configuration missing." );
882880 return false ;
883881 }
884882
885883 llvm::StringRef request{command[0 ]};
886884 std::string raw_configuration{command[1 ]};
887885
888- int i = 2 ;
889- while (command[i]) {
890- raw_configuration.append (" " ).append (command[i]);
891- }
892-
893886 llvm::Expected<llvm::json::Value> configuration =
894887 llvm::json::parse (raw_configuration);
895888
896889 if (!configuration) {
897890 llvm::Error err = configuration.takeError ();
898- std::string msg =
899- " Failed to parse json configuration: " + llvm::toString (std::move (err));
891+ std::string msg = " Failed to parse json configuration: " +
892+ llvm::toString (std::move (err)) + " \n\n " +
893+ raw_configuration;
900894 result.SetError (msg.c_str ());
901- result.SetStatus (lldb::eReturnStatusFailed);
902895 return false ;
903896 }
904897
@@ -966,6 +959,44 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger debugger,
966959 return true ;
967960}
968961
962+ // Sends a custom DAP event with an optional body.
963+ //
964+ // See
965+ // https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent
966+ bool CustomDAPEventRequestHandler::DoExecute (
967+ lldb::SBDebugger debugger, char **command,
968+ lldb::SBCommandReturnObject &result) {
969+ // Command format like: `custom-event <name> <body>?`
970+ if (!command || !command[0 ] || llvm::StringRef (command[0 ]).empty ()) {
971+ result.SetError (" Invalid use of custom-event, expected format "
972+ " `custom-event <name> <body>?`." );
973+ return false ;
974+ }
975+
976+ llvm::StringRef name{command[0 ]};
977+ llvm::json::Object event (CreateEventObject (name));
978+
979+ if (command[1 ] && !llvm::StringRef (command[1 ]).empty ()) {
980+ llvm::StringRef raw_body{command[1 ]};
981+
982+ llvm::Expected<llvm::json::Value> body = llvm::json::parse (raw_body);
983+
984+ if (!body) {
985+ llvm::Error err = body.takeError ();
986+ std::string msg = " Failed to parse custom event body: " +
987+ llvm::toString (std::move (err));
988+ result.SetError (msg.c_str ());
989+ return false ;
990+ }
991+
992+ event.try_emplace (" body" , std::move (*body));
993+ }
994+
995+ g_dap.SendJSON (llvm::json::Value (std::move (event)));
996+ result.SetStatus (lldb::eReturnStatusSuccessFinishNoResult);
997+ return true ;
998+ }
999+
9691000void DAP::SetFrameFormat (llvm::StringRef format) {
9701001 if (format.empty ())
9711002 return ;
0 commit comments