Running valgrind on device/emulator

351 views
Skip to first unread message

Yoav Weiss

unread,
Jan 14, 2009, 10:28:43 AM1/14/09
to android-...@googlegroups.com
Hi All,

I have made some modifications to one of Android's native libraries. Unfortunately, along with the desired functionality came a nasty memory overrun.
Is there some way to run native libraries using valgrind either on the device or on an emulator? Is there an alternative recommended method for tracking memory overruns in Android?

Thanks in advance,
Yoav

David Turner

unread,
Jan 14, 2009, 12:22:14 PM1/14/09
to android-...@googlegroups.com
no, there is no way to do that. Actually, implementing a "valgrind" mode for the emulator has been on my to-do list for a long time, but always slipped due to higher priority items.
(it's not totally trivial if you want to do that on a normal system image)

Yoav Weiss

unread,
Jan 14, 2009, 12:46:59 PM1/14/09
to android-...@googlegroups.com
Thanks David for your reply.
I found some references to simulator mode where the entire Android system can run in a single process in Linux and valgrind can be used.
Is there any documentation to that mode? Is it still relevant?

Dan Raaka

unread,
Jan 14, 2009, 2:37:56 PM1/14/09
to android-platform
Can you post those references that you found.
Those might be helpful for me as well.

On Jan 14, 9:46 am, "Yoav Weiss" <yoav.weiss...@gmail.com> wrote:
> Thanks David for your reply.I found some references to simulator mode where
> the entire Android system can run in a single process in Linux and valgrind
> can be used.
> Is there any documentation to that mode? Is it still relevant?
>
> On Wed, Jan 14, 2009 at 6:22 PM, David Turner <di...@android.com> wrote:
> > no, there is no way to do that. Actually, implementing a "valgrind" mode
> > for the emulator has been on my to-do list for a long time, but always
> > slipped due to higher priority items.
> > (it's not totally trivial if you want to do that on a normal system image)
>

David Turner

unread,
Jan 14, 2009, 2:46:52 PM1/14/09
to android-...@googlegroups.com
Yes, that only works under Linux, use choosecombo and select a "simulator" build (instead of "device")

I don't know if third-party libraries can easily be stuffed in the simulator

Bean, Greg

unread,
Jan 14, 2009, 2:54:16 PM1/14/09
to android-...@googlegroups.com
I've also spent a few maddening weeks trying to understand if it's possible to debug the system libraries on emulator or target...if I want to make changes, say, down inside the skia library, how can I do the typical debugger stuff? The documentation for debugging high-level java apps is pretty good, but I must be missing something obvious re: libraries and simulator modes.

Are these problems related, or is my confusion deeper than I originally thought?

Many thanks.

Yoav Weiss

unread,
Jan 14, 2009, 4:39:44 PM1/14/09
to android-...@googlegroups.com
Here's what I found. I'm still trying to make something useful out of it.


Currently I'm trying to compile the sim configuration, but I encounter many conflicts. Is there a recommended development environment for the sim configuration?

Yoav Weiss

unread,
Jan 14, 2009, 6:37:20 PM1/14/09
to android-...@googlegroups.com
Now I'm encountering a linking errors when linking development/simulator/app. The errors are that various functions are undefined in the wx libraries.
The functions are:
wxImage::HasAlpha
wxBitmap::wxBitmap()
wxMenuBase::AppendSeparator()
wxWindowBase::Move()
wxWindowBase::SetClientSize()
wxDCBase::DrawBitmap

Is there a recommended version of the wx libraries? Is there some way to work around this?

Thanks in advance,
Yoav

fadden

unread,
Jan 14, 2009, 8:03:52 PM1/14/09
to android-platform
On Jan 14, 3:37 pm, "Yoav Weiss" <yoav.weiss...@gmail.com> wrote:
> Now I'm encountering a linking errors when linking
> development/simulator/app. The errors are that various functions are
> undefined in the wx libraries.The functions are:
> wxImage::HasAlpha

I put some instructions here:

http://groups.google.com/group/android-porting/browse_thread/thread/ab553116dbc960da/29167c58b3b49051#29167c58b3b49051

Type "simulator" after doing all that.

The simulator relies on wxWidgets, which you must install. I think
this will do it:

# apt-get install libwxgtk2.6-dev wx2.6-headers wx-common

Something else might be required for 64-bit setups, though I think it
mostly just works in "cupcake".

The simulator is typically in a state somewhere between "broken" and
"really broken" since there's only a handful of people who use it
internally. The media server process usually fails and often the home
page doesn't appear. If you can exercise your library outside the
Android app framework your life will be much more pleasant -- you
don't need wxWidgets and you can just launch stuff with the command-
line "dalvikvm" on the desktop. Just put "valgrind" ahead of
"dalvikvm" in the sample script in the previous article.

Ditto for gdb, which is easier and more useful on the desktop, in
large part because the sim is a "debug" build and compiler
optimizations are disabled for most components.

Yoav Weiss

unread,
Jan 15, 2009, 4:55:35 AM1/15/09
to android-...@googlegroups.com
Thanks a lot, fadden.
I tried installing wx-common, but the linking errors stay the same. It seems like I have all the required libraries (even before the wx-common installation), but their version is not what they should be.
My installed versions are 2.6.3.2.2-2ubuntu5 (for all the above libs)
Do you have any info regarding the required library versions?

Thanks again,
Yoav

Yoav Weiss

unread,
Jan 15, 2009, 1:50:24 PM1/15/09
to android-...@googlegroups.com
I was finally able to link the simulator by re-writing the function calls that weren't supported in my installed wx libraries.
Thanks. 

Yoav Weiss

unread,
Jan 16, 2009, 4:26:25 AM1/16/09
to android-...@googlegroups.com
Is there some way to activate the browser and sending it to different URLs through command line?
Reply all
Reply to author
Forward
0 new messages