# Debugging some wrapped Fortran code

**URL:** <https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610>\
**Category:** General Usage\
**Tags:** fortran\
**Created:** [September 14, 2020, 9:10pm UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610 "2020-09-14T21:10:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [September 14, 2020, 9:10pm UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610/1 "2020-09-14T21:10:45Z")

</div>

I’ve created a Julia package that provides a wrapper around a Fortran subroutine. I’d like to build my Fortran shared library with debug information and use gdb to set a break point in the Fortran code. Is that possible to do, while still calling the Fortran code from Julia? I tried attaching gdb to Julia before I call my wrapper function, but it failed to attach.

Thanks!  
Daniel

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [September 15, 2020, 3:03pm UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610/2 "2020-09-15T15:03:34Z")

</div>

Here’s some more detail on what’s going on. When I try to attach `gdb` to the `julia` process, I get the following:

```bash
(gdb) attach 86616
Attaching to process 86616
Unable to find Mach task port for process-id 86616: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

```

I’m on a Mac. I did some searching and found that some steps to configure a certificate for gdb: [PermissionsDarwin - GDB Wiki](https://sourceware.org/gdb/wiki/PermissionsDarwin). However, even after following those steps, my issue persisted. At the bottom of the same page, they have a command to filter the logs pertaining to the `taskgated` process. When I do that and try again, I get the following message:

```bash
   0 kernel: (AppleMobileFileIntegrity) macOSTaskPolicy: (org.gnu.gdb) may not get the taskport of (julia) (pid: 86616): (julia) is hardened, (julia) doesn't have get-task-allow, (org.gnu.gdb) is a declared debugger

```

This is pretty far over my head already. Does anyone have any ideas?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [September 15, 2020, 5:26pm UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610/3 "2020-09-15T17:26:06Z")

</div>

Just in case there was a step missing: make sure and follow everything in sections 1.3 and 1.4 of the linked GDB document (probably including the reboot, unfortunately). Then be sure to _check_ the `gdb` entitlements. These _must_ include `get-task-allow` as listed by with `codesign -d --entitlements - $(which gdb)` (from the final paragraph of section 1.3. See also [this thread](https://developer.apple.com/forums/thread/127544) which might be helpful.

That said, I would generally suggest using LLDB on macOS. It is the platform-native debugger, supported by the OS publisher etc. There is still a lot of (arguably) missing functionality relative to GDB, and some major performance issues. But it generally works as expected on macOS, whereas (in my experience) GDB is very hit-or-miss.

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [September 15, 2020, 5:39pm UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610/4 "2020-09-15T17:39:28Z")

</div>

Thanks for the suggestions!

I did do the reboot and I confirmed that `get-task-allow` is included in the entitlements.

I also tried `lldb`. I’ve always used `gdb`, so perhaps I just don’t know what I’m doing, but I tried the following:

```bash
(lldb) attach 95197
error: attach failed: Error 1

```

```bash
(lldb) process attach --pid 95197
error: attach failed: Error 1

```

I guess I need to go through a similar process to make sure `lldb` has the `get-task-allow` entitlement…

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [September 15, 2020, 5:45pm UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610/5 "2020-09-15T17:45:08Z")

</div>

Looking at the thread you linked to… Is it the case that `julia` needs to also have the `get-task-allow` entitlement? Mine doesn’t:

```bash
$ codesign -d --entitlements - $(which julia)
Executable=/Applications/Julia-1.5.app/Contents/Resources/julia/bin/julia
��qq�<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.security.automation.apple-events</key>
	<true/>
	<key>com.apple.security.cs.allow-dyld-environment-variables</key>
	<true/>
	<key>com.apple.security.cs.allow-jit</key>
	<true/>
	<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
	<true/>
	<key>com.apple.security.cs.debugger</key>
	<true/>
	<key>com.apple.security.cs.disable-library-validation</key>
	<true/>
	<key>com.apple.security.device.audio-input</key>
	<true/>
	<key>com.apple.security.device.camera</key>
	<true/>
</dict>
</plist>

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [September 15, 2020, 6:10pm UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610/6 "2020-09-15T18:10:16Z")

</div>

[https://github.com/JuliaLang/julia/pull/37069](https://github.com/JuliaLang/julia/pull/37069)

Should be in 1.5.1.

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [September 15, 2020, 6:24pm UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610/7 "2020-09-15T18:24:43Z")

</div>

Thanks! I just downloaded it and `get-task-allow` is indeed now listed:

```bash
$ codesign -d --entitlements :- $(which julia)
Executable=/Applications/Julia-1.5.app/Contents/Resources/julia/bin/julia
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.security.automation.apple-events</key>
	<true/>
	<key>com.apple.security.cs.get-task-allow</key>
	<true/>
	<key>com.apple.security.cs.allow-dyld-environment-variables</key>
	<true/>
	<key>com.apple.security.cs.allow-jit</key>
	<true/>
	<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
	<true/>
	<key>com.apple.security.cs.debugger</key>
	<true/>
	<key>com.apple.security.cs.disable-library-validation</key>
	<true/>
	<key>com.apple.security.device.audio-input</key>
	<true/>
	<key>com.apple.security.device.camera</key>
	<true/>
</dict>
</plist>

```

But, unfortunately, I still can’t attach `lldb` to a `julia` process. When I try to attach it, I get this `taskgated` log entry:

```bash
   0 kernel: (AppleMobileFileIntegrity) macOSTaskPolicy: (com.apple.debugserver) may not get the taskport of (julia) (pid: 1523): (julia) is hardened, (julia) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger

```

I’m not sure why it says `julia` doesn’t have `get-task-allow`, when I can see that it clearly does.

---

<div class="post-metadata">

**Author:** ![notinaboat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/notinaboat/32/19302_2.png) [@notinaboat](https://discourse.julialang.org/u/notinaboat)\
**Post date:** [July 11, 2021, 12:15am UTC](https://discourse.julialang.org/t/debugging-some-wrapped-fortran-code/46610/8 "2021-07-11T00:15:56Z")

</div>

It should be “com.apple.security.get-task-allow” ? (delete the “.cs”)
