Fixed segfaults when using commands that take a filename.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@692 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-07-23 21:16:57 +00:00
parent d1a7f5f75d
commit c768b9256a
4 changed files with 55 additions and 45 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: DebuggerParser.cxx,v 1.69 2005-07-23 19:07:15 urchlay Exp $ // $Id: DebuggerParser.cxx,v 1.70 2005-07-23 21:16:57 urchlay Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -1167,7 +1167,7 @@ bool DebuggerParser::saveScriptFile(string file) {
StringList conds = debugger->cpuDebug().m6502().getCondBreakNames(); StringList conds = debugger->cpuDebug().m6502().getCondBreakNames();
for(unsigned int i=0; i<conds.size(); i++) for(unsigned int i=0; i<conds.size(); i++)
out << "breakif " << conds[i] << endl; out << "breakif {" << conds[i] << "}" << endl;
bool ok = out.good(); bool ok = out.good();
out.close(); out.close();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: YaccParser.cxx,v 1.18 2005-07-21 03:26:59 urchlay Exp $ // $Id: YaccParser.cxx,v 1.19 2005-07-23 21:16:57 urchlay Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -77,6 +77,7 @@ const string& errorMessage() {
Expression *getResult() { Expression *getResult() {
return result.exp; return result.exp;
lastExp = 0;
} }
@ -99,6 +100,7 @@ void setInput(const char *in) {
} }
int parse(const char *in) { int parse(const char *in) {
lastExp = 0;
errMsg = "(no error)"; errMsg = "(no error)";
setInput(in); setInput(in);
return yyparse(); return yyparse();

View File

@ -12,8 +12,12 @@ void yyerror(char *e) {
//fprintf(stderr, "%s at token \"%s\"\n", e, yytext); //fprintf(stderr, "%s at token \"%s\"\n", e, yytext);
fprintf(stderr, "%s\n", e); fprintf(stderr, "%s\n", e);
errMsg = e; errMsg = e;
if(lastExp)
// be extra paranoid about deletion
if(lastExp && dynamic_cast<Expression*>(lastExp))
delete lastExp; delete lastExp;
lastExp = 0;
} }
%} %}

View File

@ -36,12 +36,16 @@ void yyerror(char *e) {
//fprintf(stderr, "%s at token \"%s\"\n", e, yytext); //fprintf(stderr, "%s at token \"%s\"\n", e, yytext);
fprintf(stderr, "%s\n", e); fprintf(stderr, "%s\n", e);
errMsg = e; errMsg = e;
if(lastExp)
// be extra paranoid about deletion
if(lastExp && dynamic_cast<Expression*>(lastExp))
delete lastExp; delete lastExp;
lastExp = 0;
} }
#line 21 "stella.y" #line 25 "stella.y"
#ifndef YYSTYPE #ifndef YYSTYPE
typedef union { typedef union {
int val; int val;
@ -130,10 +134,10 @@ static const short yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const short yyrline[] = static const short yyrline[] =
{ {
0, 57, 60, 61, 62, 63, 64, 65, 66, 67, 0, 61, 64, 65, 66, 67, 68, 69, 70, 71,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
88, 89, 90, 91, 92 92, 93, 94, 95, 96
}; };
#endif #endif
@ -969,139 +973,139 @@ yyreduce:
switch (yyn) { switch (yyn) {
case 1: case 1:
#line 57 "stella.y" #line 61 "stella.y"
{ fprintf(stderr, "\ndone\n"); result.exp = yyvsp[0].exp; } { fprintf(stderr, "\ndone\n"); result.exp = yyvsp[0].exp; }
break; break;
case 2: case 2:
#line 60 "stella.y" #line 64 "stella.y"
{ fprintf(stderr, " +"); yyval.exp = new PlusExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " +"); yyval.exp = new PlusExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 3: case 3:
#line 61 "stella.y" #line 65 "stella.y"
{ fprintf(stderr, " -"); yyval.exp = new MinusExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " -"); yyval.exp = new MinusExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 4: case 4:
#line 62 "stella.y" #line 66 "stella.y"
{ fprintf(stderr, " *"); yyval.exp = new MultExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " *"); yyval.exp = new MultExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 5: case 5:
#line 63 "stella.y" #line 67 "stella.y"
{ fprintf(stderr, " /"); yyval.exp = new DivExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " /"); yyval.exp = new DivExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 6: case 6:
#line 64 "stella.y" #line 68 "stella.y"
{ fprintf(stderr, " %%"); yyval.exp = new ModExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " %%"); yyval.exp = new ModExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 7: case 7:
#line 65 "stella.y" #line 69 "stella.y"
{ fprintf(stderr, " &"); yyval.exp = new BinAndExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " &"); yyval.exp = new BinAndExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 8: case 8:
#line 66 "stella.y" #line 70 "stella.y"
{ fprintf(stderr, " |"); yyval.exp = new BinOrExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " |"); yyval.exp = new BinOrExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 9: case 9:
#line 67 "stella.y" #line 71 "stella.y"
{ fprintf(stderr, " ^"); yyval.exp = new BinXorExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " ^"); yyval.exp = new BinXorExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 10: case 10:
#line 68 "stella.y" #line 72 "stella.y"
{ fprintf(stderr, " <"); yyval.exp = new LessExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " <"); yyval.exp = new LessExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 11: case 11:
#line 69 "stella.y" #line 73 "stella.y"
{ fprintf(stderr, " >"); yyval.exp = new GreaterExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " >"); yyval.exp = new GreaterExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 12: case 12:
#line 70 "stella.y" #line 74 "stella.y"
{ fprintf(stderr, " >="); yyval.exp = new GreaterEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " >="); yyval.exp = new GreaterEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 13: case 13:
#line 71 "stella.y" #line 75 "stella.y"
{ fprintf(stderr, " <="); yyval.exp = new LessEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " <="); yyval.exp = new LessEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 14: case 14:
#line 72 "stella.y" #line 76 "stella.y"
{ fprintf(stderr, " !="); yyval.exp = new NotEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " !="); yyval.exp = new NotEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 15: case 15:
#line 73 "stella.y" #line 77 "stella.y"
{ fprintf(stderr, " =="); yyval.exp = new EqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " =="); yyval.exp = new EqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 16: case 16:
#line 74 "stella.y" #line 78 "stella.y"
{ fprintf(stderr, " >>"); yyval.exp = new ShiftRightExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " >>"); yyval.exp = new ShiftRightExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 17: case 17:
#line 75 "stella.y" #line 79 "stella.y"
{ fprintf(stderr, " <<"); yyval.exp = new ShiftLeftExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " <<"); yyval.exp = new ShiftLeftExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 18: case 18:
#line 76 "stella.y" #line 80 "stella.y"
{ fprintf(stderr, " ||"); yyval.exp = new LogOrExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " ||"); yyval.exp = new LogOrExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 19: case 19:
#line 77 "stella.y" #line 81 "stella.y"
{ fprintf(stderr, " &&"); yyval.exp = new LogAndExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " &&"); yyval.exp = new LogAndExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 20: case 20:
#line 78 "stella.y" #line 82 "stella.y"
{ fprintf(stderr, " U-"); yyval.exp = new UnaryMinusExpression(yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " U-"); yyval.exp = new UnaryMinusExpression(yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 21: case 21:
#line 79 "stella.y" #line 83 "stella.y"
{ fprintf(stderr, " ~"); yyval.exp = new BinNotExpression(yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " ~"); yyval.exp = new BinNotExpression(yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 22: case 22:
#line 80 "stella.y" #line 84 "stella.y"
{ fprintf(stderr, " !"); yyval.exp = new LogNotExpression(yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " !"); yyval.exp = new LogNotExpression(yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 23: case 23:
#line 81 "stella.y" #line 85 "stella.y"
{ fprintf(stderr, " U*"); yyval.exp = new ByteDerefExpression(yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " U*"); yyval.exp = new ByteDerefExpression(yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 24: case 24:
#line 82 "stella.y" #line 86 "stella.y"
{ fprintf(stderr, " U@"); yyval.exp = new WordDerefExpression(yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " U@"); yyval.exp = new WordDerefExpression(yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 25: case 25:
#line 83 "stella.y" #line 87 "stella.y"
{ fprintf(stderr, " U<"); yyval.exp = new LoByteExpression(yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " U<"); yyval.exp = new LoByteExpression(yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 26: case 26:
#line 84 "stella.y" #line 88 "stella.y"
{ fprintf(stderr, " U>"); yyval.exp = new HiByteExpression(yyvsp[0].exp); lastExp = yyval.exp; } { fprintf(stderr, " U>"); yyval.exp = new HiByteExpression(yyvsp[0].exp); lastExp = yyval.exp; }
break; break;
case 27: case 27:
#line 85 "stella.y" #line 89 "stella.y"
{ fprintf(stderr, " ()"); yyval.exp = yyvsp[-1].exp; lastExp = yyval.exp; } { fprintf(stderr, " ()"); yyval.exp = yyvsp[-1].exp; lastExp = yyval.exp; }
break; break;
case 28: case 28:
#line 86 "stella.y" #line 90 "stella.y"
{ fprintf(stderr, " []"); yyval.exp = new ByteDerefOffsetExpression(yyvsp[-3].exp, yyvsp[-1].exp); lastExp = yyval.exp; } { fprintf(stderr, " []"); yyval.exp = new ByteDerefOffsetExpression(yyvsp[-3].exp, yyvsp[-1].exp); lastExp = yyval.exp; }
break; break;
case 29: case 29:
#line 87 "stella.y" #line 91 "stella.y"
{ fprintf(stderr, " %d", yyvsp[0].val); yyval.exp = new ConstExpression(yyvsp[0].val); lastExp = yyval.exp; } { fprintf(stderr, " %d", yyvsp[0].val); yyval.exp = new ConstExpression(yyvsp[0].val); lastExp = yyval.exp; }
break; break;
case 30: case 30:
#line 88 "stella.y" #line 92 "stella.y"
{ fprintf(stderr, " %s", yyvsp[0].equate); yyval.exp = new EquateExpression(yyvsp[0].equate); lastExp = yyval.exp; } { fprintf(stderr, " %s", yyvsp[0].equate); yyval.exp = new EquateExpression(yyvsp[0].equate); lastExp = yyval.exp; }
break; break;
case 31: case 31:
#line 89 "stella.y" #line 93 "stella.y"
{ fprintf(stderr, " (CpuMethod)"); yyval.exp = new CpuMethodExpression(yyvsp[0].cpuMethod); lastExp = yyval.exp; } { fprintf(stderr, " (CpuMethod)"); yyval.exp = new CpuMethodExpression(yyvsp[0].cpuMethod); lastExp = yyval.exp; }
break; break;
case 32: case 32:
#line 90 "stella.y" #line 94 "stella.y"
{ fprintf(stderr, " (TiaMethod)"); yyval.exp = new TiaMethodExpression(yyvsp[0].tiaMethod); lastExp = yyval.exp; } { fprintf(stderr, " (TiaMethod)"); yyval.exp = new TiaMethodExpression(yyvsp[0].tiaMethod); lastExp = yyval.exp; }
break; break;
case 33: case 33:
#line 91 "stella.y" #line 95 "stella.y"
{ fprintf(stderr, " (function)"); yyval.exp = new FunctionExpression(yyvsp[0].function); lastExp = yyval.exp; } { fprintf(stderr, " (function)"); yyval.exp = new FunctionExpression(yyvsp[0].function); lastExp = yyval.exp; }
break; break;
case 34: case 34:
#line 92 "stella.y" #line 96 "stella.y"
{ fprintf(stderr, " ERR"); yyerror("Invalid label or constant"); return 1; } { fprintf(stderr, " ERR"); yyerror("Invalid label or constant"); return 1; }
break; break;
} }
@ -1337,5 +1341,5 @@ yyreturn:
#endif #endif
return yyresult; return yyresult;
} }
#line 94 "stella.y" #line 98 "stella.y"