Thread Subject: dbstop in m file

Subject: dbstop in m file

From: Olivier

Date: 6 Jan, 2012 12:48:08

Message: 1 of 8

I would like to use a command I can include in a .m file that enable to be in debug mode just after the command. Actually it is possible to use:
dbstop in myfile at line_number
but the problem is that the dbstop will occur always at the same line into the file. If I modify the file (including or deleting code) then the dbstop will not be at the same place in my code. Example:
myfile.m is:
1- if a>1
2- b=2;
3- else
4- b=3;
5- end;
I want to include a dbstop just after "b=3". Then if I use "dbstop in myfile at 4" then it's ok. Now if I modify myfile with:
1- b=0;
2- z=4;
3- if a>1
4- b=2;
5- else
6- b=3;
5- end;

Then the command "dbstop in myfile at 4" will be after b=2.

I would like to use something that I can include into the code like "dbstop now" that put me in debug mode just after the command. Whatever modifications of the file, the debug will still occur just after the command.

Does anyone know if such a command exist?

Thank you in advance for your help.

Subject: dbstop in m file

From: Bruno Luong

Date: 6 Jan, 2012 13:16:07

Message: 2 of 8

"Olivier " <olivier.isson@mstarsemi.com> wrote in message
>
> Does anyone know if such a command exist?

keyboard?

Bruno

Subject: dbstop in m file

From: Olivier

Date: 6 Jan, 2012 17:21:08

Message: 3 of 8

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <je6s6n$jes$1@newscl01ah.mathworks.com>...
> "Olivier " <olivier.isson@mstarsemi.com> wrote in message
> >
> > Does anyone know if such a command exist?
>
> keyboard?
>
> Bruno

Thank you Bruno! It remains a minor drawback: the command keyboard just give you control in the command window but does not open in the editor the mfile where it is stopped (as dbstop does). Any other ideas?

Anyway it is already not bad!

Subject: dbstop in m file

From: Bruno Luong

Date: 6 Jan, 2012 18:09:08

Message: 4 of 8

"Olivier " <olivier.isson@mstarsemi.com> wrote in message <je7ai4$bqt$1@newscl01ah.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <je6s6n$jes$1@newscl01ah.mathworks.com>...
> > "Olivier " <olivier.isson@mstarsemi.com> wrote in message
> > >
> > > Does anyone know if such a command exist?
> >
> > keyboard?
> >
> > Bruno
>
> Thank you Bruno! It remains a minor drawback: the command keyboard just give you control in the command window but does not open in the editor the mfile where it is stopped (as dbstop does). Any other ideas?

You can add:
edit myfile.m

right before keyboard

Bruno

Subject: dbstop in m file

From: Matt J

Date: 6 Jan, 2012 19:01:09

Message: 5 of 8

"Olivier " <olivier.isson@mstarsemi.com> wrote in message <je6qi8$e73$1@newscl01ah.mathworks.com>...
>
> Then the command "dbstop in myfile at 4" will be after b=2.
>
> I would like to use something that I can include into the code like "dbstop now" that put me in debug mode just after the command. Whatever modifications of the file, the debug will still occur just after the command.
>
> Does anyone know if such a command exist?
=================

You're not meant to be doing this with commands. You are meant to be inserting breakpoints directly in the editor.

http://www.mathworks.com/help/techdoc/matlab_env/brqxeeu-175.html#brqxeeu-182

Subject: dbstop in m file

From: Olivier

Date: 17 Jan, 2012 15:42:08

Message: 6 of 8

"Matt J" wrote in message <je7gdl$3lk$1@newscl01ah.mathworks.com>...
> "Olivier " <olivier.isson@mstarsemi.com> wrote in message <je6qi8$e73$1@newscl01ah.mathworks.com>...
> >
> > Then the command "dbstop in myfile at 4" will be after b=2.
> >
> > I would like to use something that I can include into the code like "dbstop now" that put me in debug mode just after the command. Whatever modifications of the file, the debug will still occur just after the command.
> >
> > Does anyone know if such a command exist?
> =================
>
> You're not meant to be doing this with commands. You are meant to be inserting breakpoints directly in the editor.
>
> http://www.mathworks.com/help/techdoc/matlab_env/brqxeeu-175.html#brqxeeu-182

That's precisely what I would like to avoid because all breakpoints disapear with a "clear all" command.

Subject: dbstop in m file

From: Olivier

Date: 17 Jan, 2012 15:47:08

Message: 7 of 8

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <je7dc4$lbm$1@newscl01ah.mathworks.com>...
> "Olivier " <olivier.isson@mstarsemi.com> wrote in message <je7ai4$bqt$1@newscl01ah.mathworks.com>...
> > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <je6s6n$jes$1@newscl01ah.mathworks.com>...
> > > "Olivier " <olivier.isson@mstarsemi.com> wrote in message
> > > >
> > > > Does anyone know if such a command exist?
> > >
> > > keyboard?
> > >
> > > Bruno
> >
> > Thank you Bruno! It remains a minor drawback: the command keyboard just give you control in the command window but does not open in the editor the mfile where it is stopped (as dbstop does). Any other ideas?
>
> You can add:
> edit myfile.m
>
> right before keyboard
>
> Bruno

Great! Thank you Bruno!

Subject: dbstop in m file

From: Kelly Kearney

Date: 17 Jan, 2012 15:57:08

Message: 8 of 8

"Olivier " <olivier.isson@mstarsemi.com> wrote in message <jf44sg$gfk$1@newscl01ah.mathworks.com>...
> "Matt J" wrote in message <je7gdl$3lk$1@newscl01ah.mathworks.com>...
> > "Olivier " <olivier.isson@mstarsemi.com> wrote in message <je6qi8$e73$1@newscl01ah.mathworks.com>...
> > >
> > > Then the command "dbstop in myfile at 4" will be after b=2.
> > >
> > > I would like to use something that I can include into the code like "dbstop now" that put me in debug mode just after the command. Whatever modifications of the file, the debug will still occur just after the command.
> > >
> > > Does anyone know if such a command exist?
> > =================
> >
> > You're not meant to be doing this with commands. You are meant to be inserting breakpoints directly in the editor.
> >
> > http://www.mathworks.com/help/techdoc/matlab_env/brqxeeu-175.html#brqxeeu-182
>
> That's precisely what I would like to avoid because all breakpoints disapear with a "clear all" command.

You could insert a specific warning message that implies you'd like to stop for debugging, then set a dbstop for just that identifier.

For example

function testing
disp('hi');
warning('stophere:testing', 'Just testing');
disp('hello');


>> dbstop if warning stophere:testing;
>> testing

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com