[ktap] Re: [PATCH 2/2] uprobes: fix calling of write_uprobe_event() with NO_LIBELF

  • From: Jovi Zhangwei <jovi.zhangwei@xxxxxxxxx>
  • To: ktap <ktap@xxxxxxxxxxxxx>
  • Date: Sun, 17 Nov 2013 21:08:48 +0800

Hi Azat,

On Sun, Nov 17, 2013 at 5:16 AM, Azat Khuzhin <a3at.mail@xxxxxxxxx> wrote:
> After 21bbbbf6c7a3f94583b0660b5db33870b6d1232e ("Support uprobe/sdt
> symbol glob match completely") write_uprobe_event() accept symbol name,
> so we need to give it.
> While we don't have libelf, just pass address in hex as string.
>
> Signed-off-by: Azat Khuzhin <a3at.mail@xxxxxxxxx>
> ---
>  userspace/eventdef.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/userspace/eventdef.c b/userspace/eventdef.c
> index ebb1679..04add30 100644
> --- a/userspace/eventdef.c
> +++ b/userspace/eventdef.c
> @@ -417,11 +417,14 @@ static int parse_events_resolve_symbol(int fd, char 
> *event, int type)
>          * We already have address, no need in resolving.
>          */
>         if (symbol_address) {
> +               char symbol[128] = {0};
>                 int ret;
>
>                 binary = strndup(event, colon - event);
> +               sprintf(symbol, "%lx", symbol_address);
> +
>                 ret = write_uprobe_event(fd, !!strstr(event, "%return"), 
> binary,
> -                                        symbol_address);
> +                                        symbol, symbol_address);
>                 free(binary);
>                 return ret;
>         }

I already take similar patch from Yicheng, both of you found this bug
almost at same time. :)

I changed the patch a little, I put the "NULL" string into
uprobe_events debugfs file,
not hex string, because there already have file offset in each line tail.

when symbol "setjmp" given, the line should be like:

p:uprobes/kp0_setjmp /lib64/libc.so.6:0x0000000000035801

when no symbol given, just raw address, it looks like:

p:uprobes/kp0_NULL /lib64/libc.so.6:0x0000000000035801

This tells user directly IMO.

Thanks for you good catching.

Jovi

Other related posts: