<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jason</title>
    <description>The latest articles on DEV Community by Jason (@jasonelwood).</description>
    <link>https://dev.to/jasonelwood</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F470391%2F7a66fc33-1847-422c-b119-f0c70f13a8ff.jpeg</url>
      <title>DEV Community: Jason</title>
      <link>https://dev.to/jasonelwood</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jasonelwood"/>
    <language>en</language>
    <item>
      <title>Xcode Man Page</title>
      <dc:creator>Jason</dc:creator>
      <pubDate>Tue, 14 Jun 2022 15:37:22 +0000</pubDate>
      <link>https://dev.to/jasonelwood/xcode-manpage-2l16</link>
      <guid>https://dev.to/jasonelwood/xcode-manpage-2l16</guid>
      <description>&lt;p&gt;&lt;strong&gt;What if Xcode had a man page? Well now it does.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Instead of searching all over the web for keyboard shortcuts, features, and other common questions you have about Xcode, wouldn't it be great if you could just open a Terminal window and search or browse the Xcode man page?&lt;/p&gt;

&lt;p&gt;Impress your friends and coworkers when you go to this man page instead of wasting time searching all over the internet for answers to your Xcode questions. You'll want to keep it open in a tab at all times. &lt;/p&gt;

&lt;p&gt;Installation:&lt;/p&gt;

&lt;p&gt;1) Create the directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir /usr/local/man/man1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Download the Xcode manpage:&lt;br&gt;
&lt;a href="https://github.com/jason-elwood/xcode-man-page/blob/master/xcode.1.gz"&gt;Download Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3) Copy the manpage to your direcory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo cp xcode.1.gz /usr/local/man/man1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4) Add new path to the /etc/man.conf file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo vim /etc/man.conf
# Add the following line where you see the other MANPATH entries:
MANPATH /usr/local/man
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can use the xcode manpage like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;man xcode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all there is to it.&lt;/p&gt;

&lt;p&gt;Please let me know what you think. It is a work in progress and I welcome bug reports, suggestions, etc.&lt;/p&gt;

&lt;p&gt;Thanks and enjoy!&lt;/p&gt;

</description>
      <category>xcode</category>
      <category>manpage</category>
      <category>swift</category>
      <category>programming</category>
    </item>
    <item>
      <title>Must-have Vim config</title>
      <dc:creator>Jason</dc:creator>
      <pubDate>Mon, 28 Sep 2020 06:44:50 +0000</pubDate>
      <link>https://dev.to/jasonelwood/must-have-vim-config-4j3i</link>
      <guid>https://dev.to/jasonelwood/must-have-vim-config-4j3i</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg7cnaqss3xufyeb8zx6t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg7cnaqss3xufyeb8zx6t.png" alt=".vimrc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Get the most out of Vim.
&lt;/h1&gt;

&lt;p&gt;Vim is pretty great right out of the box but .vimrc settings are a simple way to elevate your enjoyment of vim and speed up your workflow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;:imap jj &amp;lt;Esc&amp;gt;
:imap kk &amp;lt;C-N&amp;gt;

:set &lt;span class="nv"&gt;tabstop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4
:set &lt;span class="nv"&gt;shiftwidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4
:set expandtab
:set autoindent
:set number
:set &lt;span class="nv"&gt;term&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;screen-256color
:set &lt;span class="nv"&gt;pastetoggle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;f5&amp;gt;

:colorscheme 256_noir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just drop these lines in a file called .vimrc file and save it to your home directory.&lt;/p&gt;

&lt;p&gt;This config file includes the 256_noir Vim color scheme. You can download the scheme here:&lt;br&gt;
&lt;a href="https://github.com/andreasvc/vim-256noir" rel="noopener noreferrer"&gt;https://github.com/andreasvc/vim-256noir&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Drop this file here:&lt;br&gt;
~/.vim/colors &lt;/p&gt;

&lt;p&gt;If this scheme doesn't work for you, you can omit the last line in the .vimrc file or download and use a different scheme.&lt;/p&gt;

&lt;p&gt;As for mapping  to jj, I can't tell you how much this improves my workflow. Being able to quickly type jj instead of reaching for the esc every time I need to enter command mode is invaluable.&lt;/p&gt;

&lt;p&gt;This is just the beginning. My .vimrc file is over 100 lines. Let me know if you want me to share it. I hope this helps get you started. Let me know what you think. &lt;/p&gt;

</description>
      <category>vim</category>
      <category>linux</category>
    </item>
    <item>
      <title>Setup gdb on macOS in 2020</title>
      <dc:creator>Jason</dc:creator>
      <pubDate>Thu, 17 Sep 2020 02:21:35 +0000</pubDate>
      <link>https://dev.to/jasonelwood/setup-gdb-on-macos-in-2020-489k</link>
      <guid>https://dev.to/jasonelwood/setup-gdb-on-macos-in-2020-489k</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu8xv0q71fips00xi0pbw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu8xv0q71fips00xi0pbw.png" alt="gdb on macOS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Beginning with Mavericks (macOS 10.9) Xcode stopped supporting the gdb debugger. Below are steps to walk you through solving this not-so-straightforward problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install gdb&lt;/li&gt;
&lt;li&gt;Generate a certificate&lt;/li&gt;
&lt;li&gt;Sign certificate for gdb&lt;/li&gt;
&lt;li&gt;Create a gdb command file&lt;/li&gt;
&lt;li&gt;Generating builds&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Install gdb &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Open the Terminal app, Applications &amp;gt; Utilities &amp;gt; Terminal. This guide uses the Terminal throughout, so it's best to leave it open until you have finished all of the steps.&lt;/p&gt;

&lt;p&gt;If you don't already have gdb on your system, then you'll need to install it. I'm going to show you how to install gdb by using &lt;a href="https://brew.sh/index.html" rel="noopener noreferrer"&gt;Homebrew&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Start by verifying whether you already have gdb installed on your system. Type the following in Terminal:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

gdb &lt;span class="nt"&gt;--version&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you have gdb on your system already, you can skip to the Generate a certificate step. If you received an error, then you'll need to install gdb using Homebrew. &lt;/p&gt;

&lt;p&gt;Verify whether or not you have Homebrew by typing:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

brew &lt;span class="nt"&gt;--version&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If Homebrew isn't already installed on your system, you'll need to install it. Using Terminal, type (or copy and paste) the following command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

/bin/bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/master/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once Homebrew is installed, you can install gdb. The current version of gdb as of this writing is 9.2, which is confirmed working on Catalina as of Sept. 2020.&lt;/p&gt;

&lt;p&gt;In order to install gdb type the command: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

brew &lt;span class="nb"&gt;install &lt;/span&gt;gdb


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can confirm whether gdb is installed properly by running:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

gdb &lt;span class="nt"&gt;--version&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If everything went well then you're ready to move on to the next step!&lt;/p&gt;

&lt;h3&gt;
  
  
  Generate a certificate &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If it was as simple as installing gdb, I wouldn't have made this guide! If you attempt to debug a file now, you will get errors and unexpected behavior because the Darwin kernel does not allow gdb to control another process without having special rights. Fortunately the rest of this guide walks you through all of the steps you'll need in order to use gdb effectively on your Mac.&lt;/p&gt;

&lt;p&gt;In order to give gdb the permissions it needs, you'll need to generate a self-signed certificate.&lt;/p&gt;

&lt;p&gt;Here are the steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launch Keychain Access application: Applications &amp;gt; Utilities &amp;gt; Keychain Access.&lt;/li&gt;
&lt;li&gt;From the Keychains list on the left, right-click on the System item and select Unlock Keychain "System".&lt;/li&gt;
&lt;li&gt;From the toolbar, go to Keychain Access &amp;gt; Certificate Assistant &amp;gt; Create a Certificate.&lt;/li&gt;
&lt;li&gt;Choose a name (e.g. gdb-cert).&lt;/li&gt;
&lt;li&gt;Set Identity Type to Self Signed Root.&lt;/li&gt;
&lt;li&gt;Set Certificate Type to Code Signing.&lt;/li&gt;
&lt;li&gt;Check the Let me override defaults checkbox.&lt;/li&gt;
&lt;li&gt;At this point, you can go on with the installation process until you get the Specify a Location For The Certificate dialogue box. Here you need to set Keychain to System. Finally, you can click on the Create button.&lt;/li&gt;
&lt;li&gt;After these steps, you can see the new certificate under System keychains. From the contextual menu of the newly created certificate (right-click on it) select the Get info option. In the dialogue box, expand the Trust item and set Code signing to Always Trust.&lt;/li&gt;
&lt;li&gt;Then, from the Keychains list on the left, right-click on the System item and select Lock Keychain "System".&lt;/li&gt;
&lt;li&gt;Finally, reboot your system.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Sign certificate for gdb &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Now you'll need to sign the certificate. Create a file called &lt;strong&gt;gdb-entitlement.xml&lt;/strong&gt;. This allows macOS to trust gdb operations for debugging. Type the following into the xml file you just created, and save it:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;

&lt;span class="cp"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;plist&lt;/span&gt; &lt;span class="na"&gt;version=&lt;/span&gt;&lt;span class="s"&gt;"1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;dict&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;com.apple.security.cs.allow-jit&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;true/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;com.apple.security.cs.allow-unsigned-executable-memory&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;true/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;com.apple.security.cs.allow-dyld-environment-variables&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;true/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;com.apple.security.cs.disable-library-validation&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;true/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;com.apple.security.cs.disable-executable-page-protection&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;true/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;com.apple.security.cs.debugger&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;true/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;com.apple.security.get-task-allow&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;true/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dict&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/plist&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now back in the Terminal app, navigate to the directory where you saved the xml file.&lt;br&gt;
*note. &amp;lt;gdbPath&amp;gt; in the following command is your path to gdb. It will be something like&lt;br&gt;
/usr/local/Cellar/gdb/version/bin/gdb&lt;br&gt;
or&lt;br&gt;
/usr/local/bin/gdb.&lt;br&gt;
You can find out for sure by typing the following in the terminal:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

which gdb


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Replace &amp;lt;gdbPath&amp;gt; with your path to gdb.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

codesign &lt;span class="nt"&gt;--entitlements&lt;/span&gt; gdb-entitlement.xml &lt;span class="nt"&gt;-fs&lt;/span&gt; gdb-cert &amp;lt;gdbPath&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;where gdb-cert is the name of the certificate you created earlier, and gdbPath is the full path to your gdb binary file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a gdb command file &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;For this step, do one of the following.&lt;br&gt;
Either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the home directory, create a new file called &lt;strong&gt;.gdbinit&lt;/strong&gt;. Write the following command into it and save:
```bash
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;set startup-with-shell off&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;or 
* Type the following into the Terminal:
```bash


echo "set startup-with-shell off" &amp;gt;&amp;gt; ~/.gdbinit


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Generating builds &lt;a&gt;
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;We're almost there! If you tried debugging with gdb now, you would likely receive a "No symbol table is loaded" error. In order to solve this, you'll need to compile programs with the -ggdb option, as in the following example:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

gcc hello_world.c &lt;span class="nt"&gt;-o&lt;/span&gt; hello_world &lt;span class="nt"&gt;-ggdb&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;At this point you should be able to successfully debug your programs on Mac using gdb. Do a test by running (for example):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

gdb hello_world


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;and then from the gdb prompt, try creating a breakpoint:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;break &lt;/span&gt;main


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You should see something like the following:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

Breakpoint 1 at 0x100000de5: file hello_word.c, line 15.


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I hope you're seeing the results you expected! Leave a comment and let me know how it goes!&lt;/p&gt;

&lt;p&gt;Reference list:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.thomasvitale.com/how-to-setup-gdb-and-eclipse-to-debug-c-files-on-macos-sierra/" rel="noopener noreferrer"&gt;https://www.thomasvitale.com/how-to-setup-gdb-and-eclipse-to-debug-c-files-on-macos-sierra/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://coderwall.com/p/wyb2ug/how-fix-the-no-symbol-table-is-loaded-gdb-issue-on-mountain-lion" rel="noopener noreferrer"&gt;https://coderwall.com/p/wyb2ug/how-fix-the-no-symbol-table-is-loaded-gdb-issue-on-mountain-lion&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gdb</category>
      <category>macos</category>
      <category>debug</category>
      <category>cpp</category>
    </item>
  </channel>
</rss>
