можно ли использовать несколько потоков для ptrace приложение?

Функция инженерного анализа базы данных microsoft Visio превосходна для того, чтобы вытащить схему из базы данных и разработать оттуда. Я исследовал бы ту авеню, если Вы уже не имеете.

8
задан Evan Teran 18 June 2009 в 04:07
поделиться

2 ответа

As far as I can tell, this is not allowed. A task cannot use ptrace on a task which it has not attached. Also, a task can be traced by at most one other task, so you can't simply attach it once in each thread. I think this is because when one task attaches to another task, the tracing task becomes the parent of the traced task, and each task can only have one parent.

It seems like multi-thread tracing ought to be allowed because the threads are part of the same process, but implementation-wise, there isn't actually much distinction between threads and processes in the Linux kernel. A thread is just a task that happens to share most of its resources with another task.

If you're interested, you can browse the source code for ptrace in the kernel. Specifically look at ptrace_check_attach, which is called by sys_ptrace for most requests. It returns -ESRCH (sounds like the error code you're getting) if the target task's parent is not the current task.

4
ответ дан 5 December 2019 в 19:02
поделиться

У меня была такая же проблема (плюс многие другие!) При реализации специфичной для Linux части отладчика Maxine VM . Вы правы в своем предположении, что только один поток в отладчике может использовать ptrace для управления отлаживаемой программой. Мы достигаем этого, выполняя все вызовы ptrace в выделенном потоке. Возможно, вам будет полезно просмотреть файлы LinuxTask.java, linuxTask.h и linuxTask.c в источниках Maxine, доступных по адресу kenai.com/projects/maxine/sources/maxine/show

5
ответ дан 5 December 2019 в 19:02
поделиться
Другие вопросы по тегам:

Похожие вопросы: