Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jan 2014 19:50:01 GMT
From:      Ulf Lilleengen <lulf@FreeBSD.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/163602: pmcstat(8) doesn&#39; t search symbols under /boot/modules
Message-ID:  <201401141950.s0EJo1P8076442@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/163602; it has been noted by GNATS.

From: Ulf Lilleengen <lulf@FreeBSD.org>
To: bug-followup@FreeBSD.org, jbeich@tormail.net
Cc:  
Subject: Re: bin/163602: pmcstat(8) doesn&#39;t search symbols under /boot/modules
Date: Tue, 14 Jan 2014 20:44:15 +0100

 This is a multi-part message in MIME format.
 --------------030308020102060505000202
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 I'm not able to reproduce this at the moment. Any tips on how? Or maybe 
 you could test out this patch:
 
 http://people.freebsd.org/~lulf/patches/pmcstat_modules.diff
 
 
 --------------030308020102060505000202
 Content-Type: text/x-patch;
  name="pmcstat_modules.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="pmcstat_modules.diff"
 
 diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
 index cc43b82..d0db9c5 100644
 --- a/usr.sbin/pmcstat/pmcstat.c
 +++ b/usr.sbin/pmcstat/pmcstat.c
 @@ -583,7 +583,7 @@ main(int argc, char **argv)
  	args.pa_verbosity	= 1;
  	args.pa_logfd		= -1;
  	args.pa_fsroot		= "";
 -	args.pa_kernel		= strdup("/boot/kernel");
 +	args.pa_kernel		= strdup("/boot/kernel;/boot/modules");
  	args.pa_samplesdir	= ".";
  	args.pa_printfile	= stderr;
  	args.pa_graphdepth	= DEFAULT_CALLGRAPH_DEPTH;
 diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
 index fdcf9c4..6606fa5 100644
 --- a/usr.sbin/pmcstat/pmcstat_log.c
 +++ b/usr.sbin/pmcstat/pmcstat_log.c
 @@ -230,6 +230,8 @@ float pmcstat_threshold = 0.5; /* Cost filter for top mode. */
  static struct pmcstat_image *pmcstat_image_from_path(pmcstat_interned_string
      _path, int _iskernelmodule);
  static void pmcstat_image_get_aout_params(struct pmcstat_image *_image);
 +static void pmcstat_locate_kernelmodule(char *_buffer, size_t _buffer_length,
 +	const char *_path);
  static void pmcstat_image_get_elf_params(struct pmcstat_image *_image);
  static void	pmcstat_image_link(struct pmcstat_process *_pp,
      struct pmcstat_image *_i, uintfptr_t _lpc);
 @@ -602,6 +604,22 @@ pmcstat_image_add_symbols(struct pmcstat_image *image, Elf *e,
  			symptr->ps_end = (symptr+1)->ps_start;
  }
  
 +static void
 +pmcstat_locate_kernelmodule(char *buffer, size_t buffer_length,
 +    const char *path)
 +{
 +	char * module_paths = strdup(args.pa_kernel);
 +	char * module_path = NULL;
 +	while ((module_path = strsep(&module_paths, ";")) != NULL) {
 +		(void) snprintf(buffer, buffer_length, "%s%s/%s", args.pa_fsroot,
 +	        module_path, path);
 +		if (access(buffer, R_OK) == 0) {
 +			break;
 +		}
 +	}
 +	free(module_paths);
 +}
 +
  /*
   * Examine an ELF file to determine the size of its text segment.
   * Sets image->pi_type if anything conclusive can be determined about
 @@ -641,8 +659,7 @@ pmcstat_image_get_elf_params(struct pmcstat_image *image)
  	 * and user mode executable objects under FSROOT/PATHNAME.
  	 */
  	if (image->pi_iskernelmodule)
 -		(void) snprintf(buffer, sizeof(buffer), "%s%s/%s",
 -		    args.pa_fsroot, args.pa_kernel, path);
 +		(void) pmcstat_locate_kernelmodule(buffer, sizeof(buffer), path);
  	else
  		(void) snprintf(buffer, sizeof(buffer), "%s%s",
  		    args.pa_fsroot, path);
 
 --------------030308020102060505000202--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401141950.s0EJo1P8076442>