macOS Sierra - Debugging not working lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- mbdev · 2016-09-26 10:56 Hi, after upgrading to macOS Sierra I'm not able to debug my applications. After pressing the start button Lazarus will wait and nothing happens. But it's possible to create an executable and run it without debugger. I attached a screenshot of the console output of Lazarus. I seems like Lazarus is waiting for GDB? Do you know how to fix this problem? GDB Version: gdb-7.11 MacOS Version: OS X 10.12 Lazarus Version: 1.6 FreePascal Version: 3.0.0 ---------------------------------------------------------------------- esvignolo · 2016-09-26 15:03 Hi, there are 2 methods at least: Method a) (i use this one, and work on sierra) 1) Boot to recovery 2) In recovery Tools->Open Terminal 3) run "csrutil disable" (without quotes) 4) Restart Method b) Codesign GDB the instructions are in the wiki page of lazarus. ---------------------------------------------------------------------- mbdev · 2016-09-26 16:20 Hm, I had created the key cert. for GDB on El Capitan and it worked well. The screenshot indicates that I tried to start Lazarus as superuser and the same problem occured. I don't think that it has something to do with permissions. Which version of GDB are you using? ---------------------------------------------------------------------- Martin_fr · 2016-09-26 16:43 You got a debug PID, so something got started. See if you can create a log http://wiki.lazarus.freepascal.org/GDB_Deb ugger_Tips#Log_info_for_debug_session ---------------------------------------------------------------------- mbdev · 2016-09-26 16:59 I created an empty LCL applications and pressed run. After 10s of nothing I terminated the Lazarus process. Moreover I started lazarus as superuser to prevent possible permission problems. You can find the full lazarus log file in my attachments. ---------------------------------------------------------------------- Martin_fr · 2016-09-26 17:15 The last thing that happens is that gdb tries to launch your app. Afaik it only gets that far, if it is codesigned (but don't know for sure) Unfortunately the last bits of the file were not flushed to disk. Not sure if,what they would have revealed. You could try to run Lazarus from a console (with --log-enable / but without --log-file) then you get the output in the console window, and might get the last line. Also once the IDE hangs, open another console, run a "ps ax" or equivalent, and see if gdb is still running. Also if your app is running. -------------- Maybe this can be solved by changing some settings. In Menu "Tools" > Options. Then page "Debugger". There is a property grid. One entry is "InternalStartBreak". You can try the other values. Maybe gdsbEntry or gdsbMainAddress. --------------- If you run any antivirus make sure  that does not interfere. --- Btw, when it hangs, did you try "reset debugger" from "run" menu? ---------------------------------------------------------------------- esvignolo · 2016-09-26 19:09 I install with brew (in yosemite), after update to Sierra, I run: brew upgrade gdb This is my version now: [MacBookeEsteban:POSBerry Esteban$ gdb --version GNU gdb (GDB) 7.10.1 Copyright (C) 2015 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.  Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-apple-darwin15.2.0". Quote from: mbdev on September 26, 2016, 06:20:59 pmHm, I had created the key cert. for GDB on El Capitan and it worked well. The screenshot indicates that I tried to start Lazarus as superuser and the same problem occured. I don't think that it has something to do with permissions. Which version of GDB are you using? ---------------------------------------------------------------------- mbdev · 2016-09-27 14:22 Hi, I reinstalled gdb and recreated the cert. The problem isn't solved :/ Thank you for your help Do you have more ideas? QuoteIf you run any antivirus make sure  that does not interfere.--> No antivirus QuoteMaybe this can be solved by changing some settings. In Menu "Tools" > Options. Then page "Debugger". There is a property grid. One entry is "InternalStartBreak". You can try the other values. Maybe gdsbEntry or gdsbMainAddress.--> No effect :/ QuoteBtw, when it hangs, did you try "reset debugger" from "run" menu?--> Yes , but no effect QuoteAlso once the IDE hangs, open another console, run a "ps ax" or equivalent, and see if gdb is still running. Also if your app is running.Output: ps   PID TTY           TIME CMD   936 ttys000    0:00.03 -bash   984 ttys000    0:07.96 ./lazarus --log-enable   995 ttys000    0:00.46 /usr/local/bin/gdb -silent -i mi -nx  1004 ttys001    0:00.03 -bash QuoteUnfortunately the last bits of the file were not flushed to disk. Not sure if,what they would have revealed. You could try to run Lazarus from a console (with --log-enable / but without --log-file) then you get the output in the console window, and might get the last line. [...] (gdb) <-break-insert -f foo> &"Function \"foo\" not defined.\n" ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr= "",pending="foo",times="0",original-location="foo"} (gdb) <-break-delete 1> ^done (gdb) <-break-insert main> ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr= "0x000118a0",func="PASCALMAIN",file="project1.lpr",fullname="/Users/mi guel/tmp/project1.lpr",line="20",thread- groups=["i1"],times="0",original-location="main"} (gdb) <-break-insert *71456> ^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr= "0x00011720",at="",thread-groups=["i1"],times="0",original- location="*71456"} (gdb) <-break-insert +0> ^done,bkpt={number="4",type="breakpoint",disp="keep",enabled="y",addr= "0x00011855",func="PASCALMAIN",file="project1.lpr",fullname="/Users/mi guel/tmp/project1.lpr",line="6",thread- groups=["i1"],times="0",original- location="/Users/miguel/tmp/project1.lpr:+0"} (gdb) <-exec-run> =thread-group-started,id="i1",pid="997" =thread-created,id="1",group-id="i1" =thread-exited,id="1",group-id="i1" =thread-group-exited,id="i1" ---------------------------------------------------------------------- esvignolo · 2016-09-27 15:16 Hi, Method a) (i use this one, and work on sierra) 1) Boot to recovery 2) In recovery Tools->Open Terminal 3) run "csrutil disable" (without quotes) 4) Restart I can debug on Sierra. Quote from: mbdev on September 27, 2016, 04:22:08 pmHi, I reinstalled gdb and recreated the cert. The problem isn't solved :/ Thank you for your help Do you have more ideas? QuoteIf you run any antivirus make sure  that does not interfere.--> No antivirus QuoteMaybe this can be solved by changing some settings. In Menu "Tools" > Options. Then page "Debugger". There is a property grid. One entry is "InternalStartBreak". You can try the other values. Maybe gdsbEntry or gdsbMainAddress.--> No effect :/ QuoteBtw, when it hangs, did you try "reset debugger" from "run" menu?--> Yes , but no effect QuoteAlso once the IDE hangs, open another console, run a "ps ax" or equivalent, and see if gdb is still running. Also if your app is running.Output: ps   PID TTY           TIME CMD   936 ttys000    0:00.03 -bash   984 ttys000    0:07.96 ./lazarus --log-enable   995 ttys000    0:00.46 /usr/local/bin/gdb -silent -i mi -nx  1004 ttys001    0:00.03 -bash QuoteUnfortunately the last bits of the file were not flushed to disk. Not sure if,what they would have revealed. You could try to run Lazarus from a console (with --log-enable / but without --log-file) then you get the output in the console window, and might get the last line. [...] (gdb) <-break-insert -f foo> &"Function \"foo\" not defined.\n" ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr= "",pending="foo",times="0",original-location="foo"} (gdb) <-break-delete 1> ^done (gdb) <-break-insert main> ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr= "0x000118a0",func="PASCALMAIN",file="project1.lpr",fullname="/Users/mi guel/tmp/project1.lpr",line="20",thread- groups=["i1"],times="0",original-location="main"} (gdb) <-break-insert *71456> ^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr= "0x00011720",at="",thread-groups=["i1"],times="0",original- location="*71456"} (gdb) <-break-insert +0> ^done,bkpt={number="4",type="breakpoint",disp="keep",enabled="y",addr= "0x00011855",func="PASCALMAIN",file="project1.lpr",fullname="/Users/mi guel/tmp/project1.lpr",line="6",thread- groups=["i1"],times="0",original- location="/Users/miguel/tmp/project1.lpr:+0"} (gdb) <-exec-run> =thread-group-started,id="i1",pid="997" =thread-created,id="1",group-id="i1" =thread-exited,id="1",group-id="i1" =thread-group-exited,id="i1" ---------------------------------------------------------------------- Martin_fr · 2016-09-27 16:45 QuoteCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i =thread- exited,id="1",group-id="i1"=thread-group-exited,id="i1" I don't have a mac myself. But those 2 lines probably shouldn't be there. If I interpret them correctly your app exits (at least under gdb), before it even starts. (And its not in your code, since it never reaches the first line of your code. / it may be that no code at all is run) I have no idea why. 2 more things you can try: 1) Ensure there is a console open a 2nd terminal (shell), that you do not use. run the command "pty", it should print something like /dev/..... Copy this to "ConsoleTty" in the options property grid. Or see http://wiki.lazarus.freepascal.org/Debugger_Console_App#Redirec t_input_and_output_to_a_pty_.28terminal.29 2) Ensure all debug info is dwarf (but NOT dwarf 3) In project options debug is a setting for debug info type (dwarf or stabs) Set it to dwarf (gdb seems to be getting more issues with stabs) Unfortunately that has to be repeated for each package too. Or go to "additions and overrides" and add a line for ALL "*", set to -gw ---------------------------------------------------------------------- Jonas Maebe · 2016-09-28 10:14 Quote from: esvignolo on September 26, 2016, 05:03:10 pmHi, there are 2 methods at least: Method a) (i use this one, and work on sierra) 1) Boot to recovery 2) In recovery Tools->Open Terminal 3) run "csrutil disable" (without quotes) 4) Restart I don't understand how this by itself can change anything. Afaik, "csrutil disable" only disables SIP (system integrity protection). That functionality prevents programs from writing to certain system directories, even when they are executed as root. I have not seen any documentation anywhere that indicates it also affects the ability to debug other programs. In fact, e.g. OS X 10.10 (Yosemite) does not have SIP, but you cannot debug there either unless you codesign GDB. ---------------------------------------------------------------------- Jonas Maebe · 2016-09-28 10:39 Quote from: Jonas Maebe on September 28, 2016, 12:14:50 pmI don't understand how this by itself can change anything. Afaik, "csrutil disable" only disables SIP (system integrity protection). That functionality prevents programs from writing to certain system directories, even when they are executed as root. I have not seen any documentation anywhere that indicates it also affects the ability to debug other programs. Ah, it's here: https://developer.apple.com/library/content/documentati on/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtec tions/RuntimeProtections.html I haven't tried debugging on macOS 10.12 yet, I'll try it one of the coming days. ---------------------------------------------------------------------- nsl · 2016-10-03 11:55 Hi mbdev, I have the same problem in not being able to debug - in my case with OS-X El Capitan. I followed instructions in the Wiki to install GDB using Homebrew. This installs the latest version of GDB - 7.11. The Windows version of FPC 3.00 uses version 7.7 of GDB and I notice from the commits in the FPC trunk that there are changes being made to support GDB 7.10. Could it be that GDB 7.11 is just not compatible with FPC 3.00? Is there any way of installing an older version of GDB for OS-X? ---------------------------------------------------------------------- Jonas Maebe · 2016-10-03 11:57 Quote from: nsl on October 03, 2016, 01:55:21 pmCould it be that GDB 7.11 is just not compatible with FPC 3.00? No, it is a compatibility issue between gdb (any version) and macOS 10.12/Sierra. I haven't found a workaround yet (other than disabling SIP using csrutil, but that a bad hack). ---------------------------------------------------------------------- Thaddy · 2016-10-03 12:20 I heared that this:     Boot to recovery     Open Terminal     type csrutil disable is enough after reboot but I have to try it myself yet. ---------------------------------------------------------------------- tshahzad · 2016-10-05 07:51 GDB installed using fink and brew did not work for me. However GDB installed through macports did the trick and works. ---------------------------------------------------------------------- Thaddy · 2016-10-05 08:54 Yes, because I can confirm that one is correctly signed. Maybe of interest to Jonas et al. And should be in the wiki. ---------------------------------------------------------------------- mbdev · 2016-10-05 09:37 Hi, I tried to install gdb using MacPorts, but it failed :/ I did the following steps and attached a screenshot of the error: Xcode and Xcode Command Line Tools were already installed on my machine. GDB was removed using: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i brew remove gdb 1. I downloaded and installed MacPorts from: https://www.macports.org/install.php 2. I created a new terminal and executed: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i sudo port install gdb 3. After the installation progress gdb was installed and can be executed using ggdb. The normal gdb command will not work. When starting Lazarus I had to change the debugger path to /opt/local/bin/ggdb To display the path of gdb run: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i which -a ggdb 4. Moreover I had to assign the certificate ---------------------------------------------------------------------- Coldzer0 · 2016-10-22 03:39 at first if it's not signed sign it >> u will find a lot of tut on google then on IDE Click on Tools > Options > Debugger in Debugger_Startup_Options add this with quotes "--eval-command=set startup-with-shell off" and if u use gdb alone put this inside .gdbinit this one without quotes "set startup-with-shell off" ---------------------------------------------------------------------- mac01 · 2016-10-28 19:24 Any update on a fix for this. I too have upgraded to Mac OS Sierra and Xcode 8.1; and now have the same issue of no GDB. I have installed/re-installed GGDB currently running ggdb 7.9.1 I also get the same error when using Gdb (7.11.1). I have created new certificates and assigned to both ggd and ggdb ( laz-gdb and laz-gddb). I have also disabled sip, and also DE-installed Anti Virus. I have tried setting the debugger options Quote"--eval-command=set startup-with-shell off" and if u use gdb alone put this inside .gdbinit this one without quotes "set startup-with-shell off" When ever I try to run an application with debugger I get. Debugger Error.... "-exec-run" returned the error ",msg="During startup program terminated with signal SIG113, Real-time event 113." Any other ideas or possible solutions out there ? ---------------------------------------------------------------------- Phil · 2016-10-28 19:58 Quote from: mac01 on October 28, 2016, 09:24:43 pmAny other ideas or possible solutions out there ? If necessary, you can always debug any executable with the debugger included with Xcode. Open a Terminal window and run it like this:   lldb myprogram.app If you're familiar with gdb command-line commands, here's the mapping from gdb to lldb: http://lldb.llvm.org/lldb-gdb.html ---------------------------------------------------------------------- mac01 · 2016-10-28 21:49 Hi Phil, Thanks for that;  I will definitely use that for the moment until the integration of the debugger can be fixed. Not ideal obviously; as setting breakpoints etc on the fly as far as  can see is not possible. Again thanks for the info. ---------------------------------------------------------------------- Phil · 2016-10-29 00:03 Quote from: mac01 on October 28, 2016, 11:49:57 pmNot ideal obviously; as setting breakpoints etc on the fly as far as  can see is not possible. Sure you can. You just have to familiarize yourself with the lldb commands. Example: lldb myapp.app To set a breakpoint at line 75 of mainform.pas: breakpoint set -f mainform.pas -l 75 run When breakpoint hit, examine variable contents. Variable names must be all caps since that's how they appear in debug info: p VARNAME Continue with execution: c Exit debugger: q ---------------------------------------------------------------------- Martin V · 2016-10-31 08:44 Thank you for the lldb description. I have got MacOS 10.11, XCode 7 and the gdb IDE intetration also does not work. To find the position where my program crashes, the lldb terminal way is sufficient. But I do not manage that the source file name and line number is shown. In the IDE, I have got all debug options activated besides the "other debugging info". dwarf2 is selected. Any ideas? ---------------------------------------------------------------------- ThierryJ · 2016-10-31 16:16 Hello, Under OSX 10.11.5 I was able to debug normally. Than I have made the upgrade to MacOS 10.12 and... everything was still OK ! No problems. Than I made the upgrade to MacOS 10.12.1, and the debugger was once mode broken. I have tried to sign ggdb and/or to stop the security system, either partially or totally, no success. I decided to rollback to 10.12, and it works. But I hate to be faced to such an instability. ---------------------------------------------------------------------- mac01 · 2016-10-31 16:24 Hi I agree; after days of trying all kinds of things. I decided to go back to El Capitan. All working now.. I will watch threads and posts for any updates; in case at some time I want to try again. ---------------------------------------------------------------------- ThierryJ · 2016-10-31 17:44 @mac01 Note : I have been able to migrate to Sierra (10.12) easily. In fact I have done nothing. Than the last update to 10.12.1  broke the stuff. ---------------------------------------------------------------------- Phil · 2016-10-31 23:46 Quote from: Martin V on October 31, 2016, 09:44:28 amTo find the position where my program crashes, the lldb terminal way is sufficient. But I do not manage that the source file name and line number is shown. Sorry, I'm not sure I follow what you're asking. Are you asking, how to generate a backtrace? Same as gdb: bt How to disable application-level exception handling? In gdb, it's this:  break fpc_raiseexception In lldb, it's this:  breakpoint set -n fpc_raiseexception Works fine here with, for example, an exception raised like this: procedure TForm1.Button1Click(Sender: TObject); begin   raise Exception.Create('Some exception would occur'); end; Displays this:   * frame #0: 0x0001d670 project1`FPC_RAISEEXCEPTION     frame #1: 0x00037b9c project1`BUTTON1CLICK(this=0x00654d30, SENDER=0x00657890) + 60 at unit1.pas:31     frame #2: 0x00104d08 project1`CLICK(this=0x00657890) + 88 at control.inc:2736     frame #3: 0x0013d94d project1`CLICK(this=0x00657890) + 29 at buttoncontrol.inc:54     frame #4: 0x0013dfcd project1`CLICK(this=0x00657890) + 61 at buttons.inc:169 etc... ---------------------------------------------------------------------- Phil · 2016-10-31 23:56 Quote from: ThierryJ on October 31, 2016, 06:44:58 pm@mac01 Note : I have been able to migrate to Sierra (10.12) easily. In fact I have done nothing. Than the last update to 10.12.1  broke the stuff. The GDB debugger is part of GNU. Xcode does not use GNU tools (gcc, gdb) anymore. Xcode uses LLVM. LLVM's debugger is LLDB. No surprise that unsupported software might eventually stop working. Some links of interest: https://developer.apple.com/library/content/documentation/IDEs/Concept ual/gdb_to_lldb_transition_guide/document/lldb-terminal-workflow- tutorial.html http://lldb.llvm.org/ Even Eclipse is adding support for LLDB: https://wiki.eclipse.org/CDT/User/FAQ#How_do_I_get_the_LLDB_debugger.3 F ---------------------------------------------------------------------- Martin V · 2016-11-01 07:40 Thank you all for your hints. Now I managed to get the line where my program crashes. Here's the step-by-step explanation: 1. start lldb from the terminal: lldb myprog.app -- optionalparameters 2. enter: breakpoint set -n fpc_raisceexception 3: enter: run Now the program runs, let it crash, the stack trace address list with hex addresses appears. 4. enter: bt Now the program line numbers and other information is shown, your program is frozen 5. enter: finish program runs again and shows its own error message. I have another bug where my program simply ends without exeption. Even running via lldb let me only get a runtime error number and hex addresses. Typing "bt" does not work because the thread has already ended. How can I convert the addresses into source line numbers? But I still don't understand why the lldb integration does not work on my El Captain MacosX. I have got an older Mac with 10.6 with fpc 2.6 and there it did not work, too. ---------------------------------------------------------------------- esvignolo · 2016-11-01 10:18 Maybe is a good idea, make a app wich make translation from GDB to LLDB, the commands are similar, and if this app do the work, possible no changes need on lazarus. Only need to call to this app (like GDB) and this one call LLDB. Quote from: Phil on November 01, 2016, 12:56:22 amQuote from: ThierryJ on October 31, 2016, 06:44:58 pm@mac01 Note : I have been able to migrate to Sierra (10.12) easily. In fact I have done nothing. Than the last update to 10.12.1  broke the stuff. The GDB debugger is part of GNU. Xcode does not use GNU tools (gcc, gdb) anymore. Xcode uses LLVM. LLVM's debugger is LLDB. No surprise that unsupported software might eventually stop working. Some links of interest: https://developer.apple.com/library/content/documentation/IDEs/Concept ual/gdb_to_lldb_transition_guide/document/lldb-terminal-workflow- tutorial.html http://lldb.llvm.org/ Even Eclipse is adding support for LLDB: https://wiki.eclipse.org/CDT/User/FAQ#How_do_I_get_the_LLDB_debugger.3 F ---------------------------------------------------------------------- Phil · 2016-11-01 14:16 Quote from: Martin V on November 01, 2016, 08:40:21 amI have another bug where my program simply ends without exeption. Even running via lldb let me only get a runtime error number and hex addresses. Typing "bt" does not work because the thread has already ended. How can I convert the addresses into source line numbers? Did you try a thread backtrace? Post a simple example that demonstrates the problem and maybe somebody can look at it. ---------------------------------------------------------------------- Phil · 2016-11-01 14:19 Quote from: esvignolo on November 01, 2016, 11:18:35 amMaybe is a good idea, make a app wich make translation from GDB to LLDB, the commands are similar, and if this app do the work, possible no changes need on lazarus. Only need to call to this app (like GDB) and this one call LLDB. I won't pretend to know anything about debugger integration. All I know about lldb is what I see on the lldb site, that it has both a C++ and Python interface: http://lldb.llvm.org/ ---------------------------------------------------------------------- cpbns · 2016-11-06 20:33 i just found a possible solution to the problem in one blog: One guy developed a patch to gdb 7.12 concerning the task port mechanism. See last entry of: http://sourceware-org.1504.n7.nabble.com/gdb-on-macOS-10-12-quot- Sierra-quot-td415708.html#a415940 I myself can't develop this patch further, but it looks that the problem lays on gdb side. ---------------------------------------------------------------------- Coldzer0 · 2016-11-11 14:37 Here's the Patched Version Compiled and tested >> Mac OS "Sierra 10.12.1 (16B2555)" https://mega.nz/#!VkBWVJ7J!LzA51cXfWPK_o7TrNz6jU5jMaNGGmkgH-tj5kj-DIpI i test it with Codetyphon and Lazarus works fine please test and tell me if it work to sign it https://sourceware.org/gdb/wiki/BuildingOnDarwin On 10.12 (Sierra) or later with SIP, you need to run this: echo "set startup-with-shell off" >> ~/.gdbinit ---------------------------------------------------------------------- cpbns · 2016-11-11 19:01 Fine Work. Thanks. But, sorry, after new installation of gdb by home-brew (i guess its the same version of your link) and new codesigning(and restart of the machine), verifying in gdb "startup-with-shell off" was correctly set by .gdbinit, next problem arose (OSX 10.12.1): "During startup program terminated with signal ?, Unknown signal." i tried different debugger option in Lazarus> no change. Any idea? ---------------------------------------------------------------------- cpbns · 2016-11-11 21:08 To add to my last reply. After same tests i finally succeed by applying "csrutil enable --without debug" during startup the machine mit CMD+R ! Thats it. Lazarus and GDB work fine now!! Thank you to all of you. ---------------------------------------------------------------------- xaver13 · 2016-11-12 12:03 hello, I downloaded gdb from link above here then I ran sudo cp /Users/jiricvrk/Downloads/gdb/gdb /usr/local/bin Lazarus updates debug path automatically to  /usr/local/bin/gdb and after cmd+r csrutil enable --without debug  .. I am afraid, that nothing happened Returned requesting unsupported configuration I decided to try csruti disable But now I get:  Python Exception No module named gdb: /usr/local/bin/gdb:warning Could not load the Python gdb module from /usr/local/Cellar/gdb/7.2_1/share/gdb/python .. suggest passing --data-directory=/path/to/gdb/data-directory …The GDB command: "-exec-run" returned the error: ",msg="Unable to find Mach task port for process-id 474: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated()"" I used code sign, but get ..already signed... Jiris-Mac:~ jiricvrk$ sudo codesign -s gdb-cert  /usr/local/bin/gdb Password: /usr/local/bin/gdb: is already signed Jiris-Mac:~ jiricvrk$Jiris-Mac:~ jiricvrk$ sudo codesign -v   /usr/local/bin/gdb NOTHING RETURNED I tried  /usr/local/bin/gdb --data-directory /usr/local/bin without success. Any ideas, please? ---------------------------------------------------------------------- cpbns · 2016-11-12 14:55 I don't know if i can help you. But because i ran into similar problems, let me describe my procedure, which in the end succeeded: - I first downloaded too the gdb-exe, renamed the old gdb-exe and copied the new one into the gdb-directory. GdB-Start showed same error-message (SIG1139 ..). I gave codesign with the same certificate again. Restart gdb: Same error. - Therefore i decided to delete the complete gdb-installation directory (also in trash!). - delete the certificate in key manager (csrutil status was :  all enabled!) - gave: "homebrew install gdb" (Homebrew , a packetmanger for mac)   the 7.12.1 gdb version was installed, and what i saw into the dir /usr/local/bin, formerly it was /local/bin - creation of a new certificate (for code, system etc.) with a new certificate name, to avoid any mismatch - codesign -s ...gdb - restarting the machine - gdb results into error SIG ? - trying different debugger options, with no success - restarting machine again with CMD+R and csrutil enable --without debug - checking csrutil status - reinstalling lazarus (your applications are not deleted) - checking path of debugger in lazarus >> NOW, Everything went allright! So, i cannot explain, which of these steps are important. But what i see is that codesign seems to me a complicated process, in which it can't be seen by the user, what the operating system is really doing(f.i. are links followed up to the exec-files? are both links and exe code signed? etc.) I hope i could help for your trials. Good luck! ---------------------------------------------------------------------- xaver13 · 2016-11-12 16:10 Thank you cpbns! I erased my gdb. Then I installed brew install gdb and signed it  codesign -s gdb-cert  /usr/local/Cellar/gdb/7.12_1/bin/gdb then runed codesign -s gdb-cert  /usr/local/Cellar/gdb/7.12_1/bin/gdb and for me it was all, Lazarus started working,   csrutil was disabled from prior ---------------------------------------------------------------------- Brian Coleman · 2016-11-12 16:23 Hi, Hi, Some people have mentioned the possibility of running Lazarus under Sierra WITHOUT THE DEBUGGER. For making minimal changes to my already functional program, I'm sure I could live with this, at least for the moment. Maybe someone might kindly let me know WHAT HAS TO BE DONE TO BYPASS THE DEBUGGER. Maybe this is a naive question, but I'm a relative amateur. Brian ---------------------------------------------------------------------- Brian Coleman · 2016-11-17 12:59 Hi, Found the simple answer - not immenditely apparent  - in the options debugger menu. However, program will not compile under Sierra. Message (Lazarus 1.4.4): Compiling package FCL 1.0.1: Exit code 13, Errors 11 ---------------------------------------------------------------------- xinyiman · 2016-11-26 19:21 Hi, well I can not run away the debugger on Sierra. Come I do a Fix? ---------------------------------------------------------------------- tolisoft · 2016-12-02 13:00 I have tried everything mentioned in this thread but I did not manage to have working debugger with lazarus. Any new ideas? ---------------------------------------------------------------------- ZXDunny · 2016-12-07 09:49 FWIW, Debugging in Delphi has also died a death with Sierra 10.12.1 - Embarcadero have been unable to fix it, though they said a month or so ago that a fix was coming "soon"... and in the interim, Update 2 has been released for Delphi Berlin and no fix has been forthcoming. ---------------------------------------------------------------------- Jonas Maebe · 2016-12-07 10:52 It has been fixed in the current git version of gdb. The required change doesn't seem to have been picked up yet by macports though. I don't know about fink. ---------------------------------------------------------------------- xaver13 · 2016-12-11 08:57 I have very much troubles with it and later I recognise that restart computer is needed - like in this link http://stackoverflow.com/questions/13913818/how-to-get-a-codesigned- gdb-on-osx ---------------------------------------------------------------------- MISV · 2017-01-26 23:14 Any news on recommended solution for this? I am still using Lazarus 1.4.4 / homebrew (but can upgrade/change both if necessary) i.e. is there now an easy way to get a signed gdb through homebrew or macports which will "just work". It is a pitty Mac changes dev tools all the time ---------------------------------------------------------------------- Phil · 2017-01-26 23:21 Quote from: MISV on January 27, 2017, 12:14:35 amIt is a pitty Mac changes dev tools all the time The supported debugger on OS X has been lldb for some years. gdb was put out to pasture a long time ago. ---------------------------------------------------------------------- Jonas Maebe · 2017-01-27 16:35 Quote from: MISV on January 27, 2017, 12:14:35 amAny news on recommended solution for this? I am still using Lazarus 1.4.4 / homebrew (but can upgrade/change both if necessary) gdb 7.12.1 was just released, and it contains the necessary patches to support debugging on macOS 10.12/Sierra. If you can get fink and/or MacPorts to upgrade to that version, it should work. You do currently have give the gdb command "set startup-with-shell off" before you can launch programs and debug them on macOS 10.12/Sierra. ---------------------------------------------------------------------- MISV · 2017-01-30 12:33 I will try - will need debugging functionality soon ---------------------------------------------------------------------- tshahzad · 2017-02-15 13:05 Is there any plan to implement lldb for Lazarus. GDB will always create issues in newer versions of OSX. Thanks, Tauseef ---------------------------------------------------------------------- Phil · 2017-02-15 15:33 Quote from: tshahzad on February 15, 2017, 02:05:36 pmIs there any plan to implement lldb for Lazarus. I doubt it. It looks as though the plan from about 3 years ago was to replace gdb entirely on Mac. See item 2 here: http://lazarus-dev.blogspot.com/2014/05/de-bug-wars-new-hope.html I don't know anything about the status of that effort. Note that you _can_ debug now with lldb. Just run it from the command line:   lldb yourapp.app Here's the equivalent lldb command: http://lldb.llvm.org/lldb-gdb.html Also, it is possible to debug a Lazarus project with lldb within Xcode. It requires creating a little dummy Xcode project, but it is possible. ---------------------------------------------------------------------- Hansaplast · 2017-03-26 17:08 Quote from: Jonas Maebe on January 27, 2017, 05:35:42 pmQuote from: MISV on January 27, 2017, 12:14:35 amAny news on recommended solution for this? I am still using Lazarus 1.4.4 / homebrew (but can upgrade/change both if necessary) gdb 7.12.1 was just released, and it contains the necessary patches to support debugging on macOS 10.12/Sierra. If you can get fink and/or MacPorts to upgrade to that version, it should work. You do currently have give the gdb command "set startup-with-shell off" before you can launch programs and debug them on macOS 10.12/Sierra. This worked for me as well, however adding "set startup-with-shell off" to ~/.gdbinit didn't work. Instead I added this to the "Debugger_Startup_option" in Lazarus in the "Options" - "Debugger" - "General" window:   "--eval-command=set startup-with-shell off" (including the double quotes!!!) This does display a message each time I run a project, but it works (incl. break points and such). ---------------------------------------------------------------------- MISV · 2017-03-28 18:39 I still can not get it working I have Lazarus 1.6.4 on MacOS Sierra 10.12.3 I today installed MacPorts https://www.macports.org/install.php and through that gdb by "sudo port install gdb" I rebooted after initial failure I then in  Lazarus > Tools > Options > Debugger > Debugger_Startup_Options  added this with quotes "--eval-command=set startup-with-shell off" Two new hings happened 1) I got the message: QuoteInitialization output: =cmd-param- changed,param="startup-with-shell",value="off"2) I got prompted for  password QuoteBut in the end I get the same debugger error on startup:  The GDB command: "-exec-run" returned the error: ",msg="During statup program terminated with signal SIG113, Real-time event 113"" I am right now looking at: http://stackoverflow.com/questions/33162757/how-to-install-gdb- debugger-in-mac-osx-el-capitan ---------------------------------------------------------------------- Jonas Maebe · 2017-03-28 18:41 According to https://github.com/macports/macports- ports/blob/master/devel/gdb/Portfile , MacPorts still has gdb 7.12 while you need 7.12.1 for macOS 10.12 ---------------------------------------------------------------------- MISV · 2017-03-28 18:52 Thanks! maybe I misunderstood other posts here. Is there any automated system on Mac (i.e. like MacPorts, HomeBrew etc.) that can handle installing GDB and which has 7.12.1 or newer? Otherwise I guess I will try a more manual approach --update-- fink should have it: http://pdb.finkproject.org/pdb/browse.php?summary=gdb brew should http://braumeister.org/formula/gdb --brew help-- When I tred write "brew install gdb" it claimed I already got newest version 7.8.1 of gdb (this was after running "brew update" ) Solution: Unlink old version first I have now also signed using: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i codesign -s gdb-cert  /usr/local/Cellar/gdb/7.12.1/bin/gdb --This combination seems to work for me-- ---------------------------------------------------------------------- Hansaplast · 2017-03-28 19:23 FYI: I'm using 7.12.1 as well, through HomeBrew, and the problem remains, even though others seem to have had success with this. I described the steps I followed here. Adding the "--eval-command=set startup-with-shell off" to Lazarus > Tools > Options > Debugger > Debugger_Startup_Options resolved it for me. Adding "set startup-with-shell off" (without the quotes) to ~/.gdbinit did not seem to work on my setup. ---------------------------------------------------------------------- tigerA15 · 2017-04-21 15:43 Quote from: MISV on March 28, 2017, 08:52:24 pmThanks! maybe I misunderstood other posts here. Is there any automated system on Mac (i.e. like MacPorts, HomeBrew etc.) that can handle installing GDB and which has 7.12.1 or newer? Otherwise I guess I will try a more manual approach --update-- fink should have it: http://pdb.finkproject.org/pdb/browse.php?summary=gdb brew should http://braumeister.org/formula/gdb --brew help-- When I tred write "brew install gdb" it claimed I already got newest version 7.8.1 of gdb (this was after running "brew update" ) Solution: Unlink old version first I have now also signed using: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i codesign -s gdb-cert  /usr/local/Cellar/gdb/7.12.1/bin/gdb --This combination seems to work for me-- marked & thanks . ---------------------------------------------------------------------- manhu · 2018-07-03 13:07 If anyone has the same Problem. Try Following this: A better alternative is to install gdb from Macports: sudo port install gdb Quotein  Lazarus > Tools > Options > Debugger > Debugger_Startup_Options  added this with quotes "--eval-command=set startup-with-shell off" also: codesign -s gdb-cert with the right Settings ( check the Terminal when installing Macports > sudo port install gdb ) Shalom Manfred