John Rice
2007-Sep-01 01:33 UTC
[dtrace-discuss] Smart pointers causing name mangling problems with wrapped USDT probes in Mozilla
Hi,
We are just in the middle of writing USDT probes for mozilla to allow us
to trace URI loads and Image loads.
If you just put in a custom probe in a C++ func the function name for
the probe will come out as the mangled C++ func name. To get around this
we put the probes into extern "C" wrapper funcs which we then put in
the
code. So far so good.
What we saw though was when we put the wrapper funcs in sometimes we
still got a probe with the mangled func name and the one we wanted with
the simple wrapper func name:
bash-3.00$ dtrace -ln "moz*:::"
ID PROVIDER MODULE FUNCTION NAME
5795 mozilla9865 libxul.so
__1cJimgLoaderJLoadImage6MpnGnsIURI_22pnMnsILoadGroup_pnTimgIDecoderObserver_pnLnsISupports_I8pnLimgIRequest_p9B_I_
load-image-start
5796 mozilla9865 libxul.so mozdtrace_load_image_start
load-image-start
Tracking this down we found that if we put the wrapper in the C++ func
after the declaration of a C++ smart pointer we had no problem. If we
put it before we saw the above behavior. Looking at the preprocessor
output in both instances they look the same, apart from being moved
above or after the smart pointer.
Anyone any ideas? Is this a problem with dtrace -G ?
JR
mozilla/modules/libpr0n/src/
imgLoader.h
------------------
extern "C" {
void mozdtrace_load_image_start(imgIRequest *aRequest, nsIURI *aURI);
}
#define TRACE_MOZILLA_LOAD_IMAGE_START_POINT(aRequest_, aURI_) \
mozdtrace_load_image_start((aRequest_), (aURI_))
imgLoader.cpp
--------------------
Problem:
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, ...){
:
TRACE_MOZILLA_LOAD_IMAGE_START_POINT(aRequest, aURI);
nsCOMPtr<nsICacheEntryDescriptor> entry;
:
}
No Problem:
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, ...){
:
nsCOMPtr<nsICacheEntryDescriptor> entry;
TRACE_MOZILLA_LOAD_IMAGE_START_POINT((aRequest, aURI);
:
}
imgLoader.cpp
--------------------
void mozdtrace_load_image_start(imgIRequest *aRequest, nsIURI *aURI)
{
if (MOZILLA_LOAD_IMAGE_START_ENABLED()) {
nsCAutoString spec;
aURI->GetAsciiSpec(spec);
MOZILLA_LOAD_IMAGE_START((int *) aRequest, (char *)spec.get());
}
}
mozilla-trace.h
---------------------
:
#ifdef INCLUDE_MOZILLA_DTRACE
:
#define MOZILLA_LOAD_IMAGE_START(arg0, arg1) \
__dtrace_mozilla___load__image__start(arg0, arg1)
#define MOZILLA_LOAD_IMAGE_START_ENABLED() \
__dtraceenabled_mozilla___load__image__start()
:
extern void __dtrace_mozilla___load__image__start(int *, char *);
extern int __dtraceenabled_mozilla___load__image__start(void);
:
mozilla-trace.d
-------------------
provider mozilla {
:
probe load__image__start(int *, char *);
probe load__image__done(int *, char *);
};