This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320VC5502: Is there a TConf requirement to use <strstream> objects?

Part Number: TMS320VC5502

Tool/software:

I am trying to set up for the first time an ostrstream object, but it crashes the firmware to UTL_halt() when written to.

e.g. g_diagLog << "Hello World" << endl

class CDiagLog : public ostrstream
{
public:
    CDiagLog (char buffer[], unsigned int size);

private:
};

#pragma DATA_SECTION("ExtPgm3")
char m_logBuffer[1024] = { 0 };

#pragma DATA_SECTION("ExtPgm3")
CDiagLog g_diagLog(m_logBuffer, sizeof(m_logBuffer));

CDiagLog::CDiagLog (char buffer[], unsigned int size)
{
    memset(buffer, 0, size);
}

When I trace the program execution it follows this path (with content of some of the CPU registers given at entry to the given function):

std::basic_ostream

  sputn (ptr, count) -- XAR0: 0x04A044, T0: 0x0014

  xsputn (ptr, count) -- XAR0: 0x04a044, T0: 0x0014

std::strstreambuf:overflow (int) -- T0:0x0046

operator new[] -- T0:0x0020

operator new -- T0:0x0020

malloc() -- T0: 0x0020

MEM_alloc() -- T0: 0x0001, T1: 0x0024, T2: 0x0024

lock2() -- XAR0: 0x040000, XAR1: 0x020000, T0: 0x0001, T1: 0x0024, T2: 0x0001, T3: 0x0000

SYS_abort() -- XAR0 : 0x40000, XAR1: 0x20001

UTL_halt()

Is there something that needs to be set up in my .tcf (main.tcf) to support strstream objects?

Thanks.

  • Hi, 

    Our expert on this topic is currently out of office. We should be able to get a response sometime next week. 

    Thank you,

    -Randy

  • Hi Dean,

    The malloc() function does need system heap for dynamically allocate memory. The system heap is specified in the TCF file:

    Make sure "create a heap in this memory" is checked and the "heap size" is large enough.

    Best regards,

    Ming

  • Thanks Ming.  This resolved my issue.

    On a related note, (this is another question/issue with trying to set up a static buffer for diagnostic purposes that will be used independent of the debugger -- my other post last night focused on using printf, this one focuses on using ostrstream).  I posted this earlier yesterday, but didn't notice that there was an error when I posted it (some type of system error with the web page).  Here it is again.

    I'm trying to assign a static buffer to the ostrstream object using rdbuf() but a statement like

    g_diagLog << "Hello World" << endl;

    doesn't seem to use my m_logBuffer array.

    Is there something I need to do besides using rdbuf() to get stream data written to my static array?

    Note: I can dig into this further (I've not assigned an external buffer to an ostream before), but if there's a simple addition to what I'm doing as shown below, that would be great!

    Thanks,

    -dean

    class CDiagLog : public ostrstream
    {
    public:
        CDiagLog (char buffer[], unsigned int size);
    
    private:
    };
    
    #pragma DATA_SECTION("ExtPgm3")
    char m_logBuffer[1024] = { 0 };
    
    #pragma DATA_SECTION("ExtPgm3")
    CDiagLog g_diagLog(m_logBuffer, sizeof(m_logBuffer));
    
    CDiagLog::CDiagLog (char buffer[], unsigned int size)
    {
        memset(buffer, 0, size);
        this->rdbuf()->pubsetbuf(buffer, size);
    }
    
    
  • Hi Dean,

    Since this thread has been resolved, I will close this one. You can move the related content to the new thread.

    BTW, I have replied on the new thread you have posted yesterday.

    Best regards,

    Ming