大家好, 我们可以读取当前进程的堆栈帧吗。 因为我们知道无论何时进行函数调用在c新函数中 堆栈框架创建并将其推送到堆栈。当函数返回 时,它会从堆栈中弹出。我想知道来电者的功能 名字。 i意味着我想要这样的东西 int a( ) { printf(" File =%s \ n",__ FILE__); / *我想打印来电者在这里命名。像这样的东西 printf(" Caller function =%s \ n",__ CALLER_FUN__);它应该打印 b * / 返回0; } int b() { a(); 返回0; } int main() { b(); } 如果有的话请告诉我。 谢谢和问候 Harshal Shete
解决方案10月17日下午3:56,harshal< harshalsh ... @ gmailwrote: 大家好, 我们可以读取当前进程的堆栈帧吗。 因为我们知道无论何时在c函数中进行函数调用 堆栈框架创建并将其推送到堆栈。当函数返回 时,它会从堆栈中弹出。我想知道来电者的功能 名字。 i意味着我想要这样的东西 int a( ) { printf(" File =%s \ n",__ FILE__); / *我想打印来电者在这里命名。像这样的东西 printf(" Caller function =%s \ n",__ CALLER_FUN__);它应该打印 b * / 返回0; } int b() { a(); 返回0; } int main() { b(); } 如果有任何方法请告诉我。
你需要了解你的系统架构,装配, 编译器非常好。 以这样一种方式写一个逻辑,你可以尝试解析生成的汇编文件并了解 $调用它的b $ b函数。 在M68K的情况下,在''b''函数中会有类似 JSR _a的内容。 Karthik Balaguru
10月17日下午3:56,harshal< harshalsh ... @ gmailwrote: 大家好, 我们可以读取当前进程的堆栈帧吗。 as我们知道每当在c函数中进行函数调用时 堆栈框架 被创建并推送到堆栈。当函数返回 时,它会从堆栈中弹出。我想知道来电者的功能 名字。 i意味着我想要这样的东西 int a( ) { printf(" File =%s \ n",__ FILE__); / *我想打印来电者在这里命名。像这样的东西 printf(" Caller function =%s \ n",__ CALLER_FUN__);它应该打印 b * / 返回0; } int b() { a(); 返回0; } int main() { b(); } 如果有任何方法请告诉我。
您可以根据Linker创建的MAP文件编写一些方法,并且 也使用汇编列表。 Karthik Balaguru
karthikbalaguru写道: 10月17日下午3:56,harshal< harshalsh ... @ gmailwrote: >大家好, 我们可以读取当前进程的堆栈帧吗?
....
您可以根据MAP文件编写一些方法由Linker创建, 也使用汇编列表。我认为任何有能力这样做的人都不太可能需要 发布问题......
Hi all, Can we read the stack frame''s of the current process. as we know that whenever a function call is made in c new functions stack frame is created and pushed on to the stack. and when the function returns it is popped out from the stack. i want to know the caller functions name. i mean i want something like this int a() { printf("File = %s\n",__FILE__); /* i want to print the callers name over here. something like this printf("Caller function = %s\n",__CALLER_FUN__); it should print b*/ return 0; } int b() { a(); return 0; } int main() { b(); } if there is any way please tell me. Thanks and Regards Harshal Shete
解决方案 On Oct 17, 3:56 pm, harshal <harshalsh...@gmailwrote: Hi all, Can we read the stack frame''s of the current process. as we know that whenever a function call is made in c new functions stack frame is created and pushed on to the stack. and when the function returns it is popped out from the stack. i want to know the caller functions name. i mean i want something like this int a() { printf("File = %s\n",__FILE__); /* i want to print the callers name over here. something like this printf("Caller function = %s\n",__CALLER_FUN__); it should print b*/ return 0; } int b() { a(); return 0; } int main() { b(); } if there is any way please tell me.You need to understand the architecture of your system, assembly, compiler very well. Write a logic in such a way that, you try parsing throught the generated assembly file and get to know the function that is calling it. In the case of M68K there will be something like JSR _a inside ''b'' function. Karthik Balaguru
On Oct 17, 3:56 pm, harshal <harshalsh...@gmailwrote: Hi all, Can we read the stack frame''s of the current process. as we know that whenever a function call is made in c new functions stack frame is created and pushed on to the stack. and when the function returns it is popped out from the stack. i want to know the caller functions name. i mean i want something like this int a() { printf("File = %s\n",__FILE__); /* i want to print the callers name over here. something like this printf("Caller function = %s\n",__CALLER_FUN__); it should print b*/ return 0; } int b() { a(); return 0; } int main() { b(); } if there is any way please tell me.You can write some methods based on the MAP file created by Linker and also using the assembly listing. Karthik Balaguru
karthikbalaguru wrote: On Oct 17, 3:56 pm, harshal <harshalsh...@gmailwrote: >Hi all,Can we read the stack frame''s of the current process.
....
You can write some methods based on the MAP file created by Linker and also using the assembly listing.I think it''s unlikely that anyone capable of doing this would need to post the question...
更多推荐
如何读取运行进程的堆栈帧?
发布评论