[Lldb-commits] [PATCH] D64647: <WIP> [lldb] [Process/NetBSD] Multithread support

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 19 08:36:07 PDT 2019


mgorny added a comment.
Herald added a subscriber: dexonsmith.

So I've made some progress on this. However, I'm stuck and I'd use some help going forward.

I've made a trivial two-threaded program:

  #include <stdio.h>
  #include <assert.h>
  #include <unistd.h>
  #include <pthread.h>
  
  void* thread_func(void* x) {
  	printf("thread 1\n");
  	int i;
  	for (i = 0; i < 100; i++)
  	{
  		printf("t2 %d\n", i);
  		sleep(3);
  	}
  	return NULL;
  }
  
  int main() {
  	pthread_t t;
  
  	printf("step 1\n");
  	assert(!pthread_create(&t, NULL, thread_func, NULL));
  	printf("step 2\n");
  	int i;
  	for (i = 0; i < 100; i++)
  	{
  		printf("t1 %d\n", i);
  		sleep(3);
  	}
  	assert(!pthread_join(t, NULL));
  	printf("step 3\n");
  
  	return 0;
  }

Now, if I start it, then issue `process interrupt`, then `thread continue 1`, everything works as expected. However, if I interrupt it again and then `thread continue 2` (i.e. try to change the thread running), nothing happens.

According to the gdb-remote log, `vCont` is received but nothing is sent back (though normally stdout should happen). If I send any other command, lldb-server dies:

  1568906517.952658892 <  16> read packet: $vCont;c:0002#a4
  1568906874.978140354 <   1> read packet: 
  lldb-server exiting...

According to the posix log, Resume is working as expected.

  1568906976.934143305 NativeProcessNetBSD.cpp:Resume                               no action specified for pid 12124 tid 1
  1568906976.934377670 NativeProcessNetBSD.cpp:Resume                               processing resume action state suspended signal 2147483647 for pid 12124 tid 1
  1568906976.934622765 NativeProcessNetBSD.cpp:Resume                               processing resume action state running signal 2147483647 for pid 12124 tid 2

I suspect I'm not setting some state correctly but I so far haven't managed to figure out which.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64647/new/

https://reviews.llvm.org/D64647





More information about the lldb-commits mailing list