Recent

Author Topic: is it possible to read avr debug info with lazarus?  (Read 2162 times)

Michael Collier

  • Sr. Member
  • ****
  • Posts: 301
is it possible to read avr debug info with lazarus?
« on: July 16, 2017, 05:26:53 pm »
Is it possible to read debug information generated by gcc for an Atmel AVR device using FPC/Lazarus library or component?

I'm able to read binary file my_file.bin into lazarus, and them emulate the instructions in a simple gui.

It would be great to be able to match the my_file.c source code to the instructions.

I found info on generating debug info here:
from gcc
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
from Atmel
http://www.atmel.com/webdoc/atmelstudio/atmelstudio.sectionObjectFileForDebugging_SupportedDebugFormats.html

They both mention DWARF2 so I guess that is the way to go?
add to compiler options -gdwarf-2 and get the output from *.elf

I can examine the elf file from the command line using this
readelf.exe that ships with gcc but this is where I need more help..

Am I correct in assuming that generating DWARF2 via -gdwarf2 option and reading the .elf file will get the info I need to "connect" my source file to my binary file?

And if so, how do I go about reading the elf file from lazarus?

Or, maybe I'm going down the wrong path and there is another way?

Thanks


 



 

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: is it possible to read avr debug info with lazarus?
« Reply #1 on: July 16, 2017, 06:02:51 pm »
Yes, It should.

Basically lazarus is using gdb to read the debug info.

gdb understands dwarf (2 and some of the above) / in the end people using gcc also use gdb to debug.

So lazarus will be able to see some of the info.

- line numbers should be fine.
- simple types (int / bool) should be fine too.
- records and object may or may not work. The IDE tries to work around gdb problems with pascal structures, and that may affect how c structures are queried.

You may need some kind of dummy project. So Lazarus knows where to look for sources.

It doesn't need to compile. You can start the exe outside Lazarus, and then use attach to connect.



Michael Collier

  • Sr. Member
  • ****
  • Posts: 301
Re: is it possible to read avr debug info with lazarus?
« Reply #2 on: July 16, 2017, 06:38:59 pm »
Thanks Martin,

I searched my lazarus directory for files containing the keyword elf

I found fpdebug directory that has package fpdebug.lpk containing elf related objects ( TElfFile , TElfSection).

What I mean by reading elf info using lazarus is to use lazarus/fpc components or libraries (in my own application) rather than using the lazarus IDE itself. Sorry for any confusion there..

I'm not sure if the TElfFile , TElfSection are what I need or how to use them, I'm experimenting with them now, any help appreciated..




Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: is it possible to read avr debug info with lazarus?
« Reply #3 on: July 16, 2017, 07:06:11 pm »
FPDebug is an in progress work to replace gdb.

It includes a dwarf(2) reader. (incomplete though, and still with bugs...)
(line-info may fail, if inlined code exists or generics)

It can open linux elf, I guess that should include your avr elf. (Not sure about external debug info)

There is also the lineinfo and infodwrf (or similar) units in fpc, which can read some of that info (but are generally slow)
The IDE uses those in "Leaks and Traces" (resolve button)

You have to test it yourself though.

 

TinyPortal © 2005-2018