gcc Option Needed for gprof

依赖专家资源的传统机构与依赖数据算法的现代平台,在转化效率上谁更胜一筹?.docx 依赖专家资源的传统机构与依赖数据算法的现代平台,在转化效率上谁更胜一筹? 立即下载

来自 《Linux® Debugging and Performance Tuning: Tips and Techniques》ch1

重点如下:

1)  编译时 使用 -pg 产生profile gmon.out

2)  gprof -b a.out

3)  编译时使用-pg -fprofile-arcs -ftest-coverage 支持产生调用图

4)  运行程序后,使用gcov *.c产生调用图*.c.gcov

5)  使用kprof查看图形界面

  

gcc Option Needed for gprof

Before programs can be profiled using gprof, they must be compiled with the-pg gcc option. To get complete information about gprof, you can use the commandinfo gprof or man gprof.

Listing 1.5 shows the benefits that profiling can have on a small program. The sample1 program prints the prime numbers up to 50,000. You can use the output from gprof to increase this program's performance by changing the program to sample2, shown later in Listing 1.8.

Listing 1.5. sample1.c
1  #include <stdlib.h>
2  #include <stdio.h>
3
4  int prime (int num);
5
6  int main()
7  {
8   int i;
9   int colcnt = 0;
10  for (i=2; i <= 50000; i++)
11    if (prime(i)) {
12      colcnt++;
13      if (colcnt%9 == 0) {
14         printf("%5d\n",i);
15         colcnt = 0;
16      }
17    else
18       printf("%5d ", i);
19    }
20    putchar('\n');
21    return 0;
22  }
23
24  int prime (int num) {
25      /* check to see if the number is a prime? */
26      int i;
27      for (i=2; i < num; i++)
28      if (num %i == 0)
29        return 0;
30      return 1;
31  }

Building the sample1 Program and Using gprof

The sample1.c program needs to be compiled with the option -pg to have profile data generated, as shown in Figure 1.11.

Figure 1.11. Building and running sample1.


When the sample1 program is run, the gmon.out file is created.

To view the profiling data, the gprof utility must be on your system. If your system isrpm-based, the rpm command shows the version of gprof, as shown inFigure 1.12.

Figure 1.12. The version of gprof.


gprof is in the binutils package. For you to use the utility, the package must be installed on your system. One useful gprof option is-b. The -b option eliminates the text output that explains the data output provided by gprof:

# gprof -b ./sample1

The output shown in Listing 1.6 from gprof gives some high-level information like the total running time, which is 103.74 seconds. The main routine running time is 0.07 seconds, and the prime routine running time is 103.67 seconds. The prime routine is called 49,999 times.

Listing 1.6. Output from gprof for sample1
Flat profile:

Each sample counts as 0.01 seconds.
  %      cumulative   self              self     total
 time     seconds   seconds   calls  ms/call   ms/call   name
 99.93     103.67   103.67    49999    2.07      2.07    prime
  0.07     103.74     0.07                               main

                   Call graph

granularity: each sample hit covers 4 byte(s) for 0.01% of
103.74 seconds

index % time    self   children     called     name
                                                   <spontaneous>
[1]    100.0    0.07       103.67              main [1]
              103.67       0.00  49999/49999        prime [2]
------------------------------------------------
              103.67       0.00  49999/49999   main [1]
[2]     99.9  103.67       0.00  49999         prime [2]
------------------------------------------------

Index by function name
   [1] main                      [2] prime

Next we can use the gcov program to look at the actual number of times each line of the program was executed. (SeeChapter 2, "Code Coverage," for more about gcov.)

We will build the sample1 program with two additional options-fprofile-arcs and-ftest-coverage, as shown in Figure 1.13. These options let you look at the program using gcov, as shown inFigure 1.14.

Figure 1.13. Building sample1 with gcov options.

Figure 1.14. Running sample1 and creating gcov output.


Running gcov on the source code produces the file sample1.c.gcov. It shows the actual number of times each line of the program was executed.Listing 1.7 is the output of gcov on sample1.

Listing 1.7. Output from gcov for sample1
        -:   0:Source:sample1.c
        -:   0:Graph:sample1.bbg
        -:   0:Data:sample1.da
        -:   1:#include <stdlib.h>
        -:   2:#include <stdio.h>
        -:   3:
        -:   4:int prime (int num);
        -:   5:
        -:   6:int main()
        1:   7: {
        1:   8:  int i;
        1:   9:  int colcnt = 0;
    50000:  10:  for (i=2; i <= 50000; i++)
    49999:  11:    if (prime(i)) {
     5133:  12:      colcnt++;
     5133:  13:      if (colcnt%9 == 0) {
      570:  14:  printf("%5d\n",i);
      570:  15:  colcnt = 0;
        -:  16:    }
        -:  17:  else
     4563:  18:    printf("%5d ", i);
        -:  19:    }
        1:  20:      putchar('\n');
        1:  21:      return 0;
        -:  22: }
        -:  23:
    49999:  24:int prime (int num) {
        -:  25:     /* check to see if the number is a prime?
                    */
    49999:  26:     int i;
121337004:  27:     for (i=2; i < num; i++)
121331871:  28:     if (num %i == 0)
    44866:  29:     return 0;
     5133:  30:     return 1;
        -:  31:     }
        -:  32:

There are 5,133 prime numbers. The expensive operations in the routine prime are thefor loop (line 27) and the if statement (line 28). The "hot spots" are the loop and the if test inside the prime routine. This is where we will work to increase the program's performance. One change that will help this program is to use thesqrt() function, which returns the nonnegative square root function of the number passed in. sample2, shown inListing 1.8, has been changed to use the sqrt function in the newly created function called faster.

Listing 1.8. sample2.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <math.h>
4
5 int prime (int num);
6 int faster (int num);
7
8 int main()
9 {
10   int i;
11   int colcnt = 0;
12   for (i=2; i <= 50000; i++)
13     if (prime(i)) {
14       colcnt++;
15      if (colcnt%9 == 0) {
16         printf("%5d\n",i);
17         colcnt = 0;
18      }
19     else
20         printf("%5d ", i);
21     }
22      putchar('\n');
23      return 0;
24 }
25
26 int prime (int num) {
27     /* check to see if the number is a prime? */
28    int i;
29     for (i=2; i <= faster(num); i++)
30     if (num %i == 0)
31       return 0;
32     return 1;
33  }
34
35 int faster (int num)
36 {
37  return (int) sqrt( (float) num);
38 }

Now you can build the sample2 program (see Figure 1.15) and use gprof to check how long the program will take to run (seeFigure 1.16). Also, the gcov output shows the reduced number of times each line needs to be executed. InListing 1.9, the total running time has been reduced from 103.74 seconds to 2.80 seconds.

Figure 1.15. Building and running sample2.


Figure 1.16. Using gprof on sample2.


Listing 1.9 shows the output of gprof for the sample2 program.

Listing 1.9. Output from gprof for sample2
Flat profile:

Each sample counts as 0.01 seconds.
%     cumulative    self               self       total
time    seconds     seconds   calls   us/call    us/call  name
52.68     1.48      1.48     1061109    1.39        1.39  faster
46.61     2.78      1.30       49999   26.10       55.60  prime
 0.71     2.80      0.02                               main

                Call graph

granularity: each sample hit covers 4 byte(s)  for 0.36% of 2.80
seconds

index   % time    self   children   called       name
                                                    <spontaneous>
[1]     100.0     0.02      2.78                  main [1]
                  1.30      1.48   49999/49999       prime [2]
---------------------------------------------------
                  1.30      1.48   49999/49999       main [1]
[2]      99.3     1.30      1.48   49999          prime [2]
                  1.48      0.00   1061109/1061109   faster [3]
---------------------------------------------------
                  1.48      0.00   1061109/1061109   prime [2]
[3]      52.7     1.48      0.00   1061109        faster [3]
---------------------------------------------------
Index by function name

[3] faster                    [1] main                     [2]
prime

Now we'll run gcov on the sample2 program, as shown in Figures 1.17 and 1.18.

Figure 1.17. Building sample2 with gcov and running sample2.

Figure 1.18. Running sample2 and getting gcov output.


Listing 1.10 shows gcov output for the sample2 program.

Listing 1.10. Output of sample2.c.gcov
      -:   0:Source:sample2.c
      -:   0:Graph:sample2.bbg
      -:   0:Data:sample2.da
      -:   1:#include <stdlib.h>
      -:   2:#include <stdio.h>
      -:   3:#include <math.h>
      -:   4:
      -:   5:int prime (int num);
      -:   6:int faster (int num);
      -:   7:
      -:   8:int main()
      1:   9:{
      1:  10:   int i;
      1:  11:   int colcnt = 0;
  50000:  12:   for (i=2; i <= 50000; i++)
  49999:  13:      if (prime(i)) {
   5133:  14:      colcnt++;
   5133:  15:      if (colcnt%9 == 0) {
    570:  16:printf("%5d\n",i);
    570:  17:colcnt = 0;
      -:  18:     }
      -:  19:   else
   4563:  20:     printf("%5d ", i);
      -:  21:    }
      1:  22:      putchar('\n');
      1:  23:      return 0;
      -:  24: }
      -:  25:
  49999:  26:int prime (int num) {
      -:  27:     /* check to see if the number is a
                  prime? */
  49999:  28:    int i;
1061109:  29:     for (i=2; i <= faster(num); i++)
1055976:  30:     if (num %i == 0)
  44866:  31:       return 0;
   5133:  32:     return 1;
      -:  33:     }
      -:  34:
      -:  35:int faster (int num)
1061109:  36: {
1061109:  37:  return (int) sqrt( (float) num);
      -:  38: }
      -:  39:

The for loop in the prime routine has been reduced from 121 million executions to 1 million executions. Therefore, the total time has been reduced from 103.74 seconds to 2.80 seconds.

The tools gprof and gcov helped find the "hot spots" in this sample program. After the "hot spots" were found, the program was changed to increase its overall performance. It is interesting how changing a few lines of code can have a great impact on a program's performance.

Listing 1.11, sample3.cpp, has three different functions (1, 2, and 3). It shows a more complex use of profiling, with both flat and graphic profiles. We'll also use kprof, which can use gprof output. It presents the information in list or tree views, which make the information easier to understand when programs are more complicated. Let's start by building the sample3.cpp program and displaying the flat and graphic profiles and then displaying the data using kprof.

Listing 1.11. sample3.cpp
1  #include <iostream>
2
3  void function1(){
4     for(int i=0;i<1000000;i++);
5  }
6
7  void function2(){
8     function1();
9     for (int i=0;i<2000000;i++);
10 }
11
12 void function3(){
13    function1();
14    function2();
15    for (int i=0;i<3000000;i++);
16       function1();
17 }
18
19 int main(){
20    for(int i=0;i<10;i++)
21    function1();
22
23    for (int i=0;i<5000000;i++);
24
25    for(int i=0;i<10;i++)
26       function2();
27       for(int i=0; i<13;i++);
28          {
29          function3();
30          function2();
31          function1();
32          }
33 }

Figure 1.19 shows the commands used to build and run the sample3 program. gprof is also run on sample3 to get the profile data from sample3.

Figure 1.19. Building and capturing gprof output for sample3.


We won't use the -b option on the gprof output on the sample3 program so that we can see all the descriptive information that gprof can display.

The sample3.gprof should look similar to this:

Flat profile:
Each sample counts as 0.01 seconds.
%       cumulative    self             self      total
time    seconds       seconds  calls   ms/call   ms/call   name
43.36   4.21          4.21     12      0.35      0.52      function2()
42.84   8.37          4.16     25      0.17      0.17      function1()
 8.65   9.21          0.84                                 main
 5.15   9.71          0.50      1      0.50      1.35      function3()
 0.00   9.71          0.00      1      0.00      0.00      global constructors
                                                           keyed to function1()
 0.00   9.71          0.00      1      0.00      0.00
__static_initialization_and_destruction_0(int, int)

Field

Description

% time

The percentage of the program's total running time used by this function.

cumulative seconds

A running sum of the number of seconds accounted for by this function and those listed above it.

self seconds

The number of seconds accounted for by this function alone. This is the major sort for this listing.

calls

The number of times this function was invoked if this function is profiled; otherwise, it is blank.

self ms/call

The average number of milliseconds spent in this function per call if this function is profiled; otherwise, it is blank.

total ms/call

The average number of milliseconds spent in this function and its descendents per call if this function is profiled; otherwise, it is blank.

name

The function's name. This is the minor sort for this listing. The index shows the location of the function in the gprof listing. If the index is in parentheses, it shows where it would appear in the gprof listing if it were to be printed.


Call graph (explanation follows)
granularity: each sample hit covers 4 byte(s) for 0.10% of 9.71 seconds
index %  time  self     children      called        name
                                                       <spontaneous>
[1]   100.0    0.84     8.87                        main [1]
               3.86     1.83          11/12               function2() [2]
               1.83     0.00          11/25               function1() [3]
               0.50     0.85          1/1                 function3() [4]
------------------------------------
               0.35     0.17          1/12                function3() [4]
               3.86     1.83          11/12              main [1]
[2]   63.9     4.21     2.00          12            function2() [2]
               2.00     0.00          12/25              function1() [3]
------------------------------------
               0.33     0.00          2/25              function3() [4]
               1.83     0.00          11/25             main [1]
               2.00     0.00          12/25             function2() [2]
[3]   42.8     4.16     0.00          25            function1() [3]
------------------------------------
               0.50      0.85         1/1                main [1]
[4]   13.9     0.50      0.85         1           function3() [4]
               0.35      0.17         1/12               function2() [2]
               0.33      0.00         2/25               function1() [3]
------------------------------------
               0.00      0.00         1/1          __do_global_ctors_aux [13]
[11]  0.0      0.00      0.00         1        global constructors keyed to
function1() [11]
               0.00      0.00         1/1
__static_initialization_and_destruction_0(int, int) [12]
------------------------------------
               0.00      0.00         1/1          global constructors keyed to
function1() [11]
[12]           0.0       0.00         0.00          1
__static_initialization_and_destruction_0(int, int) [12]
------------------------------------

This table describes the program's call tree. It is sorted by the total amount of time spent in each function and its children.

Each entry in this table consists of several lines. The line with the index number at the left margin lists the current function. The lines above it list the functions that called this function, and the lines below it list the functions this one called.

You see the following:

Field

Description

index

A unique number given to each element of the table. Index numbers are sorted numerically. The index number is printed next to every function name so that it is easier to look up the function in the table.

% time

The percentage of the total time that was spent in this function and its children. Note that due to different viewpoints, functions excluded by options, and so on, these numbersdo not add up to 100%.


Field

Description

self

The total amount of time spent in this function.

children

The total amount of time propagated into this function by its children.

called

The number of times the function was called. If the function called itself recursively, the number includes only nonrecursive calls and is followed by a + and the number of recursive calls.

name

The name of the current function. The index number is printed after it. If the function is a member of a cycle, the cycle number is printed between the function's name and the index number.


For the function's parents, the fields have the following meanings:

Field

Description

self

The amount of time that was propagated directly from the function into this parent.

children

The amount of time that was propagated from the function's children into this parent.

called

The number of times this parent called the function and the total number of times the function was called. Recursive calls to the function are not included in the number after the /.

name

The parent's name. The parent's index number is printed after it. If the parent is a member of a cycle, the cycle number is printed between the name and the index number.


If the function's parents cannot be determined, the word <spontaneous> is printed in the name field, and all the other fields are blank.

For the function's children, the fields have the following meanings:

Field

Description

self

The amount of time that was propagated directly from the child into the function.

children

The amount of time that was propagated from the child's children to the function.

called

The number of times the function called this child and the total number of times the child was called. Recursive calls by the child are not listed in the number after the /.

name

The child's name. The child's index number is printed after it. If the child is a member of a cycle, the cycle number is printed between the name and the index number.


If the call graph has any cycles (circles), there is an entry for the cycle as a whole. This entry shows who called the cycle (as parents) and the members of the cycle (as children). The + recursive calls entry shows how many function calls were internal to the cycle. The calls entry for each member shows, for that member, how many times it was called from other members of the cycle.

Index by function name
[11] global constructors keyed to function1() [3] function1() [4] function3()
[12] __static_initialization_and_destruction_0(int, int) [2] function2() [1]
main



YOLO11-Seg优化:注意力魔改 | 具有切片操作的SimAM注意力,魔改SimAM 问题点:SimAM计算整张特征图的像素差平均值时加权可能会忽略小目标的重要性,同时与整体平均值相比可能和背景信息相似,导致加权增强较弱; 阅读详情

相关推荐

python提取图片中的文字写入excel文件,并打包为exe可执行文件

python提取图片中的文字写入excel文件,并打包为exe可执行文件

liqiang12689的博客 991

性能优化之C++ Profiler

最近在做有关性能优化方面的东西,其中使用到了Profiler,就目前来看除了glibc中自带的gprof以外,还有一个使用的比较广泛的由google开发的GooglePerformance tools,在这篇博文中,我们就来学学gprof这个性能调试工具吧,在介绍gprof之前,我们有必要来思考下我们优化的性能主要包括哪些部分,这部分内容可以参考这篇博文http://coolshell.cn/ar

zmyer的专栏 4608

5分钟搞定:用Pyannote和Whisper实现带说话人分离的语音转文字(附完整代码)

本文详细介绍了如何快速构建一个集成了说话人分离功能的语音转文字系统。通过结合OpenAI的Whisper模型进行高精度语音识别和Pyannote模型实现说话人分离,并提供了完整的代码实现、环境搭建指南以及核心的对齐与合并逻辑,帮助开发者高效处理会议录音、访谈等多说话人音频,实现自动化转录。

threejs5artist的博客 639

GNU profiler(gprof)使用介绍及遇到的问题总结

GNU profiler、gprof、性能测试分析、图形化调用关系

Chengzi_comm的专栏 6181

潜行游戏设计:核心机制与关卡设计解析

潜行游戏作为动作游戏的重要分支,通过视觉遮蔽、声音传播和AI行为树等复杂系统,为玩家提供独特的策略体验。视觉隐蔽系统采用视野锥和光照值的双重判定,声学传播模型模拟距离衰减和材质穿透,而敌人AI行为树则包含巡逻、警戒和团队协作等状态节点。这些技术不仅提升了游戏的真实感和挑战性,还在《合金装备》《刺客信条》等经典作品中得到广泛应用。潜行游戏的关卡设计强调多路径拓扑结构和环境叙事元素,通过沙漏模型和动态难度调节,平衡自由度和开发成本。未来,基于ML的适应性AI和物理模拟的隐蔽系统将成为创新方向。

weixin_42497762的博客 186

保姆级教程:手把手配置MAX9295/9296 GMSL2-CSI2链路,搞定4LAN/1LAN模式与常见调试

本文提供MAX9295/9296 GMSL2-CSI2链路的详细配置教程,涵盖4LAN和1LAN模式的硬件连接、寄存器配置及调试技巧。通过实战案例和代码示例,帮助开发者快速实现高带宽视频传输,解决常见问题如信号同步和功耗优化,适用于车载摄像头和机器人视觉系统开发。

weixin_42561143的博客 441

Ubuntu系统下交叉编译gpac

Ubuntu系统下交叉编译gpac

IT菜鸟 643

告别手动干预:深入浅出LPDDR5的Background ZQ校准与DVFSQ切换避坑指南

本文深入解析LPDDR5的Background ZQ校准与DVFSQ切换技术,帮助工程师实现DRAM阻抗校准的自动化管理。通过详细配置指南和实战案例,揭示如何避免动态电压调节下的模式切换陷阱,提升信号完整性和系统能效。特别适合嵌入式系统和移动终端开发者参考。

weixin_30329623的博客 458

perl中数组变量的初始化

perl array init

行风 8629

多智能体协作的本质是中介者模式,不是多开Agent

多智能体系统并非简单启动多个Agent实例,而是一种受控的、可验证的动态交互过程。其核心原理在于解耦Agent间直接依赖,通过中央中介者统一管理任务分发、协议转换、状态协调与故障兜底。这种架构显著提升系统的可观测性、容错性与可维护性,技术价值体现在强一致性保障(如金融订单原子操作)与灵活自治平衡(如边缘设备轻量协同)。典型应用场景包括电商客服协同、工业巡检调度、飞书/微信多渠道智能服务等。OpenClaw与Hermes Agent正是这一范式的工程落地代表,分别体现强中介与弱中介两种演进路径。

weixin_34151004的博客 366

【AI Agent系列】【MetaGPT】9. 一句话订阅专属信息 - 订阅智能体进阶,实现一个更通用的订阅智能体(2)

订阅智能体进阶(2)。不用爬虫,直接提取网页信息。从RunSubscription分离出AddSubscriptionTask的action,并且让SubscriptionRunner单独运行。

同学小张的博客 1590

logrotate 里面应该使用copytruncate

1. 参考http://unix.stackexchange.com/questions/33447/why-we-should-use-create-and-copytruncate-together

行风 7481

裂缝二维检测:裂缝的长度和宽度检测

这一节,我们需要去整合一下前面的代码,在进行长度和宽度的测量时,需要裂缝的类型、个数、面积的帮助。这一章是本专栏的核心部分。以上代码我均试过,由于本人能力有限,看不懂代码,最终还是没有采用,使用的是最普通检测宽度的方法,即求得骨架总长度后,用总面积求取平均宽度。

m0_62919535的博客 4247

关于SSH的一些总结

1. 查看sshd的版本 root # rpm -qf /usr/sbin/sshd openssh-server-4.3p2-82.el5 root # rpm -qi openssh-server-4.3p2-82.el5 Name : openssh-server Relocations: (not relocatable) Version

行风 6377

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

使用gcov提高代码测试覆盖率

参考:《Linux® Debugging and Performance Tuning: Tips and Techniques》 chapter 2 1. 待测代码如下: /home/a/j/nomad2:cat sample.c #include #include

行风 3268

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

cygwin 安装 python setuptools

see http://serverfault.com/questions/7282/how-to-run-easy-install-in-cygwin $ wget http://peak.telecommunity.com/dist/ez_setup.py $ python ez_setup.py

行风 2745

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

程序员的自我修养 ch6 可执行文件的装载与进程

参考《程序员的自我修养》ch6 1. MMU MMU是Memory Management Unit的缩写,中文名是内存管理单元,它是中央处理器(CPU)中用来管理虚拟存储器、物理存储器的控制线路,同时也负责虚拟地址映射为物理地址,以及提供硬件机制的内存访问授权。 在ELF中把这些属性相似的,又连在一起的段叫做一个“segment”,而系统正是按照“segment”而不是“section”

行风 2652

linux top command

man top

行风 2603

程序员的自我修养 ch4 静态链接

参考《程序员的自我修养》ch4. 1. 空间与地址分配 这里的空间分配只关注于虚拟地址空间的分配 现在的链接器空间分配基本上都采用 相同类型合并 的策略,使用这种方法的链接器一般采用一种叫 两步链接(Two-pass Linking) 的方法。 也就是说整个过程分两步: 第一步 空间与地址分配; 第二步 符号解析与重定位,这一步是链接的核心,特别是重定位; >> ld a.o b.

行风 2579

perl 字符串数组,如何输出带引号的数组元素

from: http://stackoverflow.com/questions/739214/how-do-i-output-each-perl-array-element-surrounded-in-quotes 例如: /home/a/j/nomad2:cat 1 #!/usr/bin/perl my @strArray = ("abc", "bcd"); my $text = do

行风 2422

python spark

http://pages.cpsc.ucalgary.ca/~aycock/spark/ Spark 是一种用Python 编写的强大的、通用的解析器/编译器框架, see https://www.ibm.com/developerworks/cn/linux/sdk/python/charm-27/

行风 2239

python file operation

和c语言一样,不能使用'rw'方式打开一个文件并进行读写,正确的方式是‘r+’,详见http://mail.python.org/pipermail/python-bugs-list/2001-May/005216.html Bugs item #420771, was updated on 2001-05-02 10:11 You can respond by visiting:

行风 1913

Linux Debugging 3 - Compile and Debug

gcc ldd strip objdump nm core

行风 1705

64位系统stack overflow示例

64 linux stack overflow example

行风 1650

程序员的自我修养 ch3 目标文件

参考《程序员的自我修养》ch3 1. 目标文件的种类 >> file hello.o hello.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped >> file /bin/ls /bin/ls: ELF 32-bit LSB executable, Intel 80386, vers

行风 1552

Linux Debugging 7 - Stack and Heap

1. 进程空间布局 对于32位机器来说,kernel占用了0xC0000000以及更高的地址,代码装载到0x08048000,数据段和BSS在代码段上面,栈从0xBFFFFFFF开始往下,堆的位置不确定,共享对象在最下面。 可以查看进程的maps来看,下面是64位机器的例子, /home/a/j/nomad2:cat /proc/16683/maps 00400000-004be0

行风 1479
上一篇: 使用vim/sed去除网上copy的源代码行号和空格
下一篇: 使用gcov提高代码测试覆盖率
nomad2
博客等级 码龄21年 163粉丝 420原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值