avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] jtag gdb linux


From: Bernd Trog
Subject: Re: [avr-gcc-list] jtag gdb linux
Date: Mon, 3 May 2004 09:54:13 -0700 (PDT)

On Mon, 3 May 2004, Joerg Wunsch wrote:

> honschu <address@hidden> wrote:
>
> [stack/data collision]

> > Howto solve?
>
> Buy properly design your code.  By evaluating the amount of local data
> + stack framing you need (which arguably can be a lot of work).
  
It is a lot of work, if you do this *manually*.

If you do it like this...

------------------------------------------------------------------------
$ stacktool  -mmcu=atmega16 -p demo_1.elf

this analysis will be context sensitive
origin is 0
ignoring jump to 0x0
stack ptr initialized to expected value 45f
stack ptr initialized to expected value 45f
analysis pass 1:  137 control flow steps, 152 abstract interp steps

branches that are dead in all contexts:
  0x0074 -> 0x006c

stores:
  st found at location 7e -- potentially unsafe

worst-case stack depth requirements for individual entry points,
ignoring the possibility of self-stacking interrupts:
  vector  0 RESET = 14, at 10a
  vector 32 TIMER1_OVF = 8, at 9c

total stack requirement from naive summation = 24
stack analysis steps = 303

total stack requirement from global analysis = 22
stack analysis steps = 792

memory map summary:
  data+BSS is at addresses 0x60-0x63
  stack (potentially) occupies addresses 0x449-0x45f
  there are 0x3e6 (998) bytes left in the middle (for heap or whatever)
  system seems safe!

  MAXPATH __vector_8 = 22
  MAXPATH [vec08] = 16
  MAXPATH foo = 14
  MAXPATH main = 2
  MAXPATH .do_clear_bss_start = 0
  MAXPATH __do_clear_bss = 0
  MAXPATH .do_copy_data_start = 0
  MAXPATH __do_copy_data = 0
  MAXPATH __ctors_end = 0
  MAXPATH [vec00] = 0

111 total insns: 107 known int masks, 4 unknown
3.60% insns w/ indeterminate int mask
1807 known bits in 109 states; average of 16.577982
there are 264 bits in a machine state
6.28% of bits are known, overall
29.47% of SREG bits are known, overall

*** normal termination ***
------------------------------------------------------------------------

... you hopefuly do the stack analysis more often ;-)



Recommended reading:

http://www.cs.utah.edu/flux/papers/emsoft03/emsoft03-preprint.pdf :
  
An interesting excerpt:
...
For example, consider a hypothetical embedded system where the maximum
stack depth occurs when the following events occur at almost the same
time: 1) the main program summarizes data once a second spending 100
microseconds 2 at maximum stack depth; 2) a timer interrupt fires 100
times a second spending 100 microseconds at maximum stack depth; and 3) a
packet arrives on a network interface up to 10 times a second; the handler
spends 100 microseconds at maximum stack depth. If these events occur
independently of each other, then the worst case will occur roughly once
every 10 years. This means that the worst case will probably not be
discovered during testing, but will probably occur in the real world where
there may be many instances of the embedded system.
... 


John Regehr's Stack Bounding Page / alpha-quality snapshot of the stacktool:

http://www.cs.utah.edu/~regehr/stacktool/ 






        
                
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]