0

Our Android application has lot of code written in C/C++ and whenever a crash is reported from production users we get to know the callstack along with the registers state at the time of crash. When the crash doesn't look so evident, registers state and assembly code of crashed functions will be helpful to some extent.

We pack stripped version of libraries into application and we keep unstripped libraries with us so that whenever crash is reported we get to know file and line numbers with help of unstripped libraries (using tools llvm-addr2line, llvm-objdump, llvm-readelf...)

Today we have to manually run llvm-objdump on each symbol against unstripped library to read into symbol's assembly code.

However, to improve developer productivity, we are planning to develop an application for which if we give filename as input the application prints assembly code for all of input file.

Is it possible to print assembly code so

i.e. given a source code file and unstripped library, is it possible to map and print source code and corresponding assembly code?

Similar to godbolt where we can see source code on left pane and corresponding assembly code on right pane.

Thanks.

Pendyala
  • 585
  • 1
  • 6
  • 17
  • 1
    Why not just install compiler explorer locally? You can add your own toolchain and point at your project headers. – Stephen Newell Sep 01 '22 at 16:57
  • `run llvm-objdump on each symbol` - I'd be surprised if it didn't have an option to dump the entire module in one go. – 500 - Internal Server Error Sep 01 '22 at 17:00
  • IMHO, you should compile in only C++. The C++ language can accept a lot of the C language. Thus you would not need the non-existent language of C/C++. Remember, compilers may use *name-mangling* in C++ to make symbols compatible with C (this is one reason use both C and C++ complicates development). – Thomas Matthews Sep 01 '22 at 17:00
  • 1
    Many compilers have an option to print mixed source code and assembly; that is they will print a source code statement, followed by the assembly language for that statement. You'll have to check your compiler configuration options. The IAR Electronic Workbench IDE that I am using has this option. – Thomas Matthews Sep 01 '22 at 17:02
  • You can run objdump with the option `-S` option and it will interleave assembly and the source code. Note that optimizations and inlining can mess up the mapping quite extensively. – Something Something Sep 01 '22 at 17:02
  • @StephenNewell, makes sense. I will explore this option. But if it is required to pass compiler options as well, then that is not what I am expecting. All we have are source files and unstripped library and we dont have what compilation/linker flags are passed while building the library. – Pendyala Sep 01 '22 at 17:03

0 Answers0