title: VSCode: Debugger for C++ does not launch nor attach properly
body: <p>I am using:</p>
  
  <ul>
  <li>Ubuntu 16.04 (I know it is not supported officially)</li>
  <li>Latest VSCode version</li>
  <li>Latest "C/C++ for VSCode" version</li>
  </ul>
  
  <p>My project is a C++ project and the structure looks like this:</p>
  
  <ul>
  <li>/home/lvier/mainProject/fooProject <strong>(source code)</strong></li>
  <li>/home/lvier/mainProject/build/fooProject <strong>(binaries)</strong></li>
  </ul>
  
  <p>I am working in the sub-project "/home/lvier/mainProject/fooProject" and in "/home/lvier/mainProject/<strong>build</strong>/fooProject" there are many sub programs (lets say "foo", "foo_sub1", "foo_sub2" ...).</p>
  
  <p><strong>My goal:</strong> </p>
  
  <p>I want to start the program "foo" (which starts all other foo_sub-programs) and then, I want to debug a certain sub program (let's say "foo_sub1") by attaching to it. I am also fine with starting and debugging in the same time as long as I can debug the sub-program "foo_sub1". The main project itself does not contain any executables.</p>
  
  <p><strong>Some months ago</strong>, debugging <strong>was working with "attach"</strong>. For me it is <strong>not working anymore</strong> (because of VSCode updates and/or C/C++ extension updates). Here are my problems:</p>
  
  <ol>
  <li><p>Assume that "foo" is running. 
  When using the "C++ Attach"-config and setting "request": "attach" (which is getting highlighted as "not an accepted value"), it will ask for the property "processId" if it is not set. If I set "processId", the error "Attach not supported" pops up.
  If I use the "C++ Attach"-config with "request": "launch" (in the beginning this was autogenerated by the C/C++-extension), then the program finds the process id, tries to attach but then aborts with the message "Unable to start debugging. Commands are only accepted when the process is stopped." - what a surprise.</p></li>
  <li><p>Assume that "foo" is not running yet.
  When using the "C++ Launch"-config, the program starts but no UI elements appear. Instead, it starts with a new terminal popping up which says "warning gdb failed to set controlling terminal operation not permitted" <strong>for a brief moment</strong> and in the internal console of VSCode, it states that it stops at a certain line of code (a breakpoint not defined by me) and prints 
  "Stopped due to shared library event (no libraries added or removed)
  Loaded '/lib64/ld-linux-x86-64.so.2'. Symbols loaded.
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1"."
  From there I can't continue further and I have to manually terminate the program.</p></li>
  </ol>
  
  <p>When I use GDB without VSCode, i.e. just by native terminal, my program is starting properly but with VSCode, there seem to be some issues currently.</p>
  
  <p>This is my current, autogenerated config where I only edited the "cwd" and "program" paths (<strong>assume that the environment variable "${env.build_foo}" is set to "/home/lvier/mainProject/build/fooProject"</strong>):</p>
  
  <pre><code>{
      "version": "0.2.0",
      "configurations": [
          {
              "name": "C++ Launch",
              "type": "cppdbg",
              "request": "launch",
              "targetArchitecture": "x64",
              "program": "${env.build_foo}/foo",
              "args": [],
              "stopAtEntry": false,
              "cwd": "${workspaceRoot}",
              "environment": [],
              "externalConsole": true,
              "linux": {
                  "MIMode": "gdb"
              },
              "osx": {
                  "MIMode": "lldb"
              },
              "windows": {
                  "MIMode": "gdb"
              }
          },
          {
              "name": "C++ Attach",
              "type": "cppdbg",
              "targetArchitecture": "x64",
              "request": "launch", // &lt;-- "attach" is not allowed (anymore)! :(   
              "program": "${env.build_foo}/foo_sub1",
              "args": [],
              "stopAtEntry": false,
              "cwd": "${workspaceRoot}",
              "environment": [],
              "processId": "${command.pickProcess}",
              "externalConsole": false,
              "linux": {
                  "MIMode": "gdb"
              },
              "osx": {
                  "MIMode": "lldb"
              },
              "windows": {
                  "MIMode": "gdb"
              }
          }
      ]
  }
  </code></pre>
  
  <p>So far I am really frustrated and still don't want to give up on VSCode (I don't want to switch to another IDE yet). I have searched a lot for other issues and also tried to set some other config-properties but none of it helped. </p>
  
  <p>Does anyone else also have such issues with the debugger or is this a general problem with the extension (... and Ubuntu 16.04)?
  I am happy for any help or convenient workaround. Thanks in advance!</p>
  
  <p><strong>Note:</strong>
  I have also created a thread on the related github page (see <a href="https://github.com/Microsoft/vscppsamples/issues/115" rel="nofollow">https://github.com/Microsoft/vscppsamples/issues/115</a>)</p>
  
  <p><strong>Update 07/26/2016:</strong>
  It seems like there is a bug with the C/C++ extension (see comments in the github link above). It is still being investigated though.</p>