This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "record save" failure


On 01/22/2014 04:11 AM, Sergio Durigan Junior wrote:
On Tuesday, January 21 2014, Hui Zhu wrote:

Prec didn't support multithread.

Even so, GDB shouldn't segfault like that.

Cedric, thanks for the report.  Would it be possible for you to test
this with our git HEAD?  Also, if you still find the issue with git
HEAD, could you please file a bug in our bugzilla about this issue?
Thanks.

fails too with GNU gdb (GDB) 7.7.50.20140121-cvs (git cloned yesterday)
Attached is a little C program that exhibits the problem.
You need two terminals: Tprog and Tgdb.
In Tprog: compile and run recthr.
When it stops, in Tgdb, launch gdb.
Then press enter in Tprog, and, well, follow what the program
asks you to do.

What it does is: create a thread th1, wait for gdb, th1 quits
(so that gdb sees th1 leaving, I think that's the triggering
event) and th2 is created, then gdb records a function run by that
thread and when it's done the user asks for "record save"
which fails. Then the user types "info record" and everyone
goes back to nowhere. (Maybe th2 is not necessary here.)

I think you set a global variable to the TID of th1. But th1 has gone
away when I record th2, so asking the kernel for th1's registers' values
fails. Or something like that.

I still have a 64b computer here, with debian. But I bet it would fail
with something else. (Maybe you have to run the linux kernel, not
even sure about that...)

I let you deal with your bug tracking stuff, I'm not good with those. :)

On my side I will try to change the TID for the one I record but since
you don't support multi-threading recording I won't bother you with my
little hacks, which, I fear, will be terribly dirty. (Note though
that the recording is done with "scheduler-locking on", which means I
record a single thread.)

Happy hacking!
Cédric.
/* compile with: gcc -pthread -Wall recthr.c -o recthr */
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

volatile int th1_done;

void *th1(void *_)
{
  printf("run\ngdb -p %d\nthen in gdb type:\ncont\nand press enter in this term\n", getpid());
  getchar();
  th1_done = 1;
  return 0;
}

int traceme(void)
{
  int x=0;
  int i=0;
  for (x = 0; x < 10; x++) i += x*2;
  return i;
}

void after_traceme(int x)
{
  printf("%d\n", x);
}

void *th2(void *x)
{
  int i = traceme();
  after_traceme(i);
  return 0;
}

void new_thread(void *(*f)(void *))
{
  pthread_t th;
  pthread_create(&th, 0, f, 0);
}

int main(void)
{
  new_thread(th1);
  while (!th1_done) usleep(10*1000);
  printf("type:\nctrl+c\nhb *%p\nhb *%p\ncont\nin gdb and press enter in this term\n",
         traceme, after_traceme);
  getchar();
  printf("type:\nset scheduler-locking on\nrecord full\ncont\nin gdb\n");
  printf("then:\nrecord save /tmp/XX\nit should fail\n");
  printf("then type:\ninfo record\nit should segfault\n");
  printf("and happy debugging to you too.:)\n");
  new_thread(th2);
  while (1) pause();
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]