qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/1] scripts/qemugdb/coroutine.py: get pthread p


From: Roman Penyaev
Subject: Re: [Qemu-devel] [PATCH 1/1] scripts/qemugdb/coroutine.py: get pthread pointer from '(gdb) thread info $id' output
Date: Tue, 14 Mar 2017 12:00:19 +0100

On Tue, Mar 14, 2017 at 11:21 AM, Paolo Bonzini <address@hidden> wrote:
>
>
> On 14/03/2017 11:08, Roman Pen wrote:
>> For sure under corefile debugging it is not possible to invoke
>> any syscalls, like arch_prctl(), so avoid doing that.  That will
>> simplify the script.
>
> Is the issue that start_thread only works in the main thread stack (i.e.
> not on coroutines)?

In my case I simply do not have libc6-dbg around.  And yes, what
you've mentioned is also the issue.

>
>> +    num = gdb.selected_thread().num
>> +    thr = gdb.execute('info thread %d' % num, to_string=True)
>
> What versions of gdb support gdb.execute?

Seems the beginning of python support in gdb (starting from gdb-7, right?).
At least git blame shows me this modification date on particular function:

d57a3c85f6eee (Thiago Jung Bauermann 2008-08-06 19:41:33 +0000 315)
execute_gdb_command (PyObject *self, PyObject *args)

and gdb-7 was released on October 06, 2009.

> Also, what happens if localization is in effect?

According to the gdb sources (I am not gdb developer, but this is quite
straightforward to find) this is not the issue.

What is the issue is that different targets output different lines.
Linux is always the same, no worries, take a look

   gdb/linux-thread-db.c: thread_db_pid_to_str():
        snprintf (buf, sizeof (buf), "Thread 0x%lx (LWP %ld)",

but e.g. bsd output should be different:

   gdb/bsd-uthread.c: bsd_uthread_pid_to_str():
        xsnprintf (buf, sizeof buf, "process %d, thread 0x%lx",

If this is the issue I can add third variant of getting correct
pthread_self() and make the priority:

  1. parse 'info thread'
  2. parse 'start_thread(arg=XXX)'
  3. go to arch_prctl() invocation.

But frankly this is far from simplification, from what I've started :)

--
Roman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]