matlab:Debugging on Linux Platforms

好不容易找到这篇,怕以后不好找,标记一下。

Debugging on Linux Platforms

The GNU® Debugger gdb, available on Linux® systems, provides complete source code debugging, including the ability to set breakpoints, examine variables, and step through the source code line-by-line.

In this procedure, the MATLAB® command prompt >> is shown in front of MATLAB commands, and linux> represents a Linux prompt; your system might show a different prompt. The debugger prompt is <gdb>.

To debug with gdb:

  1. Compile the source MEX file with the -g option, which builds the file with debugging symbols included. For this example, at the Linux prompt, type:

    linux> mex -g yprime.c
  2. At the Linux prompt, start the gdb debugger using the matlab function -D option.

    linux> matlab -Dgdb
    
  3. Tell gdb to stop for debugging.

    <gdb> handle SIGSEGV SIGBUS nostop noprint
    
  4. Start MATLAB without the Java® Virtual Machine (JVM™) by using the -nojvm startup flag.

    <gdb> run -nojvm
  5. In MATLAB, enable debugging with the dbmex function and run your binary MEX file.

    >> dbmex on
    >> yprime(1,1:4)
  6. You are ready to start debugging.

    It is often convenient to set a breakpoint at mexFunction so you stop at the beginning of the gateway routine.

    <gdb> break mexFunction
    <gdb> r
  7. Once you hit one of your breakpoints, you can make full use of any commands the debugger provides to examine variables, display memory, or inspect registers.

    To proceed from a breakpoint, type:

    <gdb> continue
  8. After stopping at the last breakpoint, type:

    <gdb> continue

    yprime finishes and MATLAB displays:

    ans =
    
        2.0000    8.9685    4.0000   -1.0947
    
  9. From the MATLAB prompt you can return control to the debugger by typing:

    >> dbmex stop

    Or, if you are finished running MATLAB, type:

    >> quit
  10. When you are finished with the debugger, type:

    <gdb> quit

    You return to the Linux prompt.

Refer to the documentation provided with your debugger for more information on its use.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值