Getting info to a log file

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using -finstrument-functions to log function entry/exit to a circular buffer that can be analyzed when a certain condition is detected.

 

My issue is that it is quite tedious to look up all the function address/offset (function & call site) for each call to see what the calling sequence was. 

 

What I would like to do is be able to somehow write the contents of a 2x15 array to a text file and then I can write a program to consume that and the symbol table to print out a 'human readable' calling sequence.

 

Or .. has this been done before by someone using finstrument-functions to profile code, etc. and thus there may be some tools available that do this or can be adapted?  Or possibly debugger scripting that I don't know about that would loop through the array and decode function addresses and offsets?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ChuckH wrote:
write the contents of a 2x15 array to a text file

Do you mean you want the target to do this, or the debugger/IDE to do it?

 

If the target is a small AVR, it might be easier to dump to the serial port, and capture that with something on a PC ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Easy" approach would be to add FatFs for an SD/MMC on the SPI  and just write to a file.

 

The "Instrument" stuff in GCC is obviously intended for a hosted OS where opening and writing files is trivial so you want something like that.

 

Alternatively use FDEV_SETUP_STREAM to set up a "file" that really streams data to a uart_putchar() and use that then capture the traffic in a PC terminal.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
use that then capture the traffic in a PC terminal.

Where a CSV comma separated values format is easy to capture and display in a SS.

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm reading two problems here:

1) log data to a file

2) decoding data from a file to generate function and/or line number info

 

For (2) the programs avr-nm and avr-objdump can extract a lot of information from the .elf file.  Maybe start with "avr-objdump --help".

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've been know to attach a bluetooth serial module to the UART in projects which aren't amenable to being tethered to a PC. Doesn't require any code changes; in fact it's completely invisible to the microcontroller.

 

ki0bk wrote:

clawson wrote:
use that then capture the traffic in a PC terminal.

Where a CSV comma separated values format is easy to capture and display in a SS.

Jim

 

 

Unless you're the British govt capturing covid infection statistics.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

obdevel wrote:
Unless you're the British govt capturing covid infection statistics.

What would you expect from NHS!

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

obdevel wrote:
Unless you're the British govt capturing covid infection statistics.

 

ki0bk wrote:
What would you expect from NHS!

 

I am going to issue just ONE warning.  The political/government derails are not going to be tolerated.

 

 

Jim - Moderator

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Wed. Oct 7, 2020 - 09:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ChuckH wrote:
Or possibly debugger scripting that I don't know about that would loop through the array and decode function addresses and offsets?
fyi, Python is likely with GDB.

Python (Debugging with GDB)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

re 2, addr2line given program counter values.

Toolchain Overview | AVR Libc

[mid-page]

avr-addr2line

Convert addresses to file and line.

 

addr2line (GNU Binary Utilities) due to Generating Unique Error Codes | The Embedded Muse 306 by Jack Ganssle

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
What would you expect from NHS

Just a technical point. It's an outsourced company run by an ex jockey (no really) who screwed statistics. Meanwhile NHS is a national treasure as far as 99.9% of Brits are concerned.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Cmon Cliff....

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
What would you expect from NHS!

Here's a write-up on this from The DailyWTF https://thedailywtf.com/articles/excellent-data-gathering The comments are worth reading also.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Guys, back on track please! NHS discussions can go somewhere else wink

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.