public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable
@ 2015-04-16  5:15 Mayuresh Kulkarni
  2015-04-16  5:23 ` Mayuresh Kulkarni
  0 siblings, 1 reply; 6+ messages in thread
From: Mayuresh Kulkarni @ 2015-04-16  5:15 UTC (permalink / raw)
  To: 'systemtap@sourceware.org'

Hello,

I had a userspace probe (details below) and this worked fine with stap 1.6 and gcc 4.6.  After upgrading to gcc 4.8, this has stopped working. (I believe this to be the only change, everything else on the box is the same)

stap –L detects the probe as follows:

$  stap -L 'process("/tmp/app").provider(“foo”).mark("*")'
process("/tmp/app").provider(“foo”).mark("bar")


But, stap –g –vvvvv with the following probe fails with failure to find foo_bar_semaphore

probe process("/tmp/app").provider("foo").mark("bar")
{…}

dwarf_builder::build for /tmp/app
pattern '/tmp/app' matches module '/tmp/app'
focused on module '/tmp/app' = [0x0x400000, -0x0x6bc09d8, bias 0x0 file /tmp/app ELF machine |x86_64 (code 62)
focused on module '/tmp/app'
TOK_MARK: ipsendv TOK_PROVIDER: foo
pattern 'bar' matches function 'bar'
pattern 'foo' matches function 'foo'
saw .note.stapsdt ipsendv (provider foo)  @0xf515bb
matched probe_name bar probe type uprobe3 at 0xf515bb
probe_type == uprobe3, use statement addr: 0xf515bb
pattern '/tmp/tcp_app' matches module '/tmp/app'
focused on module '/tmp/app' = [0x0x400000, -0x0x6bc09d8, bias 0x0 file /tmp/app ELF machine |x86_64 (code 62)
focused on module '/tmp/app'
query_addr 0xf515bb
looking for semaphore symbol foo_bar_semaphore , not found
looking for semaphore symbol foo_bar , not found
semantic error: no match while resolving probe point process("/tmp/app").provider("foo").mark("bar")
deleting module_cache
Pass 2: analyzed script: 1 probe(s), 10 function(s), 1 embed(s), 0 global(s) using 345860virt/73640res/19472shr kb, in 550usr/20sys/567real ms.
Pass 2: analysis failed.  Try again with another '--vp 01' option.


Any help in resolving the above is greatly appreciated.

Thanks,
Mayuresh

This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. Any unauthorized use, dissemination or copying of this transmission or the information in it is prohibited and may be unlawful. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies (digital or paper). Unless expressly stated in this e-mail, nothing in this message should be construed as a digital or electronic signature. For additional important disclaimers and disclosures regarding KCG’s products and services, please click on the following link:

http://www.kcg.com/legal/global-disclosures

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable
  2015-04-16  5:15 userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable Mayuresh Kulkarni
@ 2015-04-16  5:23 ` Mayuresh Kulkarni
  2015-04-16 14:29   ` Frank Ch. Eigler
  0 siblings, 1 reply; 6+ messages in thread
From: Mayuresh Kulkarni @ 2015-04-16  5:23 UTC (permalink / raw)
  To: 'systemtap@sourceware.org'

Sorry, please ignore the earlier email which had some incomplete information.  Here is the correct version:

Hello,

I had a userspace probe (details below) and this worked fine with stap 1.6 and gcc 4.6.  After upgrading to gcc 4.8, this has stopped working. (I believe this to be the only change, everything else on the box is the same)

stap –L detects the probe as follows:

$  stap -L 'process("/tmp/app").provider(“foo”).mark("*")'
process("/tmp/app").provider(“foo”).mark("bar")


But, stap –g –vvvvv with the following probe fails with failure to find foo_bar_semaphore

probe process("/tmp/app").provider("foo").mark("bar")
{…}

dwarf_builder::build for /tmp/app
pattern '/tmp/app' matches module '/tmp/app'
focused on module '/tmp/app' = [0x0x400000, -0x0x6bc09d8, bias 0x0 file /tmp/app ELF machine |x86_64 (code 62) focused on module '/tmp/app'
TOK_MARK: bar TOK_PROVIDER: foo
pattern 'bar' matches function 'bar'
pattern 'foo' matches function 'foo'
saw .note.stapsdt bar (provider foo)  @0xf515bb matched probe_name bar probe type uprobe3 at 0xf515bb probe_type == uprobe3, use statement addr: 0xf515bb pattern '/tmp/app' matches module '/tmp/app'
focused on module '/tmp/app' = [0x0x400000, -0x0x6bc09d8, bias 0x0 file /tmp/app ELF machine |x86_64 (code 62) focused on module '/tmp/app'
query_addr 0xf515bb
looking for semaphore symbol foo_bar_semaphore , not found looking for semaphore symbol foo_bar , not found semantic error: no match while resolving probe point process("/tmp/app").provider("foo").mark("bar")
deleting module_cache
Pass 2: analyzed script: 1 probe(s), 10 function(s), 1 embed(s), 0 global(s) using 345860virt/73640res/19472shr kb, in 550usr/20sys/567real ms.
Pass 2: analysis failed.  Try again with another '--vp 01' option.


Any help in resolving the above is greatly appreciated.

Thanks,
Mayuresh

This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. Any unauthorized use, dissemination or copying of this transmission or the information in it is prohibited and may be unlawful. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies (digital or paper). Unless expressly stated in this e-mail, nothing in this message should be construed as a digital or electronic signature. For additional important disclaimers and disclosures regarding KCG’s products and services, please click on the following link:

http://www.kcg.com/legal/global-disclosures

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable
  2015-04-16  5:23 ` Mayuresh Kulkarni
@ 2015-04-16 14:29   ` Frank Ch. Eigler
  2015-04-18 14:14     ` Mayuresh Kulkarni
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Ch. Eigler @ 2015-04-16 14:29 UTC (permalink / raw)
  To: Mayuresh Kulkarni; +Cc: 'systemtap@sourceware.org'

Mayuresh Kulkarni <mkulkarni@kcg.com> writes:

> [...]
> I had a userspace probe (details below) and this worked fine with stap 1.6 and gcc 4.6.  After upgrading to gcc 4.8, this has stopped working. (I believe this to be the only change, everything else on the box is the same)
> [...]
> But, stap -g -vvvvv with the following probe fails with failure to find foo_bar_semaphore

If you use relatively recent <sys/sdt.h> with semaphores (i.e., your C
program #defines _SDT_HAS_SEMAPHORES), you also need to run
"/usr/bin/dtrace -G ..." to create an object file that contains that
semaphore.  That .o needs to be linked into your executable.

- FChE

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable
  2015-04-16 14:29   ` Frank Ch. Eigler
@ 2015-04-18 14:14     ` Mayuresh Kulkarni
  2015-04-20 20:06       ` Frank Ch. Eigler
  0 siblings, 1 reply; 6+ messages in thread
From: Mayuresh Kulkarni @ 2015-04-18 14:14 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: 'systemtap@sourceware.org'


>> [...]
>> I had a userspace probe (details below) and this worked fine with stap
>> 1.6 and gcc 4.6.  After upgrading to gcc 4.8, this has stopped
>> working. (I believe this to be the only change, everything else on the
>> box is the same) [...] But, stap -g -vvvvv with the following probe
>> fails with failure to find foo_bar_semaphore

> If you use relatively recent <sys/sdt.h> with semaphores (i.e., your C program #defines _SDT_HAS_SEMAPHORES), you also need to run "/usr/bin/dtrace -G ..." to create an object file
> that contains that semaphore.  That .o needs to be linked into your executable.

> -FChe

Thanks for the reply. I will keep it in mind when we update to 2.7.

Meanwhile, in my setup, I have found out that the runtime box has native gcc 4.4 And the regression is because the build uses gcc 4.8 (which uses dwarf4 by default ) while till gcc 4.6, dwarf2 was the default.  So the combination of [ build with 4.6, run on box with 4.4 ] used to work but does not work if built with 4.8. If I explicitly build the binary with -g -gdwarf-2 , then things are fine.

Unfortunately, I cannot muck with the build settings. Might there be  a way of telling systemtap at runtime that the binary being probed uses dwarf4?

Thanks,
Mayuresh
This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. Any unauthorized use, dissemination or copying of this transmission or the information in it is prohibited and may be unlawful. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies (digital or paper). Unless expressly stated in this e-mail, nothing in this message should be construed as a digital or electronic signature. For additional important disclaimers and disclosures regarding KCG’s products and services, please click on the following link:

http://www.kcg.com/legal/global-disclosures

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable
  2015-04-18 14:14     ` Mayuresh Kulkarni
@ 2015-04-20 20:06       ` Frank Ch. Eigler
  2015-04-22 20:23         ` Mayuresh Kulkarni
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Ch. Eigler @ 2015-04-20 20:06 UTC (permalink / raw)
  To: Mayuresh Kulkarni; +Cc: 'systemtap@sourceware.org'


mkulkarni wrote:
>
 [...]
> Meanwhile, in my setup, I have found out that the runtime box has
> native gcc 4.4 And the regression is because the build uses gcc 4.8
> (which uses dwarf4 by default)

Why do you think so?  stap works fine here on that version of gcc, and
older, and newer.  Can you forward your full gcc/stap/elfutils/kernel
versions, and perhaps a binary (compiled with your gcc 4.8) that was
giving stap a hard time?


- FChE

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable
  2015-04-20 20:06       ` Frank Ch. Eigler
@ 2015-04-22 20:23         ` Mayuresh Kulkarni
  0 siblings, 0 replies; 6+ messages in thread
From: Mayuresh Kulkarni @ 2015-04-22 20:23 UTC (permalink / raw)
  To: 'Frank Ch. Eigler'; +Cc: 'systemtap@sourceware.org'

[-- Attachment #1: Type: text/plain, Size: 4058 bytes --]

Here is a program that fails for me. (With details about building, machine etc).  To elaborate from my last email, it is seemingly the attempt to access a local variable in the probe that fails. Does the following work for you?

Many thanks,
Mayuresh


#include <sdt.h>
#include <unistd.h>

void foo()
{
    volatile int f = 100;
    STAP_PROBE(Prod,foo);
}


int main()
{
    while(true)
    {
        sleep(1);
        foo();
    }
}

################################################
1) Building:
################################################
$ g++ --version | head -1 #gcc used by build
g++ (GCC) 4.8.2

$ /usr/bin/g++ --version | head -1   #native gcc
g++ (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)

$ rpm -qa | grep elfutils
elfutils-devel-0.152-1.el6.x86_64
elfutils-libs-0.152-1.el6.x86_64
elfutils-libelf-devel-0.152-1.el6.x86_64
elfutils-libelf-0.152-1.el6.x86_64
elfutils-0.152-1.el6.x86_64

$ uname -r
2.6.32-220.7.1.el6.x86_64

systemtap is not installed on build box. Only sdt.h and std-config.h from stap 1.6 (attached) are available on build box

$ g++ -O3 -g foo.cpp   -o /tmp/foo  //May need a -I to point to sdt.h

If I build with g++ -O3 -g -gdwarf-2, the probe works fine

#####################################################
2) Executing and probing on different box with same kernel and native gcc 4.6 (gcc 4.8 not installed on runtime box)
######################################################
$  /tmp/foo&
[1] 8213
$ sudo stap -g -e 'probe process("/tmp/foo").provider("Prod").mark("foo") { printf("f : %d\n",$f); }' -x 8213
semantic error: no match while resolving probe point process("/tmp/foo").provider("Prod").mark("foo")
Pass 2: analysis failed.  Try again with another '--vp 01' option.

$  gcc --version | head -1
gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)

$ stap --version
Systemtap translator/driver (version 1.6/0.152 non-git sources)
Copyright (C) 2005-2011 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
enabled features: AVAHI LIBRPM LIBSQLITE3 NSS BOOST_SHARED_PTR TR1_UNORDERED_MAP NLS

$ rpm -qa | grep systemtap
systemtap-runtime-1.6-5.el6_2.x86_64
systemtap-initscript-1.6-5.el6_2.x86_64
systemtap-1.6-5.el6_2.x86_64

$ rpm -qa | grep elfutils
elfutils-libelf-0.152-1.el6.x86_64
elfutils-libs-0.152-1.el6.x86_64
elfutils-0.152-1.el6.x86_64

$ uname -r
2.6.32-220.7.1.el6.x86_64









-----Original Message-----
From: Frank Ch. Eigler [mailto:fche@redhat.com]
Sent: Monday, April 20, 2015 3:07 PM
To: Mayuresh Kulkarni
Cc: 'systemtap@sourceware.org'
Subject: Re: userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable


mkulkarni wrote:
>
 [...]
> Meanwhile, in my setup, I have found out that the runtime box has
> native gcc 4.4 And the regression is because the build uses gcc 4.8
> (which uses dwarf4 by default)

Why do you think so?  stap works fine here on that version of gcc, and older, and newer.  Can you forward your full gcc/stap/elfutils/kernel versions, and perhaps a binary (compiled with your gcc 4.8) that was giving stap a hard time?


- FChE
This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. Any unauthorized use, dissemination or copying of this transmission or the information in it is prohibited and may be unlawful. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies (digital or paper). Unless expressly stated in this e-mail, nothing in this message should be construed as a digital or electronic signature. For additional important disclaimers and disclosures regarding KCG’s products and services, please click on the following link:

http://www.kcg.com/legal/global-disclosures

[-- Attachment #2: sdt.h --]
[-- Type: text/plain, Size: 15921 bytes --]

/* <sys/sdt.h> - Systemtap static probe definition macros.
   Copyright (C) 2010-2011 Red Hat Inc.

   This file is part of systemtap, and is free software in the public domain.
*/

#ifndef _SYS_SDT_H
#define _SYS_SDT_H    1

#ifdef __ASSEMBLER__
# define _SDT_PROBE(provider, name, n, arglist)	\
  _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING_1, (_SDT_DEPAREN_##n arglist)) \
  _SDT_ASM_BASE
# define _SDT_ASM_1(x)			x;
# define _SDT_ASM_2(a, b)		a,b;
# define _SDT_ASM_3(a, b, c)		a,b,c;
# define _SDT_ASM_5(a, b, c, d, e)	a,b,c,d,e;
# define _SDT_ASM_STRING_1(x)		.asciz #x;
# define _SDT_DEPAREN_0()			/* empty */
# define _SDT_DEPAREN_1(a)			a
# define _SDT_DEPAREN_2(a,b)			a b
# define _SDT_DEPAREN_3(a,b,c)			a b c
# define _SDT_DEPAREN_4(a,b,c,d)		a b c d
# define _SDT_DEPAREN_5(a,b,c,d,e)		a b c d e
# define _SDT_DEPAREN_6(a,b,c,d,e,f)		a b c d e f
# define _SDT_DEPAREN_7(a,b,c,d,e,f,g)		a b c d e f g
# define _SDT_DEPAREN_8(a,b,c,d,e,f,g,h)	a b c d e f g h
# define _SDT_DEPAREN_9(a,b,c,d,e,f,g,h,i)	a b c d e f g h i
# define _SDT_DEPAREN_10(a,b,c,d,e,f,g,h,i,j)	a b c d e f g h i j
#else
# include <stdint.h>
# define _SDT_PROBE(provider, name, n, arglist) \
  do {									    \
    __asm__ __volatile__ (_SDT_ASM_BODY(provider, name, _SDT_ASM_ARGS, (n)) \
			  :: _SDT_ASM_OPERANDS_##n arglist);		    \
    __asm__ __volatile__ (_SDT_ASM_BASE);				    \
  } while (0)
# define _SDT_S(x)			#x
# define _SDT_ASM_1(x)			_SDT_S(x) "\n"
# define _SDT_ASM_2(a, b)		_SDT_S(a) "," _SDT_S(b) "\n"
# define _SDT_ASM_3(a, b, c)		_SDT_S(a )"," _SDT_S(b) "," _SDT_S(c) "\n"
# define _SDT_ASM_5(a, b, c, d, e)	_SDT_S(a) "," _SDT_S(b) "," _SDT_S(c) ","\
					_SDT_S(d) "," _SDT_S(e) "\n"
# define _SDT_ASM_ARGS(n)		_SDT_ASM_STRING(_SDT_ASM_TEMPLATE_##n)
# define _SDT_ASM_STRING_1(x)		_SDT_ASM_1(.asciz #x)

# define _SDT_ARGFMT(no)		%n[_SDT_S##no]@_SDT_ARGTMPL(_SDT_A##no)
# ifndef STAP_SDT_ARG_CONSTRAINT
# define STAP_SDT_ARG_CONSTRAINT        nor
# endif
# define _SDT_STRINGIFY(x)              #x
# define _SDT_ARG_CONSTRAINT_STRING(x)  _SDT_STRINGIFY(x)
# define _SDT_ARG(n, x)			\
  [_SDT_S##n] "n" ((_SDT_ARGSIGNED (x) ? 1 : -1) * (int) _SDT_ARGSIZE (x)), \
  [_SDT_A##n] _SDT_ARG_CONSTRAINT_STRING (STAP_SDT_ARG_CONSTRAINT) (_SDT_ARGVAL (x))
#endif
#define _SDT_ASM_STRING(x)		_SDT_ASM_STRING_1(x)

#define _SDT_ARGARRAY(x)	(__builtin_classify_type (x) == 14	\
				 || __builtin_classify_type (x) == 5)

#ifdef __cplusplus
# define _SDT_ARGSIGNED(x)	(!_SDT_ARGARRAY (x) \
				 && __sdt_type<__typeof (x)>::__sdt_signed)
# define _SDT_ARGSIZE(x)	(_SDT_ARGARRAY (x) \
				 ? sizeof (void *) : sizeof (x))
# define _SDT_ARGVAL(x)		(x)

# include <cstddef>

template<typename __sdt_T>
struct __sdt_type
{
  static const bool __sdt_signed = false;
};
  
#define __SDT_ALWAYS_SIGNED(T) \
template<> struct __sdt_type<T> { static const bool __sdt_signed = true; };
#define __SDT_COND_SIGNED(T) \
template<> struct __sdt_type<T> { static const bool __sdt_signed = ((T)(-1) < 1); };
__SDT_ALWAYS_SIGNED(signed char)
__SDT_ALWAYS_SIGNED(short)
__SDT_ALWAYS_SIGNED(int)
__SDT_ALWAYS_SIGNED(long)
__SDT_ALWAYS_SIGNED(long long)
__SDT_ALWAYS_SIGNED(volatile signed char)
__SDT_ALWAYS_SIGNED(volatile short)
__SDT_ALWAYS_SIGNED(volatile int)
__SDT_ALWAYS_SIGNED(volatile long)
__SDT_ALWAYS_SIGNED(volatile long long)
__SDT_ALWAYS_SIGNED(const signed char)
__SDT_ALWAYS_SIGNED(const short)
__SDT_ALWAYS_SIGNED(const int)
__SDT_ALWAYS_SIGNED(const long)
__SDT_ALWAYS_SIGNED(const long long)
__SDT_ALWAYS_SIGNED(const volatile signed char)
__SDT_ALWAYS_SIGNED(const volatile short)
__SDT_ALWAYS_SIGNED(const volatile int)
__SDT_ALWAYS_SIGNED(const volatile long)
__SDT_ALWAYS_SIGNED(const volatile long long)
__SDT_COND_SIGNED(char)
__SDT_COND_SIGNED(wchar_t)
__SDT_COND_SIGNED(volatile char)
__SDT_COND_SIGNED(volatile wchar_t)
__SDT_COND_SIGNED(const char)
__SDT_COND_SIGNED(const wchar_t)
__SDT_COND_SIGNED(const volatile char)
__SDT_COND_SIGNED(const volatile wchar_t)
#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
/* __SDT_COND_SIGNED(char16_t) */
/* __SDT_COND_SIGNED(char32_t) */
#endif

template<typename __sdt_E>
struct __sdt_type<__sdt_E[]> : public __sdt_type<__sdt_E *> {};

template<typename __sdt_E, size_t __sdt_N>
struct __sdt_type<__sdt_E[__sdt_N]> : public __sdt_type<__sdt_E *> {};

#elif !defined(__ASSEMBLER__)
__extension__ extern unsigned long long __sdt_unsp;
# define _SDT_ARGINTTYPE(x)						\
  __typeof (__builtin_choose_expr (((__builtin_classify_type (x)	\
				     + 3) & -4) == 4, (x), 0U))
# define _SDT_ARGSIGNED(x)						\
  (!__extension__							\
   (__builtin_constant_p ((((unsigned long long)			\
			    (_SDT_ARGINTTYPE (x)) __sdt_unsp)		\
			   & (1ULL << (sizeof (unsigned long long)	\
				       * __CHAR_BIT__ - 1))) == 0)	\
    || (_SDT_ARGINTTYPE (x)) -1 > (_SDT_ARGINTTYPE (x)) 0))
# define _SDT_ARGSIZE(x)	\
  (_SDT_ARGARRAY (x) ? sizeof (void *) : sizeof (x))
# define _SDT_ARGVAL(x)		(x)
#endif

#if defined __powerpc__ || defined __powerpc64__
# define _SDT_ARGTMPL(id)	%I[id]%[id]
#else
# define _SDT_ARGTMPL(id)	%[id]
#endif

#ifdef __LP64__
# define _SDT_ASM_ADDR	.8byte
#else
# define _SDT_ASM_ADDR	.4byte
#endif

/* The ia64 and s390 nop instructions take an argument. */
#if defined(__ia64__) || defined(__s390__) || defined(__s390x__)
#define _SDT_NOP	nop 0
#else
#define _SDT_NOP	nop
#endif

#define _SDT_NOTE_NAME	"stapsdt"
#define _SDT_NOTE_TYPE	3

/* If the assembler supports the necessary feature, then we can play
   nice with code in COMDAT sections, which comes up in C++ code.
   Without that assembler support, some combinations of probe placements
   in certain kinds of C++ code may produce link-time errors.  */
#include "sdt-config.h"
#if _SDT_ASM_SECTION_AUTOGROUP_SUPPORT
# define _SDT_ASM_AUTOGROUP "?"
#else
# define _SDT_ASM_AUTOGROUP ""
#endif

#define _SDT_ASM_BODY(provider, name, pack_args, args)			      \
  _SDT_ASM_1(990:	_SDT_NOP)					      \
  _SDT_ASM_3(		.pushsection .note.stapsdt,_SDT_ASM_AUTOGROUP,"note") \
  _SDT_ASM_1(		.balign 4)					      \
  _SDT_ASM_3(		.4byte 992f-991f, 994f-993f, _SDT_NOTE_TYPE)	      \
  _SDT_ASM_1(991:	.asciz _SDT_NOTE_NAME)				      \
  _SDT_ASM_1(992:	.balign 4)					      \
  _SDT_ASM_1(993:	_SDT_ASM_ADDR 990b)				      \
  _SDT_ASM_1(		_SDT_ASM_ADDR _.stapsdt.base)			      \
  _SDT_SEMAPHORE(provider,name)						      \
  _SDT_ASM_STRING(provider)						      \
  _SDT_ASM_STRING(name)							      \
  pack_args args							      \
  _SDT_ASM_1(994:	.balign 4)					      \
  _SDT_ASM_1(		.popsection)

#define _SDT_ASM_BASE							      \
  _SDT_ASM_1(.ifndef _.stapsdt.base)					      \
  _SDT_ASM_5(		.pushsection .stapsdt.base,"aG","progbits",	      \
							.stapsdt.base,comdat) \
  _SDT_ASM_1(		.weak _.stapsdt.base)				      \
  _SDT_ASM_1(		.hidden _.stapsdt.base)				      \
  _SDT_ASM_1(	_.stapsdt.base: .space 1)				      \
  _SDT_ASM_2(		.size _.stapsdt.base, 1)			      \
  _SDT_ASM_1(		.popsection)					      \
  _SDT_ASM_1(.endif)

#if defined _SDT_HAS_SEMAPHORES
#define _SDT_SEMAPHORE(p,n) _SDT_ASM_1(		_SDT_ASM_ADDR p##_##n##_semaphore)
#else
#define _SDT_SEMAPHORE(p,n) _SDT_ASM_1(		_SDT_ASM_ADDR 0)
#endif

#define _SDT_ASM_TEMPLATE_0		/* no arguments */
#define _SDT_ASM_TEMPLATE_1		_SDT_ARGFMT(1)
#define _SDT_ASM_TEMPLATE_2		_SDT_ASM_TEMPLATE_1 _SDT_ARGFMT(2)
#define _SDT_ASM_TEMPLATE_3		_SDT_ASM_TEMPLATE_2 _SDT_ARGFMT(3)
#define _SDT_ASM_TEMPLATE_4		_SDT_ASM_TEMPLATE_3 _SDT_ARGFMT(4)
#define _SDT_ASM_TEMPLATE_5		_SDT_ASM_TEMPLATE_4 _SDT_ARGFMT(5)
#define _SDT_ASM_TEMPLATE_6		_SDT_ASM_TEMPLATE_5 _SDT_ARGFMT(6)
#define _SDT_ASM_TEMPLATE_7		_SDT_ASM_TEMPLATE_6 _SDT_ARGFMT(7)
#define _SDT_ASM_TEMPLATE_8		_SDT_ASM_TEMPLATE_7 _SDT_ARGFMT(8)
#define _SDT_ASM_TEMPLATE_9		_SDT_ASM_TEMPLATE_8 _SDT_ARGFMT(9)
#define _SDT_ASM_TEMPLATE_10		_SDT_ASM_TEMPLATE_9 _SDT_ARGFMT(10)
#define _SDT_ASM_OPERANDS_0()		[__sdt_dummy] "g" (0)
#define _SDT_ASM_OPERANDS_1(arg1)	_SDT_ARG(1, arg1)
#define _SDT_ASM_OPERANDS_2(arg1, arg2) \
  _SDT_ASM_OPERANDS_1(arg1), _SDT_ARG(2, arg2)
#define _SDT_ASM_OPERANDS_3(arg1, arg2, arg3) \
  _SDT_ASM_OPERANDS_2(arg1, arg2), _SDT_ARG(3, arg3)
#define _SDT_ASM_OPERANDS_4(arg1, arg2, arg3, arg4) \
  _SDT_ASM_OPERANDS_3(arg1, arg2, arg3), _SDT_ARG(4, arg4)
#define _SDT_ASM_OPERANDS_5(arg1, arg2, arg3, arg4, arg5) \
  _SDT_ASM_OPERANDS_4(arg1, arg2, arg3, arg4), _SDT_ARG(5, arg5)
#define _SDT_ASM_OPERANDS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
  _SDT_ASM_OPERANDS_5(arg1, arg2, arg3, arg4, arg5), _SDT_ARG(6, arg6)
#define _SDT_ASM_OPERANDS_7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
  _SDT_ASM_OPERANDS_6(arg1, arg2, arg3, arg4, arg5, arg6), _SDT_ARG(7, arg7)
#define _SDT_ASM_OPERANDS_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
  _SDT_ASM_OPERANDS_7(arg1, arg2, arg3, arg4, arg5, arg6, arg7), \
    _SDT_ARG(8, arg8)
#define _SDT_ASM_OPERANDS_9(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) \
  _SDT_ASM_OPERANDS_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8), \
    _SDT_ARG(9, arg9)
#define _SDT_ASM_OPERANDS_10(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) \
  _SDT_ASM_OPERANDS_9(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9), \
    _SDT_ARG(10, arg10)

/* These macros can be used in C, C++, or assembly code.
   In assembly code the arguments should use normal assembly operand syntax.  */

#define STAP_PROBE(provider, name) \
  _SDT_PROBE(provider, name, 0, ())
#define STAP_PROBE1(provider, name, arg1) \
  _SDT_PROBE(provider, name, 1, (arg1))
#define STAP_PROBE2(provider, name, arg1, arg2) \
  _SDT_PROBE(provider, name, 2, (arg1, arg2))
#define STAP_PROBE3(provider, name, arg1, arg2, arg3) \
  _SDT_PROBE(provider, name, 3, (arg1, arg2, arg3))
#define STAP_PROBE4(provider, name, arg1, arg2, arg3, arg4) \
  _SDT_PROBE(provider, name, 4, (arg1, arg2, arg3, arg4))
#define STAP_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) \
  _SDT_PROBE(provider, name, 5, (arg1, arg2, arg3, arg4, arg5))
#define STAP_PROBE6(provider, name, arg1, arg2, arg3, arg4, arg5, arg6)	\
  _SDT_PROBE(provider, name, 6, (arg1, arg2, arg3, arg4, arg5, arg6))
#define STAP_PROBE7(provider, name, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
  _SDT_PROBE(provider, name, 7, (arg1, arg2, arg3, arg4, arg5, arg6, arg7))
#define STAP_PROBE8(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) \
  _SDT_PROBE(provider, name, 8, (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8))
#define STAP_PROBE9(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
  _SDT_PROBE(provider, name, 9, (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9))
#define STAP_PROBE10(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) \
  _SDT_PROBE(provider, name, 10, \
	     (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10))

/* This STAP_PROBEV macro can be used in variadic scenarios, where the
   number of probe arguments is not known until compile time.  Since
   variadic macro support may vary with compiler options, you must
   pre-#define SDT_USE_VARIADIC to enable this type of probe.

   The trick to count __VA_ARGS__ was inspired by this post by
   Laurent Deniau <laurent.deniau@cern.ch>:
       http://groups.google.com/group/comp.std.c/msg/346fc464319b1ee5

   Note that our _SDT_NARG is called with an extra 0 arg that's not
   counted, so we don't have to worry about the behavior of macros
   called without any arguments.  */

#ifdef SDT_USE_VARIADIC
#define _SDT_NARG(...) __SDT_NARG(__VA_ARGS__, 10,9,8,7,6,5,4,3,2,1,0)
#define __SDT_NARG(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10, N, ...) N
#define _SDT_PROBE_N(provider, name, N, ...) \
  _SDT_PROBE(provider, name, N, (__VA_ARGS__))
#define STAP_PROBEV(provider, name, ...) \
  _SDT_PROBE_N(provider, name, _SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
#endif

/* These macros are for use in asm statements.  You must compile
   with -std=gnu99 or -std=c99 to use the STAP_PROBE_ASM macro.

   The STAP_PROBE_ASM macro generates a quoted string to be used in the
   template portion of the asm statement, concatenated with strings that
   contain the actual assembly code around the probe site.

   For example:

	asm ("before\n"
	     STAP_PROBE_ASM(provider, fooprobe, %eax 4(%esi))
	     "after");

   emits the assembly code for "before\nafter", with a probe in between.
   The probe arguments are the %eax register, and the value of the memory
   word located 4 bytes past the address in the %esi register.  Note that
   because this is a simple asm, not a GNU C extended asm statement, these
   % characters do not need to be doubled to generate literal %reg names.

   In a GNU C extended asm statement, the probe arguments can be specified
   using the macro STAP_PROBE_ASM_TEMPLATE(n) for n arguments.  The paired
   macro STAP_PROBE_ASM_OPERANDS gives the C values of these probe arguments,
   and appears in the input operand list of the asm statement.  For example:

	asm ("someinsn %0,%1\n" // %0 is output operand, %1 is input operand
	     STAP_PROBE_ASM(provider, fooprobe, STAP_PROBE_ASM_TEMPLATE(3))
	     "otherinsn %[namedarg]"
	     : "r" (outvar)
	     : "g" (some_value), [namedarg] "i" (1234),
	       STAP_PROBE_ASM_OPERANDS(3, some_value, some_ptr->field, 1234));

    This is just like writing:

	STAP_PROBE3(provider, fooprobe, some_value, some_ptr->field, 1234));

    but the probe site is right between "someinsn" and "otherinsn".

    The probe arguments in STAP_PROBE_ASM can be given as assembly
    operands instead, even inside a GNU C extended asm statement.
    Note that these can use operand templates like %0 or %[name],
    and likewise they must write %%reg for a literal operand of %reg.  */

#if __STDC_VERSION__ >= 199901L
# define STAP_PROBE_ASM(provider, name, ...)		\
  _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING, (__VA_ARGS__)) \
  _SDT_ASM_BASE
# define STAP_PROBE_ASM_OPERANDS(n, ...) _SDT_ASM_OPERANDS_##n(__VA_ARGS__)
#else
# define STAP_PROBE_ASM(provider, name, args)	\
  _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING, (args)) \
  _SDT_ASM_BASE
#endif
#define STAP_PROBE_ASM_TEMPLATE(n)	_SDT_ASM_TEMPLATE_##n


/* DTrace compatible macro names.  */
#define DTRACE_PROBE(provider,probe)		\
  STAP_PROBE(provider,probe)
#define DTRACE_PROBE1(provider,probe,parm1)	\
  STAP_PROBE1(provider,probe,parm1)
#define DTRACE_PROBE2(provider,probe,parm1,parm2)	\
  STAP_PROBE2(provider,probe,parm1,parm2)
#define DTRACE_PROBE3(provider,probe,parm1,parm2,parm3) \
  STAP_PROBE3(provider,probe,parm1,parm2,parm3)
#define DTRACE_PROBE4(provider,probe,parm1,parm2,parm3,parm4)	\
  STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4)
#define DTRACE_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5)	\
  STAP_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5)
#define DTRACE_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \
  STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6)
#define DTRACE_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
  STAP_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7)
#define DTRACE_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
  STAP_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8)
#define DTRACE_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
  STAP_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9)
#define DTRACE_PROBE10(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
  STAP_PROBE10(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10)


#endif /* sys/sdt.h */

[-- Attachment #3: sdt-config.h --]
[-- Type: text/plain, Size: 282 bytes --]

/* includes/sys/sdt-config.h.  Generated from sdt-config.h.in by configure.

   This file just defines _SDT_ASM_SECTION_AUTOGROUP_SUPPORT to 0 or 1 to
   indicate whether the assembler supports "?" in .pushsection directives.  */

#define _SDT_ASM_SECTION_AUTOGROUP_SUPPORT 0

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-22 20:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-16  5:15 userspace probe breakage with gcc 4.8 due to inablility to locate semaphore variable Mayuresh Kulkarni
2015-04-16  5:23 ` Mayuresh Kulkarni
2015-04-16 14:29   ` Frank Ch. Eigler
2015-04-18 14:14     ` Mayuresh Kulkarni
2015-04-20 20:06       ` Frank Ch. Eigler
2015-04-22 20:23         ` Mayuresh Kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).