This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
Re: Some weirdnes with the tools
- To: <bob dot koninckx at mail dot mech dot kuleuven dot ac dot be>
- Subject: [ECOS] Re: Some weirdnes with the tools
- From: Jesper Skov <jskov at cygnus dot co dot uk>
- Date: Mon, 18 Oct 1999 14:13:53 +0200 (CEST)
- Cc: ecos-discuss at sourceware dot cygnus dot com
- References: <000501bf195d$2c576080$56183a86@pc086-2.mech.kuleuven.ac.be>
If I'm not mistaken (and I may very well be) the problem is caused
because you use a 'new' operator without defining it. I think it calls
malloc() and throws an exception if the allocation fails. Remember
that C++ exceptions are not handled when you use the default compiler
arguments.
Anyway, this is beyond me. I'm not the biggest C++ hacker there ever
was, I must admit. You should have asked on the list directly where
you would be more likely to get a correct answer.
Jesper
--------------------
Hi Jesper,
This WE, I came accross something I really do not understand. I am working
on a package implementing the CANopen protocol. I am writing this in C++.
It contains something like this :
class CommunicationObject
{ ...
public:
virtual ~CommunicationObject();
virtual void create(void) = 0;
virtual void destroy(void) = 0;
};
class TxCOB : public CommunicationObject
{ ...
public:
virtual ~TxCOB();
virtual void create(void);
virtual void destroy(void);
};
class RxCOB : public CommunicationObject
{ ...
public:
virtual ~RxCOB();
virtual void create();
virtual void destroy(void);
};
template <class Type>
class CMS_Variable
{
....
protected:
CommunicationObject * m_cob;
};
template <class Type>
class CMS_ServerVar : public CMS_Variable<Type>
{
public:
CMS_ServerVar()
{
m_cob = new TxCOB();
m_cob->create();
}
};
template <class Type>
class CMS_ClientVar : public CMS_Variable<Type>
{
public:
CMS_ServerVar()
{
m_cob = new RxCOB();
m_cob->create();
}
};
typedef CMS_ServerVar<int> CMS_IntServerVar;
typedef CMS_ClientVar<int> CMS_IntClientVar;
It compiles and links fine, no problem there.
The strange thing is when I use it from the application that is linked
against the ECOS library.
An application like
main()
{
CMS_IntServerVar server();
CMS_IntClientVar client();
return 0;
}
Crashes on the call to m_cob->create(). When I look at the v-table of both
TxCOB and RxCOB, it is partially filled with zeros. (the create function is
a zero, the destroy is not)
If I rewrite the application as follows
main()
{
TxCOB txcob();
CommunicationObject * cob = &txcob;
cob->create()
CMS_IntServerVar server();
CMS_IntClientVar client();
return 0;
}
everything goes fine and the v-tables of both TxCOB and RxCOB are filled in
correctly.
It looks like only classes that are explicitly instantiated outside the ECOS
library have correctly filled in v-tables (although that doesn't make much
sense to me).
Have you ever come accross something like this ?? Or am I doing something
wrong ?? What section are the v-tables stored in anyway (looks like they are
in .rodata, I am not sure though) I use the EcosSWTools that I downloaded
from the web (with the Redhat 6.0 patch)
If you don't know an answer, can you post this on the appropriate discussion
forum please.
Regards,
Bob
------------------------------------------------------------------------
ir. Bob Koninckx
Katholieke Universiteit Leuven
Division Production Engineering, tel. +32 16 322535
Machine Design and Automation fax. +32 16 322987
Celestijnenlaan 300B bob.koninckx@mech.kuleuven.ac.be
B-3001 Leuven Belgium http://www.mech.kuleuven.ac.be/pma.html
------------------------------------------------------------------------