Very cool! This looks like it gets me 99% of the way to what I was looking
for. By running it with the -c option and a little awk, it's easy to get
the maximum stack depth (main + largest ISR).


carlson@gerty:~/tinyos-2.x/apps/Blink$ ruby stkchk/prog/stack_anal.rb -f
telosb.lst -c | tr ':/()' ' '   | awk 'BEGIN{}
  ($2 ~/^main$/){
    mainDepth=$4
  }
  ($2 ~/VECTOR$/ && $4 > isrDepth){
    isrFunc=$2;
    isrDepth=$4
  }
  END{
    print mainDepth+isrDepth, "(",isrFunc,")"
  }'

94 ( sig_TIMERB1_VECTOR )


Haven't played around with the recursion/indirect function calls yet, but
this looks great.

Thanks for sharing it.
-Doug

On Fri, Apr 20, 2012 at 11:08 AM, R Develop <rdeve...@gmail.com> wrote:

>
> Date: Thu, 19 Apr 2012 08:37:00 -0400
>> From: Doug Carlson <carl...@cs.jhu.edu>
>> Subject: [Mspgcc-users] Reserving stack space at compile time?
>> To: mspgcc-users@lists.sourceforge.net
>> Message-ID:
>>        <
>> cadrink_icog8vlrwspc50at-eknztfcpbxstdvpertgea3c...@mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>>
>> Howdy.
>> I recently ran into an issue with my program stack growing into the
>> statically-allocated variables in the .bss section due to some
>> overenthusiastic use of printf's. Looking through the archives, I found
>> this
>> discussion<
>> http://www.mail-archive.com/mspgcc-users@lists.sourceforge.net/msg10178.html
>> >
>> regarding
>> general stack protection techniques.
>>
>> Two questions, which may be more general gcc/ld-related than msp-specific
>>
>> 1. While it's impossible in the general case to determine the maximum
>> stack
>> size that a program will use, is there any mspgcc setting (or standalone
>> tool) that can handle the simple cases that dominate in MCUs (no
>> recursion,
>> no function pointers, no nested ISRs) and spit out a maximum stack depth?
>>
>>
> Hi,   I had earlier written a stack analysis tool for mspgcc compiled
> programs for my own use.
> I put it up on google code for anyone to download and use.
>
> The link is http://code.google.com/p/stkchk/
>
> What can it do?
> Analyze the call tree of a program and report the stack usage of a
> function (by default "main") and its children.
> Distinguish between direct function calls and indirect function calls (via
> function pointers).
> Indirect calls can be resolved if the user provides addition information
> on the command line.
> Detect recursion both direct (f() -> f()) and indirect (f()-> g()->f()),
> and report it.
>
> Thanks
> RJ
>
>
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to