Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1440483
| From | Songshan Gong <gongss@linux.vnet.ibm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map |
| Date | 2016-07-11 13:10 +0200 |
| Message-ID | <rTHg5-6eK-1@gated-at.bofh.it> (permalink) |
| References | <rS6BX-av-3@gated-at.bofh.it> <rSFT4-6xS-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
在 7/8/2016 11:21 PM, Jiri Olsa 写道:
> On Thu, Jul 07, 2016 at 09:49:36AM +0800, Song Shan Gong wrote:
>
> SNIP
>
>> + char *line = NULL;
>> + size_t n;
>> + char *sep;
>> +
>> + module_name[len - 1] = '\0';
>> + module_name += 1;
>> + snprintf(path, PATH_MAX, "%s/sys/module/%s/sections/.text",
>> + machine->root_dir, module_name);
>> + file = fopen(path, "r");
>> + if (file == NULL)
>> + return -1;
>> +
>> + len = getline(&line, &n, file);
>> + if (len < 0) {
>> + err = -1;
>> + goto out;
>> + }
>> + line[--len] = '\0'; /* \n */
>> + sep = strrchr(line, 'x');
>> + if (sep == NULL) {
>> + err = -1;
>> + goto out;
>> + }
>> + hex2u64(sep + 1, &text_start);
>
> we have following functions in tools/lib/api/fs to read
> single number from file, which I assume you do above:
>
> int sysfs__read_int(const char *entry, int *value);
> int sysfs__read_ull(const char *entry, unsigned long long *value);
>
> please check if you could use some of them,
> we could add some more generic one if needed
It seems infeasible.
Each value in /sys/module/[module name]/sections/.text is a string like
"0x000003ff8130078\n".
But the core function 'strtoull(line, NULL, 10)' in sysfs__read_ull is
based on decimal.
Maybe you can introduce a new argument indicating the value is based on
hex or decimal, or binary?
> thanks,
> jirka
>
--
SongShan Gong
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Song Shan Gong <gongss@linux.vnet.ibm.com> - 2016-07-07 03:50 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Songshan Gong <gongss@linux.vnet.ibm.com> - 2016-07-08 04:20 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Jiri Olsa <jolsa@redhat.com> - 2016-07-08 17:30 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Jiri Olsa <jolsa@redhat.com> - 2016-07-08 17:20 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Songshan Gong <gongss@linux.vnet.ibm.com> - 2016-07-11 10:20 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Songshan Gong <gongss@linux.vnet.ibm.com> - 2016-07-13 05:40 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Jiri Olsa <jolsa@redhat.com> - 2016-07-08 17:30 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Songshan Gong <gongss@linux.vnet.ibm.com> - 2016-07-11 13:10 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Jiri Olsa <jolsa@redhat.com> - 2016-07-11 14:10 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Songshan Gong <gongss@linux.vnet.ibm.com> - 2016-07-13 08:50 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Jiri Olsa <jolsa@redhat.com> - 2016-07-13 11:10 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Songshan Gong <gongss@linux.vnet.ibm.com> - 2016-07-15 09:50 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Jiri Olsa <jolsa@redhat.com> - 2016-07-15 10:30 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-07-15 15:30 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Jiri Olsa <jolsa@redhat.com> - 2016-07-08 17:30 +0200
Re: [PATCH] [RFC V1]s390/perf: fix 'start' address of module's map Jiri Olsa <jolsa@redhat.com> - 2016-07-08 17:30 +0200
csiph-web