kevin-shanghai / error_linenumber_location Goto Github PK
View Code? Open in Web Editor NEWThis program gives you an example to show how to locate the error line number when the program was crashed.
This program gives you an example to show how to locate the error line number when the program was crashed.
//********************************************************************* //Author: kevin.Fu //Email: [email protected] //Date: 2013/8/27 //********************************************************************* This program is about how to locate the error line number about the source code when the process was crashed. I think you must encountered your program was crashed but you can not locate the problem, at this time we want to know where the problem is especially the source code line number in order to make it work as soon as possible. This programe gives you answer, we use the standard api in linux such as "backtrace()" and "backtrace_sysmbols_fd()" to get the error message in stack when the program was crashed. When your program is static linked, problem was much more easy to deal, but if your programe use shared library, you must be careful, because the shared library dynamic linked, so the base address is easy changed. This programe give you an example to show how to locate the error line number of the programe, before you use run it, you must cp the share library libmyhello.so which is compiled from hello.c used command line: "gcc -g -fPIC -shared -o libmyhello.so hello.c", if you want to recompile the libmyhello.so, make sure you use this command line. There is a error in hello.c which located in line number 5:"p[2] = 'k'; run the program "a.out" with root previlege, you can get the output like this: "The pid is:4663 The .so name is:/usr/lib/libmyhello.so The Base address of the /usr/lib/libmyhello.so is:7f5dd0f4f000 The Stack Address is:0x7f5dd0f4f5c7 OffsetAddress:1479 The error line number is: /home/kevin/Work/Programing/C_Cpp/ErrorLocation/hello.c:5" You can change and trasport this programe without inform me. Just enjoy! ^_^
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.