@@ -117,6 +117,9 @@ func (grp *TargetGroup) addTarget(p ProcessInternal, pid int, currentThread Thre
117117 }
118118 t , err := grp .newTarget (p , pid , currentThread , path , cmdline )
119119 if err != nil {
120+ // Notify listeners that a child process was spawned even though we
121+ // can't debug it - listeners may care about non-Go processes.
122+ grp .notifyProcessSpawned (pid , currentThread .ThreadID (), cmdline )
120123 return nil , err
121124 }
122125 t .StopReason = stopReason
@@ -145,9 +148,29 @@ func (grp *TargetGroup) addTarget(p ProcessInternal, pid int, currentThread Thre
145148 }
146149 }
147150 grp .targets = append (grp .targets , t )
151+
152+ // Notify listeners that a child process was spawned. We do this after the
153+ // new target has been set up.
154+ grp .notifyProcessSpawned (pid , currentThread .ThreadID (), cmdline )
148155 return t , nil
149156}
150157
158+ func (grp * TargetGroup ) notifyProcessSpawned (pid , threadID int , cmdline string ) {
159+ fn := grp .Selected .BinInfo ().eventsFn
160+ if fn == nil {
161+ return
162+ }
163+
164+ fn (& Event {
165+ Kind : EventProcessSpawned ,
166+ ProcessSpawnedEventDetails : & ProcessSpawnedEventDetails {
167+ PID : pid ,
168+ ThreadID : threadID ,
169+ Cmdline : cmdline ,
170+ },
171+ })
172+ }
173+
151174// Targets returns a slice of all targets in the group, including the
152175// ones that are no longer valid.
153176func (grp * TargetGroup ) Targets () []* Target {
@@ -576,6 +599,7 @@ type Event struct {
576599 Kind EventKind
577600 * BinaryInfoDownloadEventDetails
578601 * BreakpointMaterializedEventDetails
602+ * ProcessSpawnedEventDetails
579603}
580604
581605type EventKind uint8
@@ -585,6 +609,7 @@ const (
585609 EventStopped
586610 EventBinaryInfoDownload
587611 EventBreakpointMaterialized
612+ EventProcessSpawned
588613)
589614
590615// BinaryInfoDownloadEventDetails describes the details of a BinaryInfoDownloadEvent
@@ -596,3 +621,10 @@ type BinaryInfoDownloadEventDetails struct {
596621type BreakpointMaterializedEventDetails struct {
597622 Breakpoint * LogicalBreakpoint
598623}
624+
625+ // ProcessSpawnedEventDetails describes the details of a ProcessSpawnedEvent
626+ type ProcessSpawnedEventDetails struct {
627+ PID int
628+ ThreadID int
629+ Cmdline string
630+ }
0 commit comments