multiprocess+ target remote and resume after breakpoint hit

Matthias Pfaller <[email protected]>
Newsgroups gmane.comp.gdb.devel
Organization marco Systemanalyse und Entwicklung GmbH
Message-ID <[email protected]>
Hi,

I have implemented a remote gdb stub for our bare metal targets. It's integrated into 
our rtos and makes use of the DWT/FPB unit integrated into the cortex-m cores for 
break points, watch points and single stepping. As the gdbstub runs as its own 
thread, I'm running in "non stop" mode. Break and watch points are context switched, 
i.e. every thread has its own set of breask and watch points. I'm reporting every 
thread as a new inferior with one single thread. That way gdb will keep track of 
break and watch points on a per-thread basis. To make things work I still need the 
following change:

This inhibits gdb from stopping every thread when attaching:

--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2759,15 +2759,26 @@ notice_new_inferior (thread_info *thr, bool leave_running, 
int from_tty)
        /* We're going to install breakpoints, and poke at memory,
          ensure that the inferior is stopped for a moment while we do
          that.  */
-      target_stop (inferior_ptid);
+      if (! target_is_non_stop_p ())
+       {
+         target_stop (inferior_ptid);

-      inferior->control.stop_soon = STOP_QUIETLY_REMOTE;
+         inferior->control.stop_soon = STOP_QUIETLY_REMOTE;

-      /* Wait for stop before proceeding.  */
-      inferior->add_continuation ([=] ()
+         /* Wait for stop before proceeding.  */
+         inferior->add_continuation ([=] ()
+         {
+           attach_post_wait (from_tty, mode);
+         });
+         inferior->control.stop_soon = STOP_QUIETLY_REMOTE;
+       }
+      else
         {
-         attach_post_wait (from_tty, mode);
-       });
+         if (inferior->needs_setup)
+           setup_inferior (from_tty);
+         inferior->control.stop_soon = NO_STOP_QUIETLY;
+         proceed_after_attach (inferior);
+       }

        return;
      }

This makes sure that every thread gets its own pspace/aspace to ensure per-thread 
break/watch points (I'm sure this is not the correct place to do this):

diff --git a/gdb/remote.c b/gdb/remote.c
index 173f4c94075..fb6b53e0297 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2899,7 +2899,16 @@ remote_target::remote_add_inferior (bool fake_pid_p, int pid, 
int attached,
         {
           /* Since all inferiors were already bound to a process, add
              a new inferior.  */
+#if 0
           inf = add_inferior_with_spaces ();
+#else
+         inf = add_inferior (pid);
+         inf->pspace = new program_space (new_address_space ());
+         inf->aspace = inf->pspace->aspace;
+         clone_program_space (inf->pspace, current_program_space);
+         inf->set_arch (current_inferior ()->arch ());
+         inf->tdesc_info = current_inferior ()->tdesc_info;
+#endif
         }
        switch_to_inferior_no_thread (inf);
        inf->push_target (this);

Interrupting and continuing threads  is working fine. But when I set a break point 
and the thread is interrupted, gdb will still stop all threads. It will then disable 
the break point, step over the break point and reanable the break point. After this 
is done it will continue all threads. But my system will of course die when all 
threads are stopped... I would need gdb to stop only the threads associated with the 
break point. Is there anybody else working on something similar?

Is there a way for the target to communicate to gdb that every thread is using the 
same executable?

best Regards, Matthhias
smime.p7s (application/pkcs7-signature, 4.6 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.