Re: [PATCH v9 0/4] Uprobes: Support SDT markers having reference count (semaphore)
From: Ravi Bangoria
Date: Tue Aug 21 2018 - 07:58:46 EST
On 08/21/2018 01:04 PM, Naveen N. Rao wrote:
> Song Liu wrote:
>> I am testing the patch set with the following code:
>>
>> #include <stdio.h>
>> #include <unistd.h>
>>
>> volatile short semaphore = 0;
>>
>> int for_uprobe(int c)
>> {
>> ÂÂÂÂÂÂÂ printf("%d\n", c + 10);
>> ÂÂÂÂÂÂÂ return c + 1;
>> }
>>
>> int main(int argc, char *argv[])
>> {
>> ÂÂÂÂÂÂÂ for_uprobe(argc);
>> ÂÂÂÂÂÂÂ while (1) {
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ sleep(1);
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ printf("semaphore %d\n", semaphore);
>> ÂÂÂÂÂÂÂ }
>> }
>>
>> I created a uprobe on function for_uprobe(), that uses semaphore as
>> reference counter:
>>
>> Â echo "p:uprobe_1 /root/a.out:0x49a(0x1036)" >> uprobe_events
>
> Is that even valid? That _looks_ like a semaphore, but I'm not quite sure that it qualifies as an _SDT_ semaphore. Do you see this issue if you instead use the macros provided by <sys/sdt.h> to create SDT markers?
>
Right. By default SDT reference counters(semaphore) goes into .probes
section:
[25] .probes PROGBITS 000000000060102c 00102c 000004 00 WA 0 0 2
which has PROGBITS set. So this works fine. And there are many other
things which are coded into <sys/sdt.h>. So the official way to use
SDT markers should be through that.
Ravi