Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Breakpoint on specific command line output possible?

Subject: Breakpoint on specific command line output possible?

From: Jesse Hopkins

Date: 12 Sep, 2013 12:54:06

Message: 1 of 6

Hello all -
I've been trying to track down this small but annoying issue. We've got a logging utility built up that builds XML documents during our test executions. We've written a handful of matlab helper functions that wrap Java XML code for doing things like adding text elements, etc.. We've been able to produce some nice documents, but randomly the string "null" appears at the command line output. I have not been able to trace what is causing this output. I imagine its something in Java, because matlab doesn't really have the concept of "null", and I've grepped our entire source and "null" never appears. The trouble is, it is not repeatable. It happens just enough to stay on my radar. Are there techniques to trap the command line output of Java code running in matlab? I am hoping there's some way I can cause a breakpoint whenever "null" is printed to the command line.

Subject: Breakpoint on specific command line output possible?

From: dpb

Date: 12 Sep, 2013 14:41:09

Message: 2 of 6

On 9/12/2013 7:54 AM, Jesse Hopkins wrote:
> Hello all - I've been trying to track down this small but annoying
> issue. We've got a logging utility built up that builds XML documents
> during our test executions. We've written a handful of matlab helper
> functions that wrap Java XML code for doing things like adding text
> elements, etc.. We've been able to produce some nice documents, but
> randomly the string "null" appears at the command line output. I have
> not been able to trace what is causing this output. I imagine its
> something in Java, because matlab doesn't really have the concept of
> "null", and I've grepped our entire source and "null" never appears. The
> trouble is, it is not repeatable. It happens just enough to stay on my
> radar. Are there techniques to trap the command line output of Java code
> running in matlab? I am hoping there's some way I can cause a breakpoint
> whenever "null" is printed to the command line.

I "know nuthink" about Java but -- what about for debugging redirecting
output to string variable and setting watch on it? That feasible?

I can't think of any way to make the ML debugger work on the command
output string directly...

Can you at least isolate the issue to a given function or set of
functions by observing a case when it does occur and rerunning that
input stream in piecewise fashion? Or is it one of those really nasty
things that rerunning doesn't necessarily reproduce the symptom, either?

--

Subject: Breakpoint on specific command line output possible?

From: dpb

Date: 12 Sep, 2013 16:55:33

Message: 3 of 6

On 9/12/2013 9:41 AM, dpb wrote:
...

> I "know nuthink" about Java but -- what about for debugging redirecting
> output to string variable and setting watch on it? That feasible?
...

ADDENDUM:

Or, encapsulate the functions in try/catch blocks that do the test and
throw an exception, perhaps...???

--

Subject: Breakpoint on specific command line output possible?

From: Jesse Hopkins

Date: 12 Sep, 2013 19:29:06

Message: 4 of 6

Thanks for the suggestion, but it is nasty in that re-running the same scenario shows different behavior. It may or may not appear, or maybe it appears 3 times. The only way I know to capture the output is via diary(), and that requires that I check the diary file periodically. I went down that path a bit, but by the time my code gets to a point where I can query the diary file, I'm still not certain where the "null" came from.

Subject: Breakpoint on specific command line output possible?

From: dpb

Date: 12 Sep, 2013 19:51:32

Message: 5 of 6

On 9/12/2013 2:29 PM, Jesse Hopkins wrote:
> Thanks for the suggestion, but it is nasty in that re-running the same
> scenario shows different behavior. It may or may not appear, or maybe it
> appears 3 times. The only way I know to capture the output is via
> diary(), and that requires that I check the diary file periodically. I
> went down that path a bit, but by the time my code gets to a point where
> I can query the diary file, I'm still not certain where the "null" came
> from.

I was afraid of that -- have you updated the Java install just to see if
it would magically go away?

How are you building the XML strings; can you not wrap that such that
the output goes to a variable instead of or before the file so can do
the search on it then?

Or, if nothing else the old "sprinkle a bunch of 'We are here' output
statements through the code that serve to at least do binary splits of
before/after a given routine/statement in a routine. Hopefully at least
that will be repetitive if it does happen that it is the same routine or
few routines or, conversely, if it is Java would hopefully identify a
specific routine there that is buggy or has bad inputs on occasion.

--

Subject: Breakpoint on specific command line output possible?

From: Eric Sampson

Date: 12 Sep, 2013 20:37:06

Message: 6 of 6

dpb <none@non.net> wrote in message <l0t60k$isv$1@speranza.aioe.org>...
> On 9/12/2013 2:29 PM, Jesse Hopkins wrote:
> > Thanks for the suggestion, but it is nasty in that re-running the same
> > scenario shows different behavior. It may or may not appear, or maybe it
> > appears 3 times. The only way I know to capture the output is via
> > diary(), and that requires that I check the diary file periodically. I
> > went down that path a bit, but by the time my code gets to a point where
> > I can query the diary file, I'm still not certain where the "null" came
> > from.
>
> I was afraid of that -- have you updated the Java install just to see if
> it would magically go away?
>
> How are you building the XML strings; can you not wrap that such that
> the output goes to a variable instead of or before the file so can do
> the search on it then?
>
> Or, if nothing else the old "sprinkle a bunch of 'We are here' output
> statements through the code that serve to at least do binary splits of
> before/after a given routine/statement in a routine. Hopefully at least
> that will be repetitive if it does happen that it is the same routine or
> few routines or, conversely, if it is Java would hopefully identify a
> specific routine there that is buggy or has bad inputs on occasion.
>
> --

Jesse, I think you might have the best luck by debugging from the Java side. Try the following instructions: http://www.mathworks.com/support/solutions/en/data/1-15HDKH/index.html

Tags for this Thread

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.

Contact us