     stdout = (output) -> console.log("stdout:", output)
     stderr = (output) -> console.log("stderr:", output)
     exit = (return_code) -> console.log("Exit with ", return_code)
-    process = new BufferedProcess({command, args, options, stdout, stderr, exit})
+    process.chdir atom.config.get('atom-gdb.startupDirectory')
+    childProcess = new BufferedProcess({command, args, stdout, stderr, exit})
 
   toggle_breakpoint: ->
-    console.log 'Breakpoint...'
-    editor =  atom.workspace.getActiveTextEditor()
-    console.log editor.getCursorBufferPosition().row + 1
+    editor = atom.workspace.getActiveTextEditor()
+    filename = path.basename(editor.getPath())
+    row = editor.getCursorBufferPosition().row + 1
+    @breakPoints.push {filename:filename, line:row}
+    console.log("Added breakpoint:", filename, ":", row)
+    @updateGdbInit()
+
+  updateGdbInit: ->
+    process.chdir atom.config.get('atom-gdb.startupDirectory')
+    outputFile = fs.createWriteStream(".gdbinit")
+    bps = @breakPoints
+    outputFile.on 'open', (fd) ->
+      outputFile.write "set breakpoint pending on\n"
+      outputFile.write "b " + bp.filename + ":" + bp.line + "\n" for bp in bps
+      outputFile.end()
+      return

{BufferedProcess} = require 'atom'
{CompositeDisposable} = require 'atom'

module.exports = AtomGdb =
  atomGdbView: null
  modalPanel: null
  subscriptions: null
  config:
    debuggerCommand:
      type: 'string'


  start: ->
    console.log 'Starting debugger...'
    commandWords = atom.config.get('atom-gdb.debuggerCommand').split " "
    command = commandWords[0]
    args = commandWords[1..commandWords.length]
