Pstack a process on OSX 10.9
sudo /usr/libexec/stackshot -i -u -p <pid>
This appends a stack trace of all threads of the process in question to the file /Library/Logs/stackshot-syms.log . Consider to remove the file stackshot-syms.log before calling stackshot. See: stackshot(1)
Note: stackshot is no longer included with OS X 10.11 EL Capitan.
Use the lldb debugger instead:
echo "thread backtrace all" | lldb -p <pid>
lldb is part of the command line developer tools. If you don't have lldb on your machine, a popup will help with installing XCode.
Program doesn't stop after returning 0 from main
Or is the problem in the rest of the code?
Possibly. Perhaps you've corrupted your stack somehow, so that you're "returning" from main to someplace you didn't expect. We can't really know without an complete, verifiable example.
How can I make it finish after returning 0?
You can use the kill
command on MacOS to terminate it forcefully. Using the GUI task manager may or may not work.
But perhaps a more effective course of action would be to attach a debugger to the process and see what it's actually doing.
You could read this explanation on how to do this on MacOS with XCode - but I don't use MacOS, so I wouldn't know. Also, @SergeyA graciously suggests trying using pstack to get the process' current stack. Of course, if the stack has been garbled, there's no telling what you'll actually get.
Make sure the application is compiled with debugging information included.
Finally - it's probably better to run the program with a debugger attached in the first place, and set a breakpoint at the last cout <<
line.
Golang: Cannot get gdb working for Go programs using C libraries
You're experiencing issue 5221. A related question is this one.
This problem has been partially fixed for ELF files but remains open for the Mach format
which you are using. So I guess you have to wait for go 1.3 or the appropriate fix from tip
to have this resolved.
Basically the problem is that the linker you use for the compiled .c
files does not extract
the debug info from the object (.o
) files but refers to them. As they're deleted after the
build process, gdb can't read them.
As a workaround, you might try to run go build -work
for go-glfw
so that the build
directory is not removed and the object files remain accessible.
Related Topics
Perf-Report Show Value of CPU Register
Why Non-Pic Code Can't Be Totally Aslr Using Run-Time Fixups
How Uevents Get Triggered in Kernel
How to Capitalize First Letter of Each Line in Bash
Shell Script for Process Monitoring
How to Get Clearcase Stream Name by a Given View Path
Convert Multiple Sftp Command Lines to a Single Line Command Line
Linux Diff Get Only Line Number in the Output
(Delphi Linux) Ld-Linux.Exe: Error: Cannot Find -Lgcc_S
What Does Two Dots Before a Slash Mean? (../)
Capturing Display/Monitor Images, Sending Keyboard Input on Linux
Server Composer Install --No-Dev Killed
Start X86_64 Code on X86 (32Bit) Linux, Running on X86_64 Cpu
Bluez Blotoothctl Scan VS Hcitool Scan
What Length Can a Network Interface Name Have
Linux How to Add a File to a Specific Folder Within a Zip File