[英]how to log threadwise stack of multithreaded process in linux
I want to record stack information of each thread of processes to a txt file in linux. 我想将进程的每个线程的堆栈信息记录到Linux中的txt文件中。
I want to use 'C/C++' programming language. 我想使用“ C / C ++”编程语言。
If anyone can give me possible commands or any help please reply this question. 如果有人可以给我可能的命令或任何帮助,请回答此问题。
Make a thread wise log file and have all stdout
and stderr
output redirect in that log file ... maybe this will help you for that: In multi thread application how can i redirect stderr & stdout in separate file as per thread? 制作一个线程明智的日志文件,并将所有
stdout
和stderr
输出重定向到该日志文件中……也许这将为您提供帮助: 在多线程应用程序中,如何按线程将stderr&stdout重定向到单独的文件中?
Other simple way if you do not want to redirect stdout and stderr then write your own fprintf
function which will write all messages in Thread specific files. 如果您不想重定向stdout和stderr,则可以使用其他简单方法,然后编写自己的
fprintf
函数,该函数将所有消息写入线程特定文件中。 Here based on Thread_index or thread_number you can choose your File descriptrer and write messages in that. 在这里,基于Thread_index或thread_number,您可以选择文件描述符并在其中写入消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.