Coder Social home page Coder Social logo

error_linenumber_location's Introduction

//*********************************************************************
//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! ^_^

error_linenumber_location's People

Watchers

kevin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.