| |

VerySource

 Forgot password?
 Register
Search
Author: larrydeng

Function call stack view

[Copy link]

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-8-6 09:30:01
| Show all posts
Upstairs, judging from your sample program, do you have to automatically generate a symbol table.c when compiling, just like your global variable name_rcd[], and the symbol address is stored incrementally, before you can use this Way?

Is there another way to achieve it?
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-8-6 15:45:02
| Show all posts
There is no need to generate symbol, it will generate .pdb when link is in .map, but you have to find a way to figure out the format of .pdb
Reply

Use magic Report

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-8-6 17:00:01
| Show all posts
Learn
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-6 20:15:01
| Show all posts
I don't know if there is such an API function, but I know it is very simple to implement:

Create a linked list, each node records the current function name (you can get the function name through the macro __FUNCTION__);

The specific implementation process is as follows
Each time a function is entered, a node is added; when the function is exited, the node is deleted

In this case, when each function is called, the previous node in the linked list indicates the function that called it, and the previous node indicates the last function that called it...By analogy, all the calling relationships are listed. Up
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-8-7 01:15:01
| Show all posts
Your method upstairs is theoretically possible, but it is too troublesome... and adds a lot of unnecessary overhead.

As far as I know, vxworks should use a similar method toyy偶不会. In the process of compiling the entire system, a symbol table .c file is generated, and finally this .c file is also linked into the final generated file. When you trace the stack, you can find it in that table. I think the role of the table is more than just the trace stack. The command line system provided by vxworks allows us to call the function by entering the function name, which should also be the credit of the .c file. As for files such as pdb, map, etc., it should only be meaningful when searching manually.
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-8-8 17:45:01
| Show all posts
mark
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-8-8 18:00:01
| Show all posts
.map is for people to see, .pdb is for debuggers, there are more things in it than you think, there are all kinds of data types, it should be the most convenient...
This is not very good, once the compiler optimization is turned on, the call stack cannot be obtained in this way, because many functions do not generate stack frames...
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-8-8 19:30:01
| Show all posts
The landlord seems to have added that when it is not debugging, you only need to use functions to watch the trace stack during operation, and you will never let an executable file find its own pdb...

Compiler optimization will not be generated across the board

push bp
mov bp, sp

Well, I don't know how many levels of gcc optimization will start like this...
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-8-8 22:15:01
| Show all posts
After checking, there is no mention of not building a stack frame in the various optimization instructions of gcc, and the test results also did not find the situation of not building a stack frame.
Will vc?
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-8-8 22:45:01
| Show all posts
The gcc compilation optimization is slightly worse. When cl -O2, almost all functions do not generate stack frames, unless the function calls _alloca ...

gcc -O3 -Os can actually generate the function int foo() {return f(); }:
pushl %ebp
movl %esp, %ebp
popl %ebp
jmp _r
I'm fainted, it seems that the version is too low, and it must be upgraded.....
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list