Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » DSDP - Real-Time Software Components (RTSC) » Generated code for object member of variable length structs(const keywork appears to be generated in the wrong place)
Generated code for object member of variable length structs [message #1763344] Fri, 12 May 2017 22:27 Go to next message
James Lockwood is currently offline James LockwoodFriend
Messages: 43
Registered: July 2009
Member
Hi,

I have recently run into a compiling issue since updating to the latest ARM GCC compiler (gcc-arm-non-eabi-6-2017-q1-update-win32 from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads).

Apparently this compiler is a little more strict in what it allows.

I have the following .xdc file:
import motion.interfaces.IAxisGroup;
import motion.interfaces.IAxis;
import xdc.runtime.Error;

module AxisGroup inherits IAxisGroup
{
    struct SlaveInfo_ {
        IAxis.Handle handle_IAxis;
        Bool haveAxisControl;
    }
    
    const UInt32 Version = 0;
	
instance:

    config IAxis.Handle master_IAxis = null;
    config SlaveInfo_ slaveInfo[length] = [];

internal:
    
    Void gearAllSlaveAxes(AxisGroup.Object *obj, Error.Block *eb);

	struct Instance_State {
        IAxis.Handle master_IAxis;
        SlaveInfo_ slaveInfo[length];
        Bool abortMotion;
        Bool updateMotionParameter;
        Bool hasControlOfSlaveAxes;
	}	
}


It appears that XDCTools generates a struct for variable-length object members in a way that makes that data immutable when it should not be.

The generated code looks like this in the AxisGroup.h:

typedef struct { int length; motion_groups_AxisGroup_SlaveInfo_ const *elem; } __ARRAY1_motion_groups_AxisGroup_Instance_State__slaveInfo;


what I believe should be generated is this:

typedef struct { int length; motion_groups_AxisGroup_SlaveInfo_ * const elem; } __ARRAY1_motion_groups_AxisGroup_Instance_State__slaveInfo;


Notice the difference in the placement of the "const" keyword.

The compiler error I get is "assignment of member 'haveAxisControl' in read-only object"

This error didn't appear when compiling with an older compiler, which I assume is more relaxed in allowing this, or just doesn't check.

As a test, I changed the placement of the 'const' in the AxisGroup.h file, and ran the identical command to compile from a command line window, which was:

C:/Source/GCCARM~1/gcc-arm-none-eabi-6-2017-q1-update-win32/bin/arm-none-eabi-gcc -c -MD -MF package/lib/lib/debug/motion.groups/SourceCode/AxisGroup/AxisGroup.oem4FGCC.dep -x c -Dfar= -D__DYNAMIC_REENT__ -D_DEBUG_=1 -Dxdc_target_name__=M4FGCC -Dxdc_target_types__=trust/targets/gnu/arm/SourceCode/M4FGCC/std.h -Dxdc_bld__profile_debug -Dxdc_bld__vers_1_0_6_3_1 -g -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections -g -Wunused -Wunknown-pragmas -nostartfiles -IC:/Source/GCCARM~1/gcc-arm-none-eabi-6-2017-q1-update-win32/arm-none-eabi/include -I ../../ -I. -IC:/Prj/Portico/Tiva -IC:/Prj/Portico/Bootloader -IC:/Prj/Portico/TrustRepo -IC:/ti/uia_2_00_06_52/packages -IC:/ti/xdctools_3_50_01_12_core/packages -I../.. -o package/lib/lib/debug/motion.groups/SourceCode/AxisGroup/AxisGroup.oem4FGCC SourceCode/AxisGroup/AxisGroup.c
And it compiled just fine.

There are many more modules in packages we have created with variable length arrays in the Instance_State, which fail compiling in the exact same manner.

Switching back to the old compiler is a work-around we can live with for now, but I would like someone to evaluate this and fix if possible.

Thanks.
[edited the command line used to compile to reflect exactly what it was]

[Updated on: Fri, 12 May 2017 22:35]

Report message to a moderator

Re: Generated code for object member of variable length structs [message #1763346 is a reply to message #1763344] Fri, 12 May 2017 23:09 Go to previous messageGo to next message
James Lockwood is currently offline James LockwoodFriend
Messages: 43
Registered: July 2009
Member
I believe this is not a matter of the newer compiler discovering something new, but because I also upgraded to a newer XDCTools.

I am investigating, and will have a definitive answer soon as to what is causing this.
Re: Generated code for object member of variable length structs [message #1763347 is a reply to message #1763346] Sat, 13 May 2017 00:00 Go to previous messageGo to next message
James Lockwood is currently offline James LockwoodFriend
Messages: 43
Registered: July 2009
Member
XDCTools 3_32_00_06_core works fine. My problems are with XDCTools 3_50_01_12_core, and possibly others between these two. The .h files are generated differently between versions.

Perhaps this change was intentional such that variable length structs would live in FLASH (they do need to be pre-initialized), but I have several modules which use these to store values during run-time. I am sure I can change the modules I have written to work the way I want them to, if this is indeed the new intended behavior for XDCTOOLs.

I will now look at the generated .c configuration file for 3_50_01_12 to see if it points to a memory area which is constant to determine if this really is the intended behavior.
Re: Generated code for object member of variable length structs [message #1763348 is a reply to message #1763347] Sat, 13 May 2017 02:08 Go to previous messageGo to next message
James Lockwood is currently offline James LockwoodFriend
Messages: 43
Registered: July 2009
Member
From what I can see from the auto-generated configuration .c file, the variable length structure elements are in RAM. So this seems like the an new issue to me and not an intended changed behavior.
Re: Generated code for object member of variable length structs [message #1763496 is a reply to message #1763348] Tue, 16 May 2017 17:46 Go to previous messageGo to next message
Sasha Slijepcevic is currently offline Sasha SlijepcevicFriend
Messages: 115
Registered: July 2009
Senior Member
James,
we made a change in XDCtools 3.50, described in this bug report - https://bugs.eclipse.org/bugs/show_bug.cgi?id=506855. The fix works for our common usage of vector arrays as a module config parameters, which are immutable at runtime, but it breaks your use case, where a vector array is a member of an instance structure. It also breaks some other users' code, so we are already working on a solution. Unfortunately, there is no a quick workaround that would allow you to keep using XDCtools 3.50. Can you move back to 3.32 or there is something in 3.50 that you definitely need?

Now, for little bit more details:
In 3.32 vector array types were defined as
typedef struct { int length; <ElementType> *elem; } <VectorType>;

The problem there is that we can't force the actual array to be immutable with a const qualifier
const <VectorType> vector;
because constness doesn't propagate to the objects pointed to by the structure members. Only the pointer 'elem' and 'length' are now readonly, but not the underlying array.

So, we changed it to
typedef struct { int length; <ElementType> const * elem } <VectorType>;
and now you can't change the elements in the array which works for our use case, but not for yours.

We don't have a solution yet. We might need two different types that can be used in these two different use cases where the underlying array must stay constant and when it must not.

[Updated on: Tue, 06 June 2017 21:28]

Report message to a moderator

Re: Generated code for object member of variable length structs [message #1763517 is a reply to message #1763496] Wed, 17 May 2017 00:12 Go to previous messageGo to next message
James Lockwood is currently offline James LockwoodFriend
Messages: 43
Registered: July 2009
Member
We can just use the older version of XDCTools for now. No problems there.

Thanks for the response and explanation. Looking forward to the fix.
Re: Generated code for object member of variable length structs [message #1767039 is a reply to message #1763517] Thu, 29 June 2017 20:34 Go to previous messageGo to next message
Sasha Slijepcevic is currently offline Sasha SlijepcevicFriend
Messages: 115
Registered: July 2009
Senior Member
XDCtools 3.50.03, which should be out within a month, will have a fix for this bug -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=516749
Re: Generated code for object member of variable length structs [message #1772932 is a reply to message #1767039] Mon, 18 September 2017 22:19 Go to previous message
Sasha Slijepcevic is currently offline Sasha SlijepcevicFriend
Messages: 115
Registered: July 2009
Senior Member
It took a little bit longer than a month, but 3.50.03 is finally out - http://downloads.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/rtsc/3_50_03_33/index_FDS.html
Previous Topic:Instance Proxies
Next Topic:Using XDC with CCSv3.3
Goto Forum:
  


Current Time: Thu Mar 28 14:41:40 GMT 2024

Powered by FUDForum. Page generated in 0.02947 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top