[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [issues] arm gdb backtrace for read syscall
- To: Carlos O'Donell <carlos@xxxxxxxxxxxxxxxx>
- Subject: Re: [issues] arm gdb backtrace for read syscall
- From: Matthieu CASTET <matthieu.castet@xxxxxxxxxx>
- Date: Mon, 20 Oct 2008 16:38:25 +0200
Carlos O'Donell a écrit :
> On Mon, Oct 20, 2008 at 4:23 AM, Matthieu CASTET
> <matthieu.castet@xxxxxxxxxx> wrote:
>>> Could you describe the behaviour you would like?
>> I would like that when a process is block on the read system call, I can
>> get the complete backtrace ie getting caller of the read syscall.
>> This is the case for example for sigwaitinfo syscall.
>
> Please provide a test-case.
>
Ok here a testcase. /tmp/fifo could be a fifo, an uart or whatever you like.
For info with gdb 6.8, I got [1].
Matthieu
Note that not memseting 'buff' leads to different results (ie we got the
dl_resolver call in the backtrace).
[1]
(gdb) info threads
[New Thread 723]
2 Thread 723 0x40033844 in read ()
from /opt/arm-eglibc/arm-none-linux-gnueabi/libc/lib/libpthread.so.0
* 1 Thread 722 0x4002b8b8 in pthread_join (threadid=0x4095d490,
thread_return=0xbecfdd64) at pthread_join.c:89
(gdb) thread 2
[Switching to thread 2 (Thread 723)]#0 0x40033844 in read ()
from /opt/arm-eglibc/arm-none-linux-gnueabi/libc/lib/libpthread.so.0
Current language: auto; currently asm
(gdb) bt
#0 0x40033844 in read ()
from /opt/arm-eglibc/arm-none-linux-gnueabi/libc/lib/libpthread.so.0
#1 0x400330ac in __pthread_enable_asynccancel () at cancellation.c:42
#2 0x00000000 in ?? ()
#include <pthread.h>
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/* to be build with gcc -O0 -g -lpthread
*/
#define CHECK(x) do { \
assert(x==0); \
} while (0)
void *reader(void *data)
{
char buff [10];
int fd = open("/tmp/fifo", O_RDONLY);
/* clean the stack */
memset(buff, 0, 10);
while (1) {
if (fd != -1) {
read(fd, buff, 1);
}
}
}
void launch_thread(pthread_attr_t *attr, void *(*start_routine)(void *))
{
size_t guardsize;
size_t stacksize;
pthread_t thandle;
void *ret;
int res;
printf("creating thread %p\n", start_routine);
res = pthread_create(&thandle, attr, start_routine, NULL);
printf("done with status %d %s\n", res, strerror(res));
if (res == 0) {
CHECK(pthread_join(thandle, &ret));
}
}
int main()
{
launch_thread(NULL, reader);
return 0;
}