Quantcast

hello there is a question about callgrind on the arm64.

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

hello there is a question about callgrind on the arm64.

Wuweijia

Hi :

I ran the code through the callgrind on the x86-64, it is ok , no recursive cycle existed.

But I ran the same the same code through the callgrind on the arm64, it show me there is recursive cycle existed.

 

 

  Between two callgrind.out. file:

     In arm64:

        There is function name main’2. It meaning that there is recursive cycle. And it annote the source failed.

     In x86_64:

     There is no  function name  main’2  only main., It mean that there is no cycle.

 

     How can I resovle it?

 

The compile options : gcc –g –O0 ./main.cpp

 

The gcc version 4.9

 

Run options: valgrind --tool=callgrind ./a.out

 

  Callgrind_annote option callgrind_annote –auto=yes

 

 

BR

Owen


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

my.rar (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: hello there is a question about callgrind on the arm64.

John Reiser
>       In arm64:
>
>          There is function name main’2. It meaning that there is recursive cycle. And it annote the source failed.
>
>       In x86_64:
>
>       There is no  function name  main’2  only main., It mean that there is no cycle.
>
>       How can I resolve it?

Post here the source code to the smallest (shortest) program which does not behave like you expect.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

答复: hello there is a question about callgrind on the arm64.

Wuweijia
The source code(main.cpp) is in the my.rar. and the callgrind output are also in the my.rar.

Did you never receive it ?



-----邮件原件-----
发件人: John Reiser [mailto:[hidden email]]
发送时间: 2017年5月12日 11:18
收件人: [hidden email]
主题: Re: [Valgrind-users] hello there is a question about callgrind on the arm64.

>       In arm64:
>
>          There is function name main’2. It meaning that there is recursive cycle. And it annote the source failed.
>
>       In x86_64:
>
>       There is no  function name  main’2  only main., It mean that there is no cycle.
>
>       How can I resolve it?

Post here the source code to the smallest (shortest) program which does not behave like you expect.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

main.cpp (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

答复: hello there is a question about callgrind on the arm64.

Wuweijia
In reply to this post by John Reiser

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char getCommon(char * argv) {
    char result = 0;
    result = argv[0];
    for(int i = 0; i < 2; i++ ) {
         if( argv[1] > 100 ) {
            result += argv[1] + 10;
         }

         if( argv[2] < 30 ) {
            result += argv[2] * 2;
         }
    }    

    return result;
}

char getCommon2(char * argv) {
    char result = 0;
    result = argv[0];
    for(int i = 0; i < 2; i++ ) {
         if( argv[1] > 20 ) {
            result += argv[1] + 10;
         }  

         if( argv[2] < 110 ) {
            result += argv[2] * 3;
         }  
    }    

    return result;
}


int main(int argc, char ** argv) {
    unsigned long i = 0;
    char * p = (char *)malloc(1024 * 1024);
    memset(p, 1, 1024 * 1024);

   
   for(int i = 0; i < 10; i++ ) {
       for(int j = 0; j < 1024 * 1024 - 3; j++) {
            if(j % 2 == 0) {
              p[j] = getCommon(p + j);
            } else {
              p[j] = getCommon2(p + j);
            }
       }
        memset(p, 1, 1024 * 1024);
   }
   printf("p=%p\n", p);
    return 0;
}
-----邮件原件-----
发件人: John Reiser [mailto:[hidden email]]
发送时间: 2017年5月12日 11:18
收件人: [hidden email]
主题: Re: [Valgrind-users] hello there is a question about callgrind on the arm64.

>       In arm64:
>
>          There is function name main’2. It meaning that there is recursive cycle. And it annote the source failed.
>
>       In x86_64:
>
>       There is no  function name  main’2  only main., It mean that there is no cycle.
>
>       How can I resolve it?

Post here the source code to the smallest (shortest) program which does not behave like you expect.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

答复: hello there is a question about callgrind on the arm64.

Wuweijia
In reply to this post by John Reiser
Hi:
        Is there any news?

BR
Owen

-----邮件原件-----
发件人: Wuweijia
发送时间: 2017年5月12日 12:40
收件人: 'John Reiser' <[hidden email]>; [hidden email]
抄送: Fanbohao <[hidden email]>
主题: 答复: [Valgrind-users] hello there is a question about callgrind on the arm64.


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char getCommon(char * argv) {
    char result = 0;
    result = argv[0];
    for(int i = 0; i < 2; i++ ) {
         if( argv[1] > 100 ) {
            result += argv[1] + 10;
         }

         if( argv[2] < 30 ) {
            result += argv[2] * 2;
         }
    }    

    return result;
}

char getCommon2(char * argv) {
    char result = 0;
    result = argv[0];
    for(int i = 0; i < 2; i++ ) {
         if( argv[1] > 20 ) {
            result += argv[1] + 10;
         }  

         if( argv[2] < 110 ) {
            result += argv[2] * 3;
         }  
    }    

    return result;
}


int main(int argc, char ** argv) {
    unsigned long i = 0;
    char * p = (char *)malloc(1024 * 1024);
    memset(p, 1, 1024 * 1024);

   
   for(int i = 0; i < 10; i++ ) {
       for(int j = 0; j < 1024 * 1024 - 3; j++) {
            if(j % 2 == 0) {
              p[j] = getCommon(p + j);
            } else {
              p[j] = getCommon2(p + j);
            }
       }
        memset(p, 1, 1024 * 1024);
   }
   printf("p=%p\n", p);
    return 0;
}
-----邮件原件-----
发件人: John Reiser [mailto:[hidden email]]
发送时间: 2017年5月12日 11:18
收件人: [hidden email]
主题: Re: [Valgrind-users] hello there is a question about callgrind on the arm64.

>       In arm64:
>
>          There is function name main’2. It meaning that there is recursive cycle. And it annote the source failed.
>
>       In x86_64:
>
>       There is no  function name  main’2  only main., It mean that there is no cycle.
>
>       How can I resolve it?

Post here the source code to the smallest (shortest) program which does not behave like you expect.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 答复: hello there is a question about callgrind on the arm64.

John Reiser
> Is there any news?

I ran the program in 64-bit mode on Raspberry Pi 3 (1GiB RAM) with:
        kernel-4.9.28-1 (Fedora 25)
        gcc-6.3.1
        glibc-2.24-4.fc25.aarch64
        valgrind-3.12.0 (compiled from .tar.bz2 in one-half hour)

A swap file of 2GiB was not enough:
=====
==22295==     Valgrind's memory management: out of memory:
==22295==        newSuperblock's request for 1835012096 bytes failed.
==22295==        1,247,584,256 bytes have already been mmap-ed ANONYMOUS.
==22295==     Valgrind cannot continue.  Sorry.
=====
A swap file of 4GiB allowed execution to finish:
        # dd if=/dev/zero of=/swap-file bs=1M count=4096
        # chmod 600 /swap-file
        # swapon /swap-file
[Side comment: Requiring more than 3GiB (1GiB RAM plus 2GiB swapspace)
for this small, short program is wildly extravagant by callgrind.]

The execution (several minutes) was:
        gcc  -g  -O0  ./main.cpp
        valgrind  --tool=callgrind  ./a.out
        callgrind_annotate  --auto=yes  callgrind.out.PID  main.cpp

The complete output from callgrind_annotate is attached (callgrind_annotate.out,
4.5 kB).  I see lines such as
=====
10,485,720  char getCommon2(char * argv) {
   5,242,860      char result = 0;
  15,728,580      result = argv[0];
  94,371,480      for(int i = 0; i < 2; i++ ) {
          34  => ./main.cpp:getCommon2(char*)'2 (1x)
  52,428,600           if( argv[1] > 20 ) {
=====
This suggests to me that callgrind's code which discovers tracebacks
has a problem, because there is no subroutine call anywhere in getCommon2,
yet callgrind thinks that getCommon2 called itself [recursively].
I have not looked carefully at what is happening.

--






------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

callgrind_annotate.out (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: hello there is a question about callgrind on the arm64.

Josef Weidendorfer
In reply to this post by Wuweijia
Hi Owen,

callgrind currently is somewhat broken on ARM, as the
tracking of entering/leaving functions is unreliable.

Callgrind heavily uses the stack pointer for that.
On x86, this works fine, as every call/return changes
the SP, but on ARM, this is not the case.

There are ideas and at some point, there were
patches promised by someone, but unfortunately nothing
useful up to now...

Josef


Am 12.05.2017 um 05:11 schrieb Wuweijia:

> Hi :
>
> I ran the code through the callgrind on the x86-64, it is ok , no
> recursive cycle existed.
>
> But I ran the same the same code through the callgrind on the arm64, it
> show me there is recursive cycle existed.
>
>    Between two callgrind.out. file:
>
>       In arm64:
>
>          There is function name main’2. It meaning that there is
> recursive cycle. And it annote the source failed.
>
>       In x86_64:
>
>       There is no  function name  main’2  only main., It mean that there
> is no cycle.
>
>       How can I resovle it?
>
> The compile options : gcc –g –O0 ./main.cpp
>
> The gcc version 4.9
>
> Run options: valgrind --tool=callgrind ./a.out
>
>    Callgrind_annote option callgrind_annote –auto=yes
>
> BR
>
> Owen
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> Valgrind-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
Loading...