Using valgrind with the simulator

189 views
Skip to first unread message

Yoav Weiss

unread,
Feb 2, 2009, 7:21:00 AM2/2/09
to android-...@googlegroups.com
Hi all,

I'm having trouble running the simulator using valgrind and tracking down memory leaks and errors.
I've compiled the simulator over an Ubuntu 8.04 VM and running it using:
valgrind -v --log-file=logs.txt ./out/host/linux-x86/bin/simulator

This way doesn't really debug the actual Android process since is it a child process of the simulator. However, when I tried adding the --trace-children option to valgrind, I received an error: "execvp 'xterm' failed: permission denied".
Running the same as a super user, didn't make any difference.

Is this a known issue? How can I run valgrind to get memory info of the actual Android process?

Thanks in advance,
Yoav

Angus Lees

unread,
Feb 2, 2009, 10:13:43 AM2/2/09
to android-...@googlegroups.com
erm.. you're valgrinding a virtual machine. It's a long way from
there to the actual process running within android (which I think is
what you're asking about).

You want to cross-compile valgrind for arm and run it *inside* the
emulator - I've no idea how badly the ibinder stuff will upset it.

- Gus

Yoav Weiss

unread,
Feb 2, 2009, 2:40:17 PM2/2/09
to android-...@googlegroups.com
Thanks Gus for your reply.

I'm not trying to valgrind an application, I'm trying to valgrind one of the native libraries (which I modified). So there's no virtual machine in the mix. As far as I understood, the Simulator is a single Linux process running (more or less) the entire Android environment in it, so valgrind should detect memory problems in one of the libraries.

Yoav


On Mon, Feb 2, 2009 at 4:13 PM, Angus Lees <al...@google.com> wrote:

erm.. you're valgrinding a virtual machine.  It's a long way from
there to the actual process running within android (which I think is
what you're asking about).

You want to cross-compile valgrind for arm and run it *inside* the
emulator - I've no idea how badly the ibinder stuff will upset it.

 - Gus

fadden

unread,
Feb 2, 2009, 7:45:49 PM2/2/09
to android-platform
On Feb 2, 11:40 am, Yoav Weiss <yoav.weiss...@gmail.com> wrote:
> I'm not trying to valgrind an application, I'm trying to valgrind one of the
> native libraries (which I modified). So there's no virtual machine in the
> mix. As far as I understood, the Simulator is a single Linux process running
> (more or less) the entire Android environment in it, so valgrind should
> detect memory problems in one of the libraries.

You need to run "simulator", and when the UI pops up check the "Use
valgrind" checkbox. (If you find yourself changing this often, go
into File->Preferences->Simulator and uncheck "Boot runtime when
simulator starts". That'll give you an opportunity to fiddle with the
options before things kick in.)

You can also check "Use debugger" to have things break in gdb. If
both "use debugger" and "use valgrind" are enabled, you get "--db-
attach=yes" behavior.

Running valgrind on the simulator front-end is not very useful unless
you'd like to help the wxWidgets developers fix some things.

Customary warning: this is not a supported component, and we don't
promise it will do anything useful.

Yoav Weiss

unread,
Feb 3, 2009, 3:15:13 AM2/3/09
to android-...@googlegroups.com
Thanks fadden,

Is it possible to run valgrind with some options?
I tried adding options in the File->Preferences->Simulator screen, but it failed to run, since it took the entire string as a file name. Is there options support or should I add one?
If there is none, can you please direct me to the code that loads valgrind?

Yoav

fadden

unread,
Feb 3, 2009, 7:28:30 PM2/3/09
to android-platform
On Feb 3, 12:15 am, Yoav Weiss <yoav.weiss...@gmail.com> wrote:
> If there is none, can you please direct me to the code that loads valgrind?

In the git sources:

development/simulator/app/DeviceManager.cpp,
DeviceManager::DeviceThread::LaunchProcess()
Reply all
Reply to author
Forward
0 new messages