Does Valgrind work with Xenomai?
Hi,
I currently have a C++ application that is using 5 RTDM drivers, 2 Xenomai real-time user-space threads and several non-real-time Linux threads.
This application seems to have a memory leak because after running for several hours the OOM-Killer kills this application.
I am looking for a memory leak detection tool to help find the leak.
Two years ago in the following mail it was mentioned that making Valgrind aware of Xenomai syscalls was on the todo list.
http://article.gmane.org/gmane.linux.real-time.xenomai.users/1805
Has this been done?
Does Valgrind work with Xenomai?
Do you have to use the Xenomai simulator with Valgrind?
Or is there a better memory debugger the works with C++, Linux, and Xenomai?
Thanks,
Rob
Quoted 15 lines · Robert McCullough
Hi,
I currently have a C++ application that is using 5 RTDM drivers, 2 Xenomai real-time user-space threads and several non-real-time Linux threads.
This application seems to have a memory leak because after running for several hours the OOM-Killer kills this application.
I am looking for a memory leak detection tool to help find the leak.
Quoted 9 lines
Two years ago in the following mail it was mentioned that making Valgrind aware of Xenomai syscalls was on the todo list.
http://article.gmane.org/gmane.linux.real-time.xenomai.users/1805
Has this been done?
No news.
Quoted 2 lines
Does Valgrind work with Xenomai?
Nope.
Quoted 2 lines
Do you have to use the Xenomai simulator with Valgrind?
This won't work in your case. The simulator is rather aimed at virtualizing a standalone environment for debugging the nucleus and skins that normally run in kernel space; it is not application-oriented - you would have lots of namespace conflicts to begin with.
Quoted 2 lines
Or is there a better memory debugger the works with C++, Linux, and Xenomai?
Sorry for the lame suggestion, but you may have to resort to old cranky tools like dmalloc, provided your new/delete operators are still backed by malloc(3). At least you should be able to identify some leakage.
Quoted 13 lines
Thanks,
Rob
------------------------------------------------------------------------
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
Quoted 26 lines · Philippe Gerum
Quoted 15 lines · Robert McCullough
Hi,
I currently have a C++ application that is using 5 RTDM drivers, 2 Xenomai real-time user-space threads and several non-real-time Linux threads.
This application seems to have a memory leak because after running for several hours the OOM-Killer kills this application.
I am looking for a memory leak detection tool to help find the leak.
Quoted 9 lines
Two years ago in the following mail it was mentioned that making Valgrind aware of Xenomai syscalls was on the todo list.
http://article.gmane.org/gmane.linux.real-time.xenomai.users/1805
Has this been done?
Quoted 6 lines
No news.
Quoted 2 lines
Does Valgrind work with Xenomai?
Nope.
Another way around, at least if you are using the posix skin, is to compile your application for Linux without Xenomai. If you are using a legacy API, you can do this with Xenomai/SOLO. If you are using the native API, then maybe you can ask gently Philippe to write a native skin for Xenomai/SOLO.
Now, about valgrind, I spent some time thinking about it. A first modification of valgrind, is to allow dynamic syscall tables, such as what Xenomai use. This should be an easy task.
The next task is to rewrite all xenomai syscalls in valgrind language (that is mainly to identify memory reads and writes), this is not a hard task, but a rather long one. So, my idea (which remains an idea for now) was to write the interface of the syscalls in IDL, and to generate automatically the code for valgrind.
Signature · 1 line
Gilles.
wLe Thu, 20 Nov 2008 14:24:30 +0100, Gilles Chanteperdrix
Quoted 45 lines · <[email protected]> a écrit:
Quoted 26 lines · Philippe Gerum
Quoted 15 lines · Robert McCullough
Hi,
I currently have a C++ application that is using 5 RTDM drivers, 2 Xenomai real-time user-space threads and several non-real-time Linux threads.
This application seems to have a memory leak because after running for several hours the OOM-Killer kills this application.
I am looking for a memory leak detection tool to help find the leak.
Quoted 9 lines
Two years ago in the following mail it was mentioned that making Valgrind aware of Xenomai syscalls was on the todo list.
http://article.gmane.org/gmane.linux.real-time.xenomai.users/1805
Has this been done?
Quoted 6 lines
No news.
Quoted 2 lines
Does Valgrind work with Xenomai?
Nope.
Another way around, at least if you are using the posix skin, is to compile your application for Linux without Xenomai. If you are using a legacy API, you can do this with Xenomai/SOLO. If you are using the native API, then maybe you can ask gently Philippe to write a native skin for Xenomai/SOLO.
Now, about valgrind, I spent some time thinking about it. A first modification of valgrind, is to allow dynamic syscall tables, such as what Xenomai use. This should be an easy task.
Quoted 6 lines
The next task is to rewrite all xenomai syscalls in valgrind language (that is mainly to identify memory reads and writes), this is not a hard task, but a rather long one. So, my idea (which remains an idea for now) was to write the interface of the syscalls in IDL, and to generate automatically the code for valgrind.
I would tell, no , it does not ... after spending time with it .
enclosed is a patch of my work against valgrind 3.3.0
Best Regards
Steph
../valgrind-3.3.0/coregrind/m_syswrap/syswrap-linux.c renamed from coregrind/m_syswrap/syswrap-linux.c +4 -0
@@ -2797,6 +2797,7 @@ } } +/* --------------------------------------------------------------------- ioprio_ wrappers ------------------------------------------------------------------ */
@@ -2822,6 +2823,9 @@PRE_MEM_READ ("utimensat(tvp)" ,ARG3 ,sizeof (struct vki_timespec ) ); } + + +#undef PRE#undef POST
../valgrind-3.3.0/coregrind/m_syswrap/syswrap-x86-linux.c renamed from coregrind/m_syswrap/syswrap-x86-linux.c +37 -2
@@ -788,6 +788,8 @@DECL_TEMPLATE (x86_linux, sys_vm86old);DECL_TEMPLATE (x86_linux, sys_vm86);DECL_TEMPLATE (x86_linux, sys_syscall223); +DECL_TEMPLATE (x86_linux, xeno_bind_skin); +DECL_TEMPLATE (x86_linux, xn_shadow_sys_info);PRE (old_select) {
@@ -1816,6 +1818,26 @@ ARG4, ARG5, ARG6 ); } +PRE (xeno_bind_skin) +{ +"skin pre" ); +} + +POST (xeno_bind_skin) +{ +"rt_skin_bind pre" ); +} +PRE (xn_shadow_sys_info) +{ +"xn_shadow_sys_info" ); +} + +POST (xn_shadow_sys_info) +{ +"xn_shadow_sys_info" ); +} + +#undef PRE#undef POST
@@ -1827,8 +1849,18 @@/* Add an x86-linux specific wrapper to a syscall table. */ #define PLAX_ (sysno, name) WRAPPER_ENTRY_X_(x86_linux, sysno, name)#define PLAXY (sysno, name) WRAPPER_ENTRY_XY(x86_linux, sysno, name) - - +/* Xenomai multiplexer syscall. */ +#define __xn_sys_mux 555/* Must fit within 15bit */ +/* Xenomai nucleus syscalls. */ +#define __xn_sys_bind 0/* muxid = bind_to_interface(magic,featdep,abirev) */ +#define __xn_sys_completion 1/* xnshadow_completion(&completion) */ +#define __xn_sys_migrate 2/* switched = xnshadow_relax/harden() */ +#define __xn_sys_barrier 3/* started = xnshadow_wait_barrier(&entry,&cookie) */ +#define __xn_sys_info 4/* xnshadow_get_info(muxid,&info) */ +#define __xn_sys_arch 5/* r = xnarch_local_syscall(args) */ +#define __xn_sys_trace 6/* r = xntrace_xxx(...) */ +#define __xn_mux_code (shifted_id,op) ((op << 24)|shifted_id|(__xn_sys_mux & 0x7fff)) +#define XENOMAI_SYSCALL (op) __xn_mux_code(0,op)// This table maps from __NR_xxx syscall numbers (from // linux/include/asm-i386/unistd.h) to the appropriate PRE/POST sys_foo() // wrappers on x86 (as per sys_call_table in linux/arch/i386/kernel/entry.S).
@@ -2218,6 +2250,9 @@LINXY (__NR_get_robust_list, sys_get_robust_list),// 312 LINX_ (__NR_utimensat, sys_utimensat),// 320 +// LINXY(__xn_sys_mux, rt_heap_bind), // 555 +PLAXY (__xn_sys_mux, xeno_bind_skin),// 555 + PLAXY(XENOMAI_SYSCALL(__xn_sys_info),xn_shadow_sys_info), }; const UInt ML_(syscall_table_size) =
../valgrind-3.3.0/include/vki/vki-scnums-x86-linux.h renamed from include/vki/vki-scnums-x86-linux.h +2 -0
@@ -353,6 +353,8 @@#define __NR_vmsplice 316#define __NR_utimensat 320 +#define __xn_sys_mux 555 +#endif /* __VKI_SCNUMS_X86_LINUX_H */ /*--------------------------------------------------------------------*/
--> -----Original Message-----
--> From: Gilles Chanteperdrix [mailto:[email protected]] --> Sent: Thursday, November 20, 2008 8:25 AM
--> To: [email protected]
--> Cc: [email protected]; [email protected]
--> Subject: Re: [Xenomai-help] Does Valgrind work with Xenomai? -->
-->
--> Philippe Gerum wrote:
--> > Robert McCullough wrote:
--> >> Hi,
--> >>
--> >>
--> >>
--> >> I currently have a C++ application that is using 5 RTDM drivers, 2 --> >> Xenomai real-time user-space threads and several non-real-time --> Linux
--> >> threads.
--> >>
--> >> This application seems to have a memory leak because after running --> for
--> >> several hours the OOM-Killer kills this application. --> >>
--> >> I am looking for a memory leak detection tool to help find the --> leak.
--> >>
--> >>
--> >>
--> >> Two years ago in the following mail it was mentioned that making --> >> Valgrind aware of Xenomai syscalls was on the todo list. --> >>
--> >> http://article.gmane.org/gmane.linux.real-time.xenomai.users/1805
--> >>
--> >>
--> >>
--> >> Has this been done?
--> >>
--> >
--> > No news.
--> >
--> >> Does Valgrind work with Xenomai?
--> >>
--> >
--> > Nope.
-->
--> Another way around, at least if you are using the posix skin, is to --> compile your application for Linux without Xenomai. If you are using a --> legacy API, you can do this with Xenomai/SOLO. If you are using the --> native
--> API, then maybe you can ask gently Philippe to write a native skin for --> Xenomai/SOLO.
-->
--> Now, about valgrind, I spent some time thinking about it. A first --> modification of valgrind, is to allow dynamic syscall tables, such as --> what
--> Xenomai use. This should be an easy task.
-->
--> The next task is to rewrite all xenomai syscalls in valgrind language --> (that is mainly to identify memory reads and writes), this is not a --> hard
--> task, but a rather long one. So, my idea (which remains an idea for --> now)
--> was to write the interface of the syscalls in IDL, and to generate --> automatically the code for valgrind.
-->
--> --
--> Gilles.
[Robert McCullough]
Thanks Gilles for your advice and information.
My application uses the native skin but not to much so it might not take too much to convert to the posix skin. I will look into doing this. As far as the 5 RTDM drivers go, they will not run under Linux without Xenomai, correct? So, I will have to replace them with non-real-time drivers or simulate them in my application.
I am new to valgrind and have just started to try it. So, at this time I would not be very much help in the modification to work with Xenomai.
I am currently using the Linux "top" utility to monitor the memory usage of my application. Is this the best utility for this job?
Also, is there a way to monitor the memory usage of my Xenomai tasks and RTDM drivers?
Best regards,
Robert McCullough
Quoted 78 lines · Robert McCullough
--> -----Original Message-----
--> From: Gilles Chanteperdrix [mailto:[email protected]] --> Sent: Thursday, November 20, 2008 8:25 AM
--> To: [email protected]
--> Cc: [email protected]; [email protected]
--> Subject: Re: [Xenomai-help] Does Valgrind work with Xenomai? -->
-->
--> Philippe Gerum wrote:
--> > Robert McCullough wrote:
--> >> Hi,
--> >>
--> >>
--> >>
--> >> I currently have a C++ application that is using 5 RTDM drivers,
2
--> >> Xenomai real-time user-space threads and several non-real-time --> Linux
--> >> threads.
--> >>
--> >> This application seems to have a memory leak because after
running
--> for
--> >> several hours the OOM-Killer kills this application. --> >>
--> >> I am looking for a memory leak detection tool to help find the --> leak.
--> >>
--> >>
--> >>
--> >> Two years ago in the following mail it was mentioned that making --> >> Valgrind aware of Xenomai syscalls was on the todo list. --> >>
--> >> http://article.gmane.org/gmane.linux.real-time.xenomai.users/1805
--> >>
--> >>
--> >>
--> >> Has this been done?
--> >>
--> >
--> > No news.
--> >
--> >> Does Valgrind work with Xenomai?
--> >>
--> >
--> > Nope.
-->
--> Another way around, at least if you are using the posix skin, is to --> compile your application for Linux without Xenomai. If you are using
a
--> legacy API, you can do this with Xenomai/SOLO. If you are using the --> native
--> API, then maybe you can ask gently Philippe to write a native skin
for
--> Xenomai/SOLO.
-->
--> Now, about valgrind, I spent some time thinking about it. A first --> modification of valgrind, is to allow dynamic syscall tables, such
as
--> what
--> Xenomai use. This should be an easy task.
-->
--> The next task is to rewrite all xenomai syscalls in valgrind
language
--> (that is mainly to identify memory reads and writes), this is not a --> hard
--> task, but a rather long one. So, my idea (which remains an idea for --> now)
--> was to write the interface of the syscalls in IDL, and to generate --> automatically the code for valgrind.
-->
--> --
--> Gilles.[Robert McCullough]
Quoted 8 lines
Thanks Gilles for your advice and information.
My application uses the native skin but not to much so it might not take too
much to convert to the posix skin. I will look into doing this. As far as
the 5 RTDM drivers go, they will not run under Linux without Xenomai, correct? So, I will have to replace them with non-real-time drivers or simulate them in my application.
There is an experimental branch of RTDM which allows to run RTDM drivers over plain Linux. I do not remember where it is. Maybe someone can give us more details?
Quoted 10 lines
I am new to valgrind and have just started to try it. So, at this time I would not be very much help in the modification to work with Xenomai.
I am currently using the Linux "top" utility to monitor the memory usage of
my application. Is this the best utility for this job?Also, is there a way to monitor the memory usage of my Xenomai tasks and RTDM drivers?
No, not yet.
Signature · 1 line
Gilles.