mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	mingo@elte.hu, acme@redhat.com, namhyung.kim@kernel.org,
	Michael Lentine <mlentine@google.com>
Subject: Re: [PATCH 2/2] perf tools: add automatic remapping of Android libraries
Date: Mon, 19 May 2014 11:58:54 +0200	[thread overview]
Message-ID: <20140519095854.GB5027@krava.brq.redhat.com> (raw)
In-Reply-To: <1400282087-4616-3-git-send-email-eranian@google.com>

On Sat, May 17, 2014 at 01:14:47AM +0200, Stephane Eranian wrote:
> From: Michael Lentine <mlentine@google.com>
> 
> This patch automtically adjusts the path of MMAP records
> associated with Android system libraries. It enables running
> perf reporting tools directly on the Android system natively.

could the changelog have more info about the lib name changes?

SNIP

> +
> +	if (!strncmp(filename, "/data/app-lib", 13)) {
> +		char *apk_path;
> +
> +		if (!app_abi_length)
> +			return false;
> +
> +		new_length = 7 + app_abi_length + lib_length;
> +
> +		apk_path = getenv("APK_PATH");
> +		if(apk_path) {
> +			snprintf(*newfilename, new_length + strlen(apk_path) + 1,
> +				 "%s/libs/%s/%s", apk_path, app_abi, libname);
> +		} else {
> +			snprintf(*newfilename, new_length,
> +				 "libs/%s/%s", app_abi, libname);
> +		}

missing check for overflowing PATH_MAX for 'new_length' and 'new_length + strlen(apk_path) + 1'

> +		return true;
> +	}
> +
> +	if (!strncmp(filename, "/system/lib/", 11)) {
> +		char *ndk, *app;
> +		const char *arch;
> +		size_t ndk_length;
> +		size_t app_length;
> +
> +		ndk = getenv("NDK_ROOT");
> +		app = getenv("APP_PLATFORM");
> +
> +		if (!(ndk && app))
> +			return false;
> +
> +		ndk_length = strlen(ndk);
> +		app_length = strlen(app);
> +
> +		if (!(ndk_length && app_length && app_abi_length))
> +			return false;
> +
> +		arch = !strncmp(app_abi, "arm", 3) ? "arm" :
> +		       !strncmp(app_abi, "mips", 4) ? "mips" :
> +		       !strncmp(app_abi, "x86", 3) ? "x86" : NULL;
> +
> +		if (!arch)
> +			return false;
> +
> +		new_length = 27 + ndk_length +
> +			     app_length + lib_length
> +			   + strlen(arch);

missing check for overflowing PATH_MAX for 'new_length'

> +
> +		snprintf(*newfilename, new_length,
> +			"%s/platforms/%s/arch-%s/usr/lib/%s",
> +			ndk, app, arch, libname);
> +
> +		return true;
> +	}
> +	return false;
> +}
> +

SNIP

> +		if (android) {
> +			char *newfilename_ptr = newfilename;
> +			if (replace_android_lib(filename, &newfilename_ptr))
> +				filename = newfilename;

Why is the newfilename_ptr needed? We could pass newfilename directly
to replace_android_lib function

		if (replace_android_lib(filename, newfilename))
			filename = newfilename;

thanks,
jirka

  reply	other threads:[~2014-05-19  9:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16 23:14 [PATCH 0/2] perf tools: improve perf support on Android Stephane Eranian
2014-05-16 23:14 ` [PATCH 1/2] perf tools: add cat as fallback pager Stephane Eranian
2014-05-17  1:55   ` David Ahern
2014-05-16 23:14 ` [PATCH 2/2] perf tools: add automatic remapping of Android libraries Stephane Eranian
2014-05-19  9:58   ` Jiri Olsa [this message]
2014-05-16 23:15 [PATCH 0/2] perf tools: improve perf support on Android Stephane Eranian
2014-05-16 23:15 ` [PATCH 2/2] perf tools: add automatic remapping of Android libraries Stephane Eranian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140519095854.GB5027@krava.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@redhat.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mlentine@google.com \
    --cc=namhyung.kim@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®