<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/developer/tools-software/oss-platforms/f/gnu-toolchain-forum/47694/arm-none-eabi-gcc-unable-to-see-local-variables-in-modeldebugger</link><description> Hi, 
 When I load a simple C target binary built with arm-non-eabi tool chain loaded on the ARmCortex-M7 Fast Model in the fast Models framework it fails to show the local variables complaining &amp;quot;??? (can&amp;#39;t read from memory from 0xFFFFFFFFFFFFFFF4 (size</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/thread/168891?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2020 01:06:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1092c479-7194-4677-9108-9a28ee6424a4</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/474/1680._5F00_Verify_2D00_answer_2D00_nordic_5F00_2.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/thread/168889?ContentTypeID=1</link><pubDate>Mon, 30 Nov 2020 21:29:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e979ba9d-8f34-4e4d-8a85-2305ce8e96b1</guid><dc:creator>CDAMP</dc:creator><description>&lt;p&gt;I found a resolution to this - finally.&lt;/p&gt;
&lt;p&gt;The model debugger successfully shows the local variables when target is built with DWARF2 debugging format, so building the target code with -gwarf-2 option fixed the issue. The default format of debugging info, I believe stabs does not work&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/thread/167663?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 14:30:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:85985ad3-bf3c-4ac9-8983-394465f3378c</guid><dc:creator>CDAMP</dc:creator><description>&lt;p&gt;Well, then there should be some way / hook to turn that so called optimization off to debug embedded code, shouldn&amp;#39;t it be&amp;nbsp; - like the compiler writers do not know that - I do not believe it. Do u know how to get around it if you think that is the reason&amp;nbsp; ? There is an option -Og that tells the compiler to &amp;quot;optimize&amp;quot; code that is debugger friendly, have not tried it, but am 99% skeptical it won&amp;#39;t work. Will check that out. On the same lines - and to your point - I plan to build it with armcc when I get the cycles to do so and update my findings&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/thread/167647?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 08:23:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ad3e4b83-6920-434f-9b7d-efb544870b34</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;I&amp;#39;d still say that&amp;#39;s likely down to &amp;quot;optimisation&amp;quot;.&lt;/p&gt;
&lt;p&gt;eg, the compiler has not put those things in memory - just in registers.&lt;/p&gt;
&lt;p&gt;The compiler is not obliged to generate &amp;quot;useless&amp;quot; code - even if &amp;quot;optimisation&amp;quot; is turned off.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/thread/167641?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 02:26:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:048b73a5-c9c0-400f-aa35-24bcbacd391a</guid><dc:creator>CDAMP</dc:creator><description>&lt;p&gt;Investigating further I don&amp;#39;t think the linker script has an issue, even when I had a .stack region allocated the issue persisted.&lt;/p&gt;
&lt;p&gt;Within the main() if I declare a variable as static then again the debugger sees it at run time. So my best educated guess is that the debugger cannot resolve the symbols that are in automatic scope, for some reason. Not tried looking into the different debug formats (stabs, dwarf etc.) which one do ARM native tools work with seamlessly.&lt;/p&gt;
&lt;p&gt;For now I can workaround with debugging declaring variables in global scope or static if in local scope and once all is good revert them as automatic variables in local scope and move on. Would like to get a resolution to the issue -if someone can enlighten me&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/thread/167640?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 23:04:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1c1bb65e-0917-44e9-8520-8623b758207b</guid><dc:creator>CDAMP</dc:creator><description>&lt;p&gt;Hi Andy,&lt;/p&gt;
&lt;p&gt;Also, I notice that if I declare the program variables in global scope i.e. declare/define&amp;nbsp;dmaSrcStartAddr, blockSize etc before main() then the debugger sees it just fine; since as expected the memory allocation of these is set at compile time and the exact address where they get allocated is easily seen from the linker map file.&lt;/p&gt;
&lt;p&gt;So, basically the issue occurs for local&amp;nbsp;variables in the main() that get allocated on the stack - for some reason the debugger cannot see it - I can infer it from the register contents but that&amp;#39;s very tedious and error prone when stepping through the&amp;nbsp; C code.&lt;/p&gt;
&lt;p&gt;Suspect this has to do with stack area allocation ? My linker script is as follows, I do not have explicit .stack section in it:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;SECTIONS
{
    .  = 0x0;         /* From 0x00000000 */

    .text : 
    {
        *(vectors)    /* Vector table */
        *(.text)      /* Program code */
    }
    .rodata : 
    {
        *(.rodata)    /* Read only data */
    }

    .  = 0x00002000;  /* From 0x0002000 */      
    .data :
    {
        *(.data)      /* Stack memory */
    }

    .  = 0x00008000;  /* From 0x0008000 */      

    _BSS_START = .;   /* Indicates where BSS section starts in RAM */
    .bss :
    {
        *(.bss)       /* Zero-filled run time allocate data memory */
    }
    _BSS_END = .;     /* Indicates where BSS section ends in RAM */
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/thread/167637?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 18:34:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:186577fe-bfc4-491c-90b1-725f9da17c44</guid><dc:creator>CDAMP</dc:creator><description>&lt;p&gt;Thanks, Andy for the response !&lt;/p&gt;
&lt;p&gt;I have disabled - or so I think- optimization via option -O0 (as in letter &amp;#39;O&amp;#39;zero) and that does not make any difference.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the initialization in my main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;typedef volatile unsigned int * memaddr_t;

#define RAM_DMA_BLOCK_SIZE		1024
#define RAM_DMA_BLOCK_SRC 		0x00000200
#define RAM_DMA_BLOCK_DST 		0x00001300

void
__main(void)
{
    memaddr_t dmaSrcStartAddr = ((memaddr_t) RAM_DMA_BLOCK_SRC);
	memaddr_t dmaDstStartAddr = ((memaddr_t) RAM_DMA_BLOCK_DST);
	unsigned int blockSize = RAM_DMA_BLOCK_SIZE;
	
	for (int i = 0; i &amp;lt; blockSize; i++)
	{
		*dmaSrcStartAddr = 0xa5a5a5a5;
		*dmaDstStartAddr = 0x0;
		dmaSrcStartAddr++;
		dmaDstStartAddr++;
	}
	
	unsigned int foo = 0x11;
	foo++;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now when I run the code in the modeldebugger , step into main, the debugger cannot resolve teh contents of the local variables as shown in my screen-shot. It sees the local variables, but is unable to access the corresponding memory.&lt;/p&gt;
&lt;p&gt;I see identical behavior on Windows &amp;amp; Linux platforms. Was thinking if using arm tools (arm compiler toolchain) rather than gnu one would help, but its not so trivial to port even a simple target&amp;nbsp; from arm-none-eabi-gcc toolchain to a newbuild environment; looking into it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: arm-none-eabi-gcc : unable to see local variables in modeldebugger</title><link>https://community.arm.com/thread/167620?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 08:28:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5bd698cf-c23e-4614-abbd-2405444a852c</guid><dc:creator>Andy Neil</dc:creator><description>[quote userid="68067" url="~/developer/tools-software/oss-platforms/f/gnu-toolchain-forum/47694/arm-none-eabi-gcc-unable-to-see-local-variables-in-modeldebugger"]a simple C target binary[/quote]
&lt;p&gt;The trouble with trivial code is that it is highly likely to get optimised away ...&lt;/p&gt;
&lt;p&gt;Perhaps show the code in question?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/474/0804._5F00_Insert-Code-_2D00_-Nordic-2.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>