Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: "Error using ==> dbstop"
Date: Mon, 29 Jun 2009 21:09:01 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 32
Message-ID: <h2bahd$ap6$1@fred.mathworks.com>
References: <h1vvp9$e75$1@fred.mathworks.com> <4a659c20-07f7-421f-b010-1d7aca2078f6@j19g2000vbp.googlegroups.com> <h29n1b$51j$1@fred.mathworks.com> <h29ubm$kfs$1@fred.mathworks.com> <h2a5po$amq$1@fred.mathworks.com> <MPG.24b27338f102bf719899f2@news.mathworks.com> <h2b74l$n7f$1@fred.mathworks.com> <h2b8a5$cl5$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246309741 11046 172.30.248.38 (29 Jun 2009 21:09:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 29 Jun 2009 21:09:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:551536


"us "
> 274           findLandingLine       codetools\private\evalmxdom.m

now, if we look at this line (r2009a), we see

function landingLine = findLandingLine(file,targetLine)
% Probe to see where the breakpoint wants to land.
% Precondition: this file has no existing breakpoints.
try
    dbstop(file,num2str(targetLine))
catch %#ok<CTCH>
    % This errors if there aren't any executible lines left or if there is
    % any sort of parse error.
end

which, in turn, is called twice from
    iStartLine = findLandingLine(file, cellBoundaries(iCell, 1));
    iEndLine   = findLandingLine(file, cellBoundaries(iCell, 2) + 1);     % <- 2nd call

in the OP's case, TARGETLINE is 5 (see OP's TEST.M) and, therefore, the error is caught at the second call to FINDLANDINGLINE with TARGETLINE = 6 and consequently LASTERROR is assigned to

     lasterr
%{
     Error using ==> dbstop
     You can not set a breakpoint past the start of the last
     expression in the file.
%}

my guess: since this try/catch block is a mere lazy construct (for not having to check the validity of the line number), the LASTERROR should be reset (to the previous value, if any) to not cause such troubles...

just a thought
us