Skip to content

Commit

Permalink
The error module now uses thread-local storage
Browse files Browse the repository at this point in the history
- Any spawned thread will have its own error-messages
- It is not yet possible to push errors from one thread onto another


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17227 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Sep 13, 2013
1 parent b987e65 commit a3c9c53
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 147 deletions.
36 changes: 16 additions & 20 deletions Compiler/runtime/Error_omc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,15 @@ extern "C" {
void Error_addMessage(int errorID, void *msg_type, void *severity, const char* message, modelica_metatype tokenlst)
{
ErrorMessage::TokenList tokens;
if (error_on) {
while(MMC_GETHDR(tokenlst) != MMC_NILHDR) {
const char* token = MMC_STRINGDATA(MMC_CAR(tokenlst));
tokens.push_back(string(token));
tokenlst=MMC_CDR(tokenlst);
}
add_message(errorID,
(ErrorType) (MMC_HDRCTOR(MMC_GETHDR(msg_type))-Error__SYNTAX_3dBOX0),
(ErrorLevel) (MMC_HDRCTOR(MMC_GETHDR(severity))-Error__ERROR_3dBOX0),
message,tokens);
while (MMC_GETHDR(tokenlst) != MMC_NILHDR) {
const char* token = MMC_STRINGDATA(MMC_CAR(tokenlst));
tokens.push_back(string(token));
tokenlst=MMC_CDR(tokenlst);
}
add_message(errorID,
(ErrorType) (MMC_HDRCTOR(MMC_GETHDR(msg_type))-Error__SYNTAX_3dBOX0),
(ErrorLevel) (MMC_HDRCTOR(MMC_GETHDR(severity))-Error__ERROR_3dBOX0),
message,tokens);
}

extern void* Error_getMessages()
Expand All @@ -80,21 +78,19 @@ extern const char* Error_printMessagesStr()
extern void Error_addSourceMessage(int _id, void *msg_type, void *severity, int _sline, int _scol, int _eline, int _ecol, int _read_only, const char* _filename, const char* _msg, void* tokenlst)
{
ErrorMessage::TokenList tokens;
if (error_on) {
while(MMC_GETHDR(tokenlst) != MMC_NILHDR) {
tokens.push_back(string(MMC_STRINGDATA(MMC_CAR(tokenlst))));
tokenlst=MMC_CDR(tokenlst);
}
add_source_message(_id,
(ErrorType) (MMC_HDRCTOR(MMC_GETHDR(msg_type))-Error__SYNTAX_3dBOX0),
(ErrorLevel) (MMC_HDRCTOR(MMC_GETHDR(severity))-Error__ERROR_3dBOX0),
_msg,tokens,_sline,_scol,_eline,_ecol,_read_only,_filename);
while(MMC_GETHDR(tokenlst) != MMC_NILHDR) {
tokens.push_back(string(MMC_STRINGDATA(MMC_CAR(tokenlst))));
tokenlst=MMC_CDR(tokenlst);
}
add_source_message(_id,
(ErrorType) (MMC_HDRCTOR(MMC_GETHDR(msg_type))-Error__SYNTAX_3dBOX0),
(ErrorLevel) (MMC_HDRCTOR(MMC_GETHDR(severity))-Error__ERROR_3dBOX0),
_msg,tokens,_sline,_scol,_eline,_ecol,_read_only,_filename);
}

extern int Error_getNumMessages()
{
return errorMessageQueue.size();
return getMembers()->errorMessageQueue->size();
}

void Error_setShowErrorMessages(int *show)
Expand Down
44 changes: 9 additions & 35 deletions Compiler/runtime/Error_rml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ extern "C" {

void ErrorExt_5finit(void)
{
// empty the queue.
while(!errorMessageQueue.empty()) {
delete errorMessageQueue.top();
errorMessageQueue.pop();
}
numErrorMessages = 0;
}

RML_BEGIN_LABEL(ErrorExt__setCheckpoint)
Expand Down Expand Up @@ -85,20 +79,6 @@ RML_BEGIN_LABEL(ErrorExt__getLastDeletedCheckpoint)
}
RML_END_LABEL

RML_BEGIN_LABEL(ErrorExt__errorOn)
{
error_on = true;
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(ErrorExt__errorOff)
{
error_on = false;
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

/* Function to give feedback to the user on which component the error is "on" */
RML_BEGIN_LABEL(ErrorExt__updateCurrentComponent)
{
Expand All @@ -122,14 +102,11 @@ RML_BEGIN_LABEL(ErrorExt__addMessage)
char* message = RML_STRINGDATA(rmlA3);
void* tokenlst = rmlA4;
ErrorMessage::TokenList tokens;
if (error_on) {
while(RML_GETHDR(tokenlst) != RML_NILHDR) {
tokens.push_back(string(RML_STRINGDATA(RML_CAR(tokenlst))));
tokenlst=RML_CDR(tokenlst);
}
add_message(errorID,tp,severity,message,tokens);
//printf(" Adding message, size: %d, %s\n",errorMessageQueue.size(),message);
while(RML_GETHDR(tokenlst) != RML_NILHDR) {
tokens.push_back(string(RML_STRINGDATA(RML_CAR(tokenlst))));
tokenlst=RML_CDR(tokenlst);
}
add_message(errorID,tp,severity,message,tokens);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL
Expand All @@ -149,21 +126,18 @@ RML_BEGIN_LABEL(ErrorExt__addSourceMessage)
void* tokenlst = rmlA10;
ErrorMessage::TokenList tokens;

if (error_on) {
while(RML_GETHDR(tokenlst) != RML_NILHDR) {
tokens.push_back(string(RML_STRINGDATA(RML_CAR(tokenlst))));
tokenlst=RML_CDR(tokenlst);
}

add_source_message(errorID,tp,severity,message,tokens,sline,scol,eline,ecol,isReadOnly,filename);
while(RML_GETHDR(tokenlst) != RML_NILHDR) {
tokens.push_back(string(RML_STRINGDATA(RML_CAR(tokenlst))));
tokenlst=RML_CDR(tokenlst);
}
add_source_message(errorID,tp,severity,message,tokens,sline,scol,eline,ecol,isReadOnly,filename);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(ErrorExt__getNumMessages)
{
rmlA0 = mk_icon((errorMessageQueue.size()));
rmlA0 = mk_icon((getMembers()->errorMessageQueue->size()));
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL
Expand Down

0 comments on commit a3c9c53

Please sign in to comment.