@@ -557,11 +557,6 @@ class Target : public std::enable_shared_from_this<Target>,
557557 TargetEventData (const lldb::TargetSP &target_sp,
558558 const ModuleList &module_list);
559559
560- TargetEventData (const lldb::TargetSP &target_sp, std::string session_name);
561-
562- TargetEventData (const lldb::TargetSP &target_sp,
563- const ModuleList &module_list, std::string session_name);
564-
565560 ~TargetEventData () override ;
566561
567562 static llvm::StringRef GetFlavorString ();
@@ -570,8 +565,6 @@ class Target : public std::enable_shared_from_this<Target>,
570565 return TargetEventData::GetFlavorString ();
571566 }
572567
573- static llvm::StringRef GetSessionNameFromEvent (const Event *event_ptr);
574-
575568 void Dump (Stream *s) const override ;
576569
577570 static const TargetEventData *GetEventDataFromEvent (const Event *event_ptr);
@@ -587,7 +580,6 @@ class Target : public std::enable_shared_from_this<Target>,
587580 private:
588581 lldb::TargetSP m_target_sp;
589582 ModuleList m_module_list;
590- std::string m_session_name;
591583
592584 TargetEventData (const TargetEventData &) = delete ;
593585 const TargetEventData &operator =(const TargetEventData &) = delete ;
@@ -631,6 +623,30 @@ class Target : public std::enable_shared_from_this<Target>,
631623 // / requirements.
632624 llvm::Error SetLabel (llvm::StringRef label);
633625
626+ // / Get the target session name for this target.
627+ // /
628+ // / Provides a meaningful name for IDEs or tools to display for dynamically
629+ // / created targets. Defaults to "Session {ID}" based on the globally unique
630+ // / ID.
631+ // /
632+ // / \return
633+ // / The target session name for this target.
634+ const std::string &GetTargetSessionName () { return m_target_session_name; }
635+
636+ // / Set the target session name for this target.
637+ // /
638+ // / This should typically be set along with the event
639+ // / eBroadcastBitNewTargetCreated. Useful for scripts or triggers that
640+ // / automatically create targets and want to provide meaningful names that
641+ // / IDEs or other tools can display to help users identify the origin and
642+ // / purpose of each target.
643+ // /
644+ // / \param[in] target_session_name
645+ // / The target session name to set for this target.
646+ void SetTargetSessionName (llvm::StringRef target_session_name) {
647+ m_target_session_name = target_session_name.str ();
648+ }
649+
634650 // / Find a binary on the system and return its Module,
635651 // / or return an existing Module that is already in the Target.
636652 // /
@@ -1672,8 +1688,11 @@ class Target : public std::enable_shared_from_this<Target>,
16721688 bool m_is_dummy_target;
16731689 unsigned m_next_persistent_variable_index = 0 ;
16741690 lldb::user_id_t m_target_unique_id =
1675- LLDB_INVALID_GLOBALLY_UNIQUE_TARGET_ID; // / The globally unique ID
1691+ LLDB_INVALID_GLOBALLY_UNIQUE_TARGET_ID; // /< The globally unique ID
16761692 // / assigned to this target
1693+ std::string m_target_session_name; // /< The target session name for this
1694+ // / target, used to name debugging
1695+ // / sessions in DAP.
16771696 // / An optional \a lldb_private::Trace object containing processor trace
16781697 // / information of this target.
16791698 lldb::TraceSP m_trace_sp;
0 commit comments