Shop OBEX P1 Docs P2 Docs Learn Events
Easier way to get filesize info? — Parallax Forums

Easier way to get filesize info?

RaymanRayman Posts: 14,665
edited 2013-03-28 12:33 in Propeller 1
I'm finding it difficult to figure out the instructions here to determine the final filesize:
http://code.google.com/p/propgcc/wiki/PropGccMaps

Plus, I don't really want to install Perl...

Any chance you can come up with a simpler tool to figure this out?

Can't you tell anything by the size of the a.out file?

Somehow the loader figures out how many bytes to program using only a.out, right?
«1

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-22 18:49
    Rayman wrote: »
    I'm finding it difficult to figure out the instructions here to determine the final filesize:
    http://code.google.com/p/propgcc/wiki/PropGccMaps

    Plus, I don't really want to install Perl...

    Any chance you can come up with a simpler tool to figure this out?

    Can't you tell anything by the size of the a.out file?

    Somehow the loader figures out how many bytes to program using only a.out, right?
    You can use propeller-elf-objdump to find the size of each loadable section and add them up.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-22 19:08
    David Betz wrote: »
    You can use propeller-elf-objdump to find the size of each loadable section and add them up.
    Sorry, I guess my reply wasn't helpful. I hadn't looked at the link you included in your message. I guess that technique is already using propeller-elf-objdump so I guess you're looking for something that will give you the answer directly rather than requiring you to add up the sizes of each section. You can't just use the size of a.out or foo.elf since there is lots of symbol and line number information in those files in addition to the actual generated code. You can strip the object file and that will give you a better idea but it still isn't accurate. An .elf file is a fairly complicated data structure. It isn't just a linear image of the program like Spin binaries. If you really need this I can make a utility to distill the size from the .elf headers. I wrote the .elf file reading code that is part of propeller-load and p2load so I can use that to parse the headers and add up the sizes. Even then, it may not be just a single number. For instance, using the xmm-split memory model, the loader produces separate sets of data to load into SRAM and flash. Tell me what you want and I'll try to make a program to do it. This isn't really hard so don't worry about asking.
  • RaymanRayman Posts: 14,665
    edited 2013-03-22 19:12
    I've been running -objdump and seeing things like this:
    [FONT=Consolas][SIZE=1][FONT=Consolas][SIZE=1]Sections:
    
    1>  Idx Name          Size      VMA       LMA       File off  Algn
    
    1>    0 .boot         00000020  00000000  00000000  00000094  2**0
    
    1>                    CONTENTS, ALLOC, LOAD, READONLY, CODE
    
    1>    1 .lmmkernel    00000764  00000000  00000020  000000b4  2**2
    
    1>                    CONTENTS, ALLOC, LOAD, CODE
    
    1>    2 .init         00000074  00000784  00000784  00000818  2**2
    
    1>                    CONTENTS, ALLOC, LOAD, READONLY, CODE
    
    1>    3 .text         00001408  000007f8  000007f8  0000088c  2**2
    
    1>                    CONTENTS, ALLOC, LOAD, READONLY, CODE
    
    1>    4 .fini         00000030  00001c00  00001c00  00001c94  2**2
    
    1>                    CONTENTS, ALLOC, LOAD, READONLY, CODE
    
    1>    5 .hub          00000374  00001c30  00001c30  00001cc4  2**2
    
    1>                    CONTENTS, ALLOC, LOAD, CODE
    
    1>    6 .ctors        00000008  00001fa4  00001fa4  00002038  2**2
    
    1>                    CONTENTS, ALLOC, LOAD, CODE
    
    1>    7 .dtors        0000000c  00001fac  00001fac  00002040  2**2
    
    1>                    CONTENTS, ALLOC, LOAD, CODE
    
    1>    8 .bss          0000028c  00001fb8  00001fb8  0000204c  2**2
    
    1>                    ALLOC
    
    1>    9 .hub_heap     00000004  00002244  00002244  0000204c  2**0
    
    1>                    ALLOC
    
    1>   10 .debug_aranges 00000040  00000000  00000000  0000204c  2**0
    
    1>                    CONTENTS, READONLY, DEBUGGING
    
    1>   11 .debug_info   0000127b  00000000  00000000  0000208c  2**0
    
    1>                    CONTENTS, READONLY, DEBUGGING
    
    1>   12 .debug_abbrev 00000332  00000000  00000000  00003307  2**0
    
    1>                    CONTENTS, READONLY, DEBUGGING
    
    1>   13 .debug_line   00000232  00000000  00000000  00003639  2**0
    
    1>                    CONTENTS, READONLY, DEBUGGING
    
    1>   14 .debug_frame  00000064  00000000  00000000  0000386c  2**2
    
    1>                    CONTENTS, READONLY, DEBUGGING
    
    1>   15 .debug_str    00000014  00000000  00000000  000038d0  2**0
    
    1>                    CONTENTS, READONLY, DEBUGGING
    
    1>   16 .debug_loc    000015b0  00000000  00000000  000038e4  2**0
    
    1>                    CONTENTS, READONLY, DEBUGGING
    
    1>   17 .debug_ranges 00000178  00000000  00000000  00004e94  2**0
    
    1>                    CONTENTS, READONLY, DEBUGGING
    [/SIZE][/FONT][/SIZE][/FONT]
    

    Call me lazy, but I don't really want to sort through all that just to figure out if my code is too big or not...

    I like the way SimpleIDE gives you the size, but I want to use Visual Studio as my editor...
    So, I need a simple way to determine the sizes...
    It'd really be nice to get a report, the way that the Prop Tool does...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-22 19:17
    Rayman wrote: »
    I've been running -objdump and seeing things like this:
    1>    8 .bss          0000028c  00001fb8  00001fb8  0000204c  2**2
    
    1>                    ALLOC
    
    1>    9 .hub_heap     00000004  00002244  00002244  0000204c  2**0
    
    1>                    ALLOC
    
    1>   10 .debug_aranges 00000040  00000000  00000000  0000204c  2**0
    
    1>                    CONTENTS, READONLY, DEBUGGING
    
    

    Call me lazy, but I don't really want to sort through all that just to figure out if my code is too big or not...

    I like the way SimpleIDE gives you the size, but I want to use Visual Studio as my editor...
    So, I need a simple way to determine the sizes...
    It'd really be nice to get a report, the way that the Prop Tool does...
    If you're using LMM or CMM mode you can get a quick answer just by looking at the one line labeled ".hub_heap". This section is placed at the end of allocated memory as the start of the malloc heap. The second number (in this case 0x00002244) is the size of everything up to that point since the load starts at location 0 in hub memory. It's not a pretty way of figuring this out and it won't work in XMM modes but it should give you an accurate size in LMM or CMM modes.
  • RaymanRayman Posts: 14,665
    edited 2013-03-22 19:22
    That's a useful tip, thanks.

    BTW: I see you posted earlier while I was typing... Yes, I would like to ask for a command line tool to report memory usage,
    especially if it's not a lot of work for you.

    I feel like I'm on pretty solid ground with my Visual Studio IDE approach, except for this one thing...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-22 19:25
    Rayman wrote: »
    That's a useful tip, thanks.

    BTW: I see you posted earlier while I was typing... Yes, I would like to ask for a command line tool to report memory usage,
    especially if it's not a lot of work for you.

    I feel like I'm on pretty solid ground with my Visual Studio IDE approach, except for this one thing...
    Okay, I'll try to put that together tomorrow. As I said, I already have code to parse ELF files. It's just a matter of displaying the total sizes. The tool will need to display up to three different sizes: hub, SRAM, and flash. I guess I could skip any section that had zero size if you think it will be distracting to see all three every time. I'm thinking of something like this:
    hub: 0x00002244 (8772) bytes
    sram: 0x00000000 (0) bytes
    flash: 0x00000000 (0) bytes
    
    Does that seem okay to you?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-22 19:31
    David Betz wrote: »
    Okay, I'll try to put that together tomorrow. As I said, I already have code to parse ELF files. It's just a matter of displaying the total sizes. The tool will need to display up to three different sizes: hub, SRAM, and flash. I guess I could skip any section that had zero size if you think it will be distracting to see all three every time. I'm thinking of something like this:
    hub: 0x00002244 (8772) bytes
    sram: 0x00000000 (0) bytes
    flash: 0x00000000 (0) bytes
    
    Does that seem okay to you?
    I just noticed that there is another utility called propeller-elf-objsize that does pretty much what you want at least for LMM and CMM modes.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-22 19:33
    David Betz wrote: »
    I just noticed that there is another utility called propeller-elf-objsize that does pretty much what you want at least for LMM and CMM modes.
    Darn! I should think before I type! The program is called "propeller-elf-size". Sorry!
  • RaymanRayman Posts: 14,665
    edited 2013-03-22 19:51
    The instructions say this though:
     You could get a similar map by using the "propeller-elf-size -A" command, but unfortunately that command includes debug information in the totals.
    
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-03-22 19:56
    I like the way SimpleIDE gives you the size, but I want to use Visual Studio as my editor...

    Can you do that?

    Hmm - it appears you can http://msdn.microsoft.com/en-us/library/dd885242.aspx

    Very interesting idea, Rayman.

    So - could you add a menu item "compile" and it shells a command line program?
  • RaymanRayman Posts: 14,665
    edited 2013-03-22 20:01
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-23 04:42
    Rayman wrote: »
    The instructions say this though:
     You could get a similar map by using the "propeller-elf-size -A" command, but unfortunately that command includes debug information in the totals.
    
    I'm not sure why you'd want -A. I thought the idea was to get a more concise output. Just propeller-elf-size with no arguments gives you essentially a single line with the total not including any debug information. Isn't that what you were looking for? We still need another solution for the XMM modes though since all of the memory use gets lumped into a single number so you can't tell how much hub, ram, and flash are used separately.
  • RaymanRayman Posts: 14,665
    edited 2013-03-23 06:26
    Ok, that's not too bad...

    Here's the output:
    [FONT=Consolas][SIZE=1][FONT=Consolas][SIZE=1]1>------ Build started: Project: Hello_P1, Configuration: Debug Win32 ------
    1>     text	   data	    bss	    dec	    hex	filename
    1>     8120	      0	    656	   8776	   2248	a.out
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    [/SIZE][/FONT][/SIZE][/FONT]
    

    I guess you're saying that the "dec" number is the bytes of HUB RAM required for LMM and CMM codes.

    Still, this is a bit cryptic...

    I think it would be nice if we had a tool that gave more simplified details and also worked for XMM modes...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-23 06:33
    Rayman wrote: »
    Ok, that's not too bad...

    Here's the output:
    [FONT=Consolas][SIZE=1][FONT=Consolas][SIZE=1]1>------ Build started: Project: Hello_P1, Configuration: Debug Win32 ------
    1>     text	   data	    bss	    dec	    hex	filename
    1>     8120	      0	    656	   8776	   2248	a.out
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    [/SIZE][/FONT][/SIZE][/FONT]
    

    I guess you're saying that the "dec" number is the bytes of HUB RAM required for LMM and CMM codes.

    Still, this is a bit cryptic...

    I think it would be nice if we had a tool that gave more simplified details and also worked for XMM modes...
    "dec" is the value in decimal, "hex" is the value in hex. That wasn't entirely obvious to me at first glance.

    Anyway, I'll write another utility. I had started to do that and was trying to decide what name to use. That's when I noticed there was already a program called propeller-elf-size.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-23 07:04
    What would you like the output of this program to look like?
  • RaymanRayman Posts: 14,665
    edited 2013-03-23 10:25
    Well, for LMM and CMM, I think I'd like something like the Prop Too:

    Program: 20,000 bytes, Variable: 2,000 bytes, Stack/Free: (do some math here)

    For XMM and the like, I really don't know because I haven't done a lot of that yet (but am working up to it)......
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-23 10:38
    Rayman wrote: »
    Well, for LMM and CMM, I think I'd like something like the Prop Too:

    Program: 20,000 bytes, Variable: 2,000 bytes, Stack/Free: (do some math here)

    For XMM and the like, I really don't know because I haven't done a lot of that yet (but am working up to it)......
    Thanks for the suggestion. With the XMM modes it isn't really possible to say how much Stack/Free space there is because it depends on the configuration of the cache driver and that isn't known until load time.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-23 10:46
    Here is my first attempt. This is being run on the xmm-split version of fibo.
    david-betzs-macbook-pro:xmm dbetz$ propeller-elf-image-size fibo.elf
    hub:   1948 bytes
    ram:   1292 bytes
    flash: 12064 bytes
    
    This was written before I saw your suggestion of reporting program and variable space separately. Actually, it will be more like GCC to report "text", "data", and "bss".
  • RaymanRayman Posts: 14,665
    edited 2013-03-23 11:44
    looks good. seperate var and prog good for lmm and cmm though
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-23 12:43
    Rayman wrote: »
    looks good. seperate var and prog good for lmm and cmm though
    Actually, program vs. variables (code vs. data) applies to all of the memory sections. It is possible to put data in flash and it is possible to put code in hub memory. I guess that's why propeller-elf-size displays so much information. Memory layout in a GCC program isn't quite as simplistic as in Spin.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-28 05:26
    I just pushed the initial version of propeller-elf-image-size to the "p2test" branch on Google Code. This produces the output I described in an earlier message. I'll split "code" and "data" in a later version.
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 06:03
    I can't find it... Can you point me to the download page? Or post a Windows executable?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-28 07:31
    Rayman wrote: »
    I can't find it... Can you point me to the download page? Or post a Windows executable?
    It's in propgcc/loader and is built with the Makefile in that directory. It's only checked into the p2test branch. Source is in propgcc/loader/src.
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 08:29
    Ok, I see it in there. The date on the file is 19Mar13, so I thought it couldn't be there if it was added today...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-28 09:57
    Rayman wrote: »
    Ok, I see it in there. The date on the file is 19Mar13, so I thought it couldn't be there if it was added today...
    That's when I first wrote the code. I just pushed it to Google Code today. Sorry for the delay!
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 10:34
    David, Ok, appears you anticipated somebody asking for this then...

    BTW: When I downloaded the new version, I noticed this comment:

    "It also adds support for -e to write a bootable image to the P2 boot SPI flash"

    For what command is the -e option for?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-28 10:51
    Rayman wrote: »
    David, Ok, appears you anticipated somebody asking for this then...

    BTW: When I downloaded the new version, I noticed this comment:

    "It also adds support for -e to write a bootable image to the P2 boot SPI flash"

    For what command is the -e option for?
    propeller-load
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 11:04
    Wait a minute... I thought I had it but, I don't...

    I was looking at propeller-elf-size instead of propeller-elf-image-size ...

    After reading your post again, are you saying there is no Windows executable to download, just GCC source code?
    Any chance you could provide a Windows executable?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-28 11:06
    Rayman wrote: »
    Wait a minute... I thought I had it but, I don't...

    I was looking at propeller-elf-size instead of propeller-elf-image-size ...

    After reading your post again, are you saying there is no Windows executable to download, just GCC source code?
    Any chance you could provide a Windows executable?
    Yes, I can make one but not until later this evening. Sorry!

    propeller-elf-size is a standard utility from binutils.
  • RaymanRayman Posts: 14,665
    edited 2013-03-28 12:30
    Does the new (19Mar13) PropGCC include all the P2 preview stuff?
    I.e., should I be using that instead?
Sign In or Register to comment.