您好!
我想知道能否获得源代码中特定行的地址。
我将尝试确保在目标命中断点时将其停止。
提前感谢。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
我想知道能否获得源代码中特定行的地址。
我将尝试确保在目标命中断点时将其停止。
提前感谢。
我会 改用断点属性。 请注意、用户指南的示例中有一些拼写错误。 缺少"Type"节点。
下面是一个工作示例:
// Import the DSS packages into our namespace to save on typing importPackage(Packages.com.ti.debug.engine.scripting) importPackage(Packages.com.ti.ccstudio.scripting.environment) importPackage(Packages.java.lang) // Create our scripting environment object - which is the main entry point into any script and // the factory for creating other Scriptable ervers and Sessions var script = ScriptingEnvironment.instance() // Create a log file in the current directory to log script execution script.traceBegin("BreakpointsTestLog.xml", "DefaultStylesheet.xsl") // Set our TimeOut script.setScriptTimeout(15000) // Log everything script.traceSetConsoleLevel(TraceLevel.INFO) script.traceSetFileLevel(TraceLevel.ALL) // Get the Debug Server and start a Debug Session debugServer = script.getServer("DebugServer.1") debugServer.setConfig("./targetConfigs/MSPM0G3507.ccxml"); debugSession = debugServer.openSession("*", "CORTEX_M0P") debugSession.target.connect(); // Load a program // (ScriptingEnvironment has a concept of a working folder and for all of the APIs which take // path names as arguments you can either pass a relative path or an absolute path) debugSession.memory.loadProgram("./Debug/gpio_toggle_output_LP_MSPM0G3507_nortos_ticlang.out") // for setting breakpoint to perform profile control point var bpProps2 = debugSession.breakpoint.createProperties(1); bpProps2.setSourceLocation("Hardware Configuration.Type.Location", "C:/Users/user/workspace_v1250/gpio_toggle_output_LP_MSPM0G3507_nortos_ticlang/gpio_toggle_output.c", 51); var bp2 = debugSession.breakpoint.add(bpProps2); // add breakpoint var bpLoc = bpProps2.getNumeric("Hardware Configuration.Type.Location"); // get address of breakpoint script.traceWrite("BP Location: 0x" + bpLoc.toString(16)); if(debugSession.expression.evaluate("PC") != bpLoc) { script.traceWrite("PC: 0x" + debugSession.expression.evaluate("PC").toString(16)); debugSession.target.run(); } script.traceWrite("PC: 0x" + debugSession.expression.evaluate("PC").toString(16)); script.traceWrite("Halted at breakpoint"); // All done debugSession.target.disconnect(); debugSession.terminate() debugServer.stop() script.traceSetConsoleLevel(TraceLevel.INFO) script.traceWrite("TEST SUCCEEDED!") // Stop logging and exit. script.traceEnd()
控制台输出:
谢谢
小
我还有一个关于此参数的问题 "Hardware Configuration.Type.Location", 此参数是否是常量参数?
不可以、您可以更改该值。 如果您使用数字值设置该值、它将在地址上设置它。 在我的示例中、我传入了一个包含源文件和行的字符串。
读回该值时、如果我读取一个字符串、我会得到源信息和行信息。 在我的示例中、我读取了一个数字值、因此我得到了地址。