Hi Stephane,
Do you mean mean the i value in "for(i =0; i <pfm_current->pme_count; i++) " in pfmlib_common.c?

Then it is 0 while the program stops.

Thanks!
--------------------------------------------------------------------
(gdb) b 1899
Breakpoint 1 at 0x804ead1: file pfmon.c, line 1899.
(gdb) r --help
Starting program: /usr/local/bin/pfmon --help
[Thread debugging using libthread_db enabled]
[New Thread 0xb7de48d0 (LWP 20951)]
[Switching to Thread 0xb7de48d0 (LWP 20951)]

Breakpoint 1, main (argc=2, argv=0xbf841dc4) at pfmon.c:1900
1900        pfmon_initialize(argv);
(gdb) s
pfmon_initialize (argv=0xbf841dc4) at pfmon.c:1387
1387        pfmon_get_version();
(gdb) n
1389        ret = pfmon_api_probe();
(gdb) n
1390        if (ret) {
(gdb) n
1402        if (options.pfm_version != PERFMON_VERSION_20)
(gdb) n
1403            options.opt_has_sets = 1;
(gdb) n
1408        pfmon_arch_initialize();
(gdb) n
1410        setup_common_signals();
(gdb) n
1413        if (pfm_initialize() != PFMLIB_SUCCESS)
(gdb) n
1416        pfm_get_version(&version);
(gdb) n
1417        if (PFM_VERSION_MAJOR(version) < 3 || PFM_VERSION_MINOR(version) < 2)
(gdb) n
1421        options.arg_mem_max = pfmon_get_perfmon_arg_mem_max();
(gdb) n
1423        ret = pfm_get_pmu_type(&options.pmu_type);
(gdb) n
1424        if (ret != PFMLIB_SUCCESS) {
(gdb) n
1428        ret = pfm_get_num_counters(&options.max_counters);
(gdb) n
1429        if (ret != PFMLIB_SUCCESS) {
(gdb) n
1433        if (check_forced_generic(argv[0])) {
(gdb) n
1442        pfmon_detect();
(gdb) n
1444        options.session_timeout = PFMON_NO_TIMEOUT;
(gdb) n
1445        options.interval = PFMON_NO_TIMEOUT;
(gdb) n
1450        long_val = sysconf(_SC_NPROCESSORS_ONLN);
(gdb) n
1451        if (long_val == -1)
(gdb) n
1454        options.online_cpus = long_val;
(gdb) n
1456        long_val = sysconf(_SC_NPROCESSORS_CONF);
(gdb) n
1457        if (long_val == -1)
(gdb) n
1460        options.config_cpus = long_val;
(gdb) n
1462        pfmon_get_phys_cpu_mask();
(gdb) n
1464        clock_getres(CLOCK_MONOTONIC, &ts);
(gdb) n
1465        options.clock_res  = ts.tv_sec * 1000000000 + ts.tv_nsec;
(gdb) n
1466        options.page_size  = getpagesize();
(gdb) n
1467        options.cpu_mhz    = pfmon_find_cpu_speed();
(gdb) n
1469        pfm_get_max_event_name_len(&len);
(gdb) s
pfm_get_max_event_name_len (len=0xbf841cc0) at pfmlib_common.c:907
907        if (PFMLIB_INITIALIZED() == 0)
(gdb) n
909        if (len == NULL)
(gdb) n
912        for(i=0; i < pfm_current->pme_count; i++) {
(gdb) n
913            str = pfm_current->get_event_name(i);
(gdb) p i
$1 = 0
(gdb) n
914            if (!str)
(gdb) n
916            l = strlen(str);
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0xb7e5c613 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb)


On Thu, Sep 24, 2009 at 4:20 AM, stephane eranian <eranian@googlemail.com> wrote:
On Thu, Sep 24, 2009 at 9:29 AM, Qingyuan Deng <ddqqyy@gmail.com> wrote:
> I tracked into the program and found the segmentation fault happened at:
>
> in pfmon.c
> pfmon_initialize()->pfm_get_max_event_name_len(&len)
>
> then it jumped into pfmlib_common.c
>
> pfm_get_max_event_name_len (len=0xbffd9460) at pfmlib_common.c:907
> 907        if (PFMLIB_INITIALIZED() == 0)
> (gdb) n
> 909        if (len == NULL)
> (gdb) n
> 912        for(i=0; i < pfm_current->pme_count; i++) {
> (gdb) n
> 913            str = pfm_current->get_event_name(i);
> (gdb) n
> 914            if (!str)
> (gdb) n
> 916            l = strlen(str);
> (gdb) n
>
> Program received signal SIGSEGV, Segmentation fault.
> 0xb7ef5613 in strlen () from /lib/tls/i686/cmov/libc.so.6
>
> Here is the backtrace:
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0xb7e7a8d0 (LWP 5257)]
> 0xb7ef2613 in strlen () from /lib/tls/i686/cmov/libc.so.6
> (gdb) backtrace
> #0  0xb7ef2613 in strlen () from /lib/tls/i686/cmov/libc.so.6
> #1  0xb7fed411 in pfm_get_max_event_name_len (len=0xbf8d5d60)
>     at pfmlib_common.c:916
> #2  0x0804dd45 in pfmon_initialize (argv=0xbf8d5e64) at pfmon.c:1469
> #3  0x0804eadf in main (argc=1, argv=0xbf8d5e64) at pfmon.c:1900
> (gdb)


I have seen this problem on an other machine as well. But I don't remember what
the cause was. It has to do with the event table.
Could you print the value of i (the event index) so we know where it stops?

>
> On Thu, Sep 24, 2009 at 3:25 AM, stephane eranian <eranian@googlemail.com>
> wrote:
>>
>> What does ldd pfmon say?
>>
>>
>> On Thu, Sep 24, 2009 at 9:01 AM, Qingyuan Deng <ddqqyy@gmail.com> wrote:
>> > Hello,
>> >
>> > I patched the kernel and installed both libpfm and perfmon, however I
>> > got
>> > segmentation fault while I tried running command: "pfmon --help'. Could
>> > anyone help me to figure it out please?
>> >
>> > I am running Ubuntu 9.04 on kernel 2.6.29. I downloaded the latest
>> > version
>> > of libpfm, perfmon, and the base system patch from the sourceforge page.
>> > My
>> > processor is Intel core i7 920 and I adjusted related configuration when
>> > I
>> > configured the kernel.  Following is the debug message from gdb:
>> >
>> >
>> > qdeng@qdeng-desktop:~/pmu/perfmon2/pfmon-3.9$ sudo make install
>> > [sudo] password for qdeng:
>> > make[1]: Entering directory `/home/qdeng/pmu/perfmon2/pfmon-3.9/pfmon'
>> > make[2]: Entering directory
>> > `/home/qdeng/pmu/perfmon2/pfmon-3.9/pfmon/smpl_mod'
>> > make[2]: Nothing to be done for `all'.
>> > make[2]: Leaving directory
>> > `/home/qdeng/pmu/perfmon2/pfmon-3.9/pfmon/smpl_mod'
>> > cc -o pfmon pfmon.o pfmon_smpl.o pfmon_util.o pfmon_system.o
>> > pfmon_task.o
>> > pfmon_symbols.o pfmon_results.o pfmon_hash.o pfmon_smpl_dfl.o pfmon_os.o
>> > pfmon_os_v2x.o pfmon_util_x86.o pfmon_i386_p6.o pfmon_gen_ia32.o
>> > pfmon_amd64.o pfmon_core.o pfmon_intel_atom.o pfmon_intel_nhm.o
>> > pfmon_pentium4.o  -g -ggdb -Wall -Werror -D_REENTRANT
>> > -I/usr/local/include
>> > -DCONFIG_PFMON_I386 -DPFMON_DEBUG -DDATADIR=\"/usr/local/share/pfmon\"
>> > -I.
>> > -I/usr/include/libelf -D_GNU_SOURCE -DPFMON_DEBUG -g
>> > smpl_mod/libsmplfmt.a
>> > -lpthread -lm -lrt -Wl,-Bstatic -lelf -Wl,-Bdynamic -L/usr/local/lib
>> > -lpfm
>> > mkdir -p /usr/local/bin
>> > install -m 755 pfmon /usr/local/bin/pfmon
>> > ln -sf /usr/local/bin/pfmon /usr/local/bin/pfmon_gen
>> > make[1]: Leaving directory `/home/qdeng/pmu/perfmon2/pfmon-3.9/pfmon'
>> > make[1]: Entering directory `/home/qdeng/pmu/perfmon2/pfmon-3.9/tests'
>> > mkdir -p /usr/local/bin
>> > install -m 755 pfdbg /usr/local/bin/pfdbg
>> > make[1]: Leaving directory `/home/qdeng/pmu/perfmon2/pfmon-3.9/tests'
>> > make[1]: Entering directory `/home/qdeng/pmu/perfmon2/pfmon-3.9/docs'
>> > mkdir -p /usr/local/share/man/man1
>> > install -m 644 pfmon.1 /usr/local/share/man/man1
>> > make[1]: Leaving directory `/home/qdeng/pmu/perfmon2/pfmon-3.9/docs'
>> > qdeng@qdeng-desktop:~/pmu/perfmon2/pfmon-3.9$ pfmon --help
>> > Segmentation fault
>> > qdeng@qdeng-desktop:~/pmu/perfmon2/pfmon-3.9$ gdb pfmon
>> > GNU gdb 6.8-debian
>> > Copyright (C) 2008 Free Software Foundation, Inc.
>> > License GPLv3+: GNU GPL version 3 or later
>> > <http://gnu.org/licenses/gpl.html>
>> > This is free software: you are free to change and redistribute it.
>> > There is NO WARRANTY, to the extent permitted by law.  Type "show
>> > copying"
>> > and "show warranty" for details.
>> > This GDB was configured as "i486-linux-gnu"...
>> > (gdb) run --help
>> > Starting program: /usr/local/bin/pfmon --help
>> > [Thread debugging using libthread_db enabled]
>> > [New Thread 0xb7e598d0 (LWP 4437)]
>> >
>> > Program received signal SIGSEGV, Segmentation fault.
>> > [Switching to Thread 0xb7e598d0 (LWP 4437)]
>> > 0xb7ed1613 in strlen () from /lib/tls/i686/cmov/libc.so.6
>> > (gdb)
>> >
>> > Thanks!
>> > Qingyuan
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> > is the only developer event you need to attend this year. Jumpstart your
>> > developing skills, take BlackBerry mobile applications to market and
>> > stay
>> > ahead of the curve. Join us from November 9&#45;12, 2009. Register
>> > now&#33;
>> > http://p.sf.net/sfu/devconf
>> > _______________________________________________
>> > perfmon2-devel mailing list
>> > perfmon2-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/perfmon2-devel
>> >
>> >
>
>