500-thread-timeout.patch 943 B

123456789101112131415161718192021222324252627282930313233
  1. --- a/gdb/gdbserver/thread-db.c
  2. +++ b/gdb/gdbserver/thread-db.c
  3. @@ -21,6 +21,7 @@
  4. Foundation, Inc., 51 Franklin Street, Fifth Floor,
  5. Boston, MA 02110-1301, USA. */
  6. +#include <unistd.h>
  7. #include "server.h"
  8. #include "linux-low.h"
  9. @@ -134,6 +135,7 @@
  10. td_event_msg_t msg;
  11. td_err_e err;
  12. struct inferior_linux_data *tdata;
  13. + int timeout;
  14. if (debug_threads)
  15. fprintf (stderr, "Thread creation event.\n");
  16. @@ -144,7 +146,13 @@
  17. In the LinuxThreads implementation, this is safe,
  18. because all events come from the manager thread
  19. (except for its own creation, of course). */
  20. - err = td_ta_event_getmsg (thread_agent, &msg);
  21. + for (timeout = 0; timeout < 50000; timeout++)
  22. + {
  23. + err = td_ta_event_getmsg (thread_agent, &msg);
  24. + if (err != TD_NOMSG)
  25. + break;
  26. + usleep(1000);
  27. + }
  28. if (err != TD_OK)
  29. fprintf (stderr, "thread getmsg err: %s\n",
  30. thread_db_err_str (err));