Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I will try to provide all the required information step by step:</p> <p>Information 1 : The relevant code.</p> <pre><code>//Step 1: Create msg and fill message Id MsgBase*msgPtr = new Der1(); // C'tor of Der1 is as follows: Der1::Der1 () : MsgBase ( ATS_SUTD_EPCTESTER_ATTACH_SCENARIO_MsgId ), // msgid is 13( 0xd ) ueId ( IE_UE_KEY, "UE", false ), configFileName ( IE_CONFIG_FILE_NAME_KEY, "Configuration File Name", false ) { // Insert the IEs in the map this-&gt;addIEEntry ( IE_UE_KEY, &amp;ueId ); // this puts entries in the map this-&gt;addIEEntry ( IE_CONFIG_FILE_NAME_KEY, &amp;configFileName ); } // Step 2: Declare event and post the event Event* event = new Event ( eventId, "Event" ); event-&gt;setData( msgPtr, hdr); // check the message id at this stage ( cout &lt;&lt; "msgId = " &lt;&lt; ( ( (Der1* )msgPtr )-&gt;messageId )&lt;&lt; endl; // Here it comes out // to be 0xd which is correct // post the event AppClass::getInstance()-&gt;addEventAndSchedule ( event ); //The queue is a member of AppClass and has been defined as std::list &lt;EventBase* &gt; eventQueue; // The code which inserts data into the queue is as follows: bool AppClass::addEventAndSchedule ( EventBase* ev ) { if ( ev == NULL ) return false; this-&gt;eventQueueMutex.acquireLock(); this-&gt;eventQueue.push_back( ev ); this-&gt;eventQueueMutex.releaseLock(); // Submit Job to Scheduler bool status = JobScheduler::getInstance()-&gt;scheduleJob( this ); return status; } // The event class is class Event: public EventBase { public: Event (); virtual ~Event (); Event ( int evId ); Event ( int evId, string evName ); MsgBase* getMessagePtr (); void setData ( MsgBase* mPtr, Header* hPtr ) private: // Prevent copying Event&amp; operator= ( Event&amp; ev ); Event ( Event&amp; evBase ); MsgBase* msgPtr; Header* hdrPtr; }; void Event::setData ( MsgBase* mPtr, Header* hPtr ) { this-&gt;msgPtr = mPtr; this-&gt;hdrPtr = hPtr; } Step 3 : Extract the event and re-print the message Id // The code which extracts data from the queue is as follows: void AppClass::process () { EventBase* beventPtr = NULL; this-&gt;eventQueueMutex.acquireLock(); if ( !this-&gt;eventQueue.empty() ) { beventPtr = (EventBase* )( this-&gt;eventQueue.front() ); this-&gt;eventQueue.pop_front(); } else { isQueueEmpty = true; } this-&gt;eventQueueMutex.releaseLock(); Event* eventPtr = ( Event* )beventPtr ; Der1* msgPtr = (Der1* )( eventPtr-&gt;getMessagePtr()) ; cout &lt;&lt; "msgId = " &lt;&lt; msgPtr-&gt;messageId &lt;&lt; endl; // This value //comes out to be incorrect it is now 0xd000000 i.e. a 3 byte shift } </code></pre> <p>Information 2 : Exact problem. The exact problem is that the 'messasgeId' is getting changed in transition. Initially it is 0xd but after popping from the queue it becomes 0xd000000. Because of this all the processing stops. The address of this parameter also changes from 0x82bd7cc to 0x82bd7c9 when printed in the program. However when seen from gdb it is still 0x82bd7cc and the value is still 0xd.</p> <p>Information 3 : Compiler Flags. Compiler Flags are same for all the files and they are: -O0 -g3 -Wall -fmessage-length=0</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload