无法在fpc调试输出中生成行号

时间:2017-12-05 18:24:11

标签: freepascal

我有一个非常简单的测试程序(test.pas),如下所示,我正在尝试生成内存跟踪,但无法获得包含行号等的任何详细输出。

/**
 * Saves unique selector for the given element into chrome.storage
 *
 * The function invokes by panel.js ("chrome.devtools.inspectedWindow.eval")
 * @param el {HTMLElement}
 */
function saveUniqueSelector(el) {
    if (el) {
        const selectorGenerator = new CssSelectorGenerator();
        const selector = selectorGenerator.getSelector(el);
        if (selector) {
            console.log('Saving selector', selector);
            chrome.storage.local.set({prev_selected: selector});
        }
    }
}

我跑了以下。

program test;

var
  intPointer:^integer;

begin
  new(intPointer); //Allocate some memory
  intPointer^:=5;
  // dispose(intPointer);

  WriteLn('Hello World');

end.

这是我得到的输出。

fpc -g -gh -gl test.pas; ./test

在这个玩具示例中,我可以说Hello World Heap dump by heaptrc unit 1 memory blocks allocated : 2/8 0 memory blocks freed : 0/0 1 unfreed memory blocks : 2 True heap size : 327680 (32 used in System startup) True free heap : 327488 Should be : 327512 Call trace for block $00000001000CA0C0 size 2 没有被处理掉,但是对于更大的应用程序,我希望有更多的洞察力。在线的其他示例似乎显示原始文件中分配内存的行号,我想知道我做错了什么。

有什么建议吗?

编辑:

添加了另一个例子(第9.2小节),我无法获取行号信息。

http://www.math.uni-leipzig.de/pool/tuts/FreePascal/units/node10.html

1 个答案:

答案 0 :(得分:1)

Sometimes lineinfo can't determine source file exactly, especially for the top call in stack trace. If you would like to see the file name, you need to move your code from the main begin/end statement into a procedure. It's not ideal solution, but it makes debugging a bit easier.

<a href="https://www.companyname.com/language/projectname/manage/maintenance/web-content-management?p_p_id=15&amp;p_p_lifecycle=0&amp;p_p_state=pop_up&amp;p_p_mode=view&amp;_15_struts_action=%2Fjournal%2Fselect_folder&amp;_15_folderId=4655761" data-direction-right="true" data-folder-id="4655761">TEST</a>

Also, it seems that now unit exeinfo (which is used by lineinfo) supports only ppc32 architecture on macOS.