R0 CREW

R2 + threads + breakpoints problem

Hello all

I have a small trouble, I working a lot with linux binaries, and last time found what they have a lot of threads. But can’t set the breakpoits in common places like recv, or write, etc
in sym.imp I can’t see it, the same if I just place “db printf”

small poc C code
Compilled with “gcc -o test test.c -lpthread”

Hide

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>

void test_thread(void)
{
printf(“testing…\n”);
sleep(5);
}

int main()
{
pthread_t p_thread;

if(pthread_create(&p_thread, NULL, test_thread, NULL))
exit(EXIT_FAILURE);

if(pthread_join(p_thread, NULL))
exit(EXIT_FAILURE);

exit(EXIT_SUCCESS);
}

In gdb I can catch bp in printf, but with r2 can’t.

Any help how to deal with it?

Best regards

Copypaste from telegram chat (xvilka):

r2 is a lowlevel debugger, so it stops on the ‘start’, not the ‘main’. But adding ‘future’ breakpoints is nearly completed.

You may try:

  1. To set a breakpoint on a ‘print’ function, keep in mind the special naming scheme in the radare2. In our case ‘printf’ is just ‘sym.imp.printf’ (may be without ‘aa’), I hope it is easy to figure out the rest.
  2. change entrypoint (‘Setting breakpoint on the entrypoint = main’): ‘e dbg.bep’

The problem is what printf is not in sym.imp, only sleep, from that code, what I tried to do is:

db printf
db sym.imp.printf

Tried search something related, but no luck, no way :frowning:

PS i can put bp in sleep, after printf, but is not interesting for me