Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)


What links here:

Fixing GDB errors

Mac errors

“It seems that gdb needs a set startup-with-shell off line in .gdbinit to work corrected on macOS Sierra or later. (I’m not talking about gdb-dashboard; it’s gdb itself)” https://github.com/cyrus-and/gdb-dashboard/issues/81

Also, codesigning. If you are getting this in gdb on macOS while trying to run a program: Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))

  1. Open Keychain Access
    • In menu, open Keychain Access > Certificate Assistant > Create a certificate
  2. Give it a name (e.g. gdbc)
    • Identity type: Self Signed Root
    • Certificate type: Code Signing
    • Check: let me override defaults
    • Continue until “specify a location for…”
    • Set Keychain location to System
    • Create certificate and close Certificate Assistant.
    • Find certificate in System keychain.
    • Double click certificate
    • Expand Trust, set Code signing to always trust
    • Restart taskgated in terminal: killall taskgated
    • Codesign gdb using your certificate: codesign -fs gdbc /usr/local/bin/gdb
  3. Shut down your mac and restart in recovery mode (hold down command-R until apple logo appears)
    • Open terminal window
    • Modify System Integrity Protection to allow debugging: csrutil enable –without debug
    • Reboot your Mac. Debugging with gdb should now work as expected.

If the error is “python complete expression” or something like that

Copy this into a script:

#!/bin/env bash
mkdir -p ~/.gdbinit.d/
wget 'https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob_plain;f=gdb/python/lib/gdb/FrameDecorator.py' -O ~/.gdbinit.d/FrameDecorator.py
sed -i '1s/^/python gdb.COMPLETE_EXPRESSION = gdb.COMPLETE_SYMBOL\n/' .gdbinit
cat >>.gdbinit <<EOF
        python
        import imp
        gdb.FrameDecorator = imp.new_module('FrameDecorator')
        gdb.FrameDecorator.FrameDecorator = FrameDecorator
        end
        EOF

then run it

Repeating GET request in JS

function getMyData() {
    var xh = new XMLHttpRequest()
    var xlink = "wheremydatais.com"
    xh.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            console.log(JSON.parse(this.responseText));
            getMyData()
        }
    }
    xh.open("GET", xlink, true) // true/false for async
    xh.send()
}