Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimcn committed Sep 28, 2018
1 parent cb21b8e commit 5977bac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
18 changes: 13 additions & 5 deletions adapter/debugsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def DEBUG_attach(self, args):
pid = args.get('pid', None)
program = args.get('program', None)
if pid is None and program is None:
raise UserError('One of \'program\', \'pid\' properties is required for attach.')
raise UserError('Either \'program\' or \'pid\' is required for attach.')
self.exec_commands(args.get('initCommands'))
self.target = self.create_target(args)
self.disassembly = disassembly.AddressSpace(self.target)
Expand Down Expand Up @@ -276,7 +276,7 @@ def create_target(self, args):
raise UserError('Could not initialize debug target: ' + error.GetCString())
else:
if args['request'] == 'launch':
raise UserError('\program\' is required for launch.')
raise UserError('\'program\' property is required for launch.')
target = self.debugger.CreateTarget('') # OK if attaching by pid
target.GetBroadcaster().AddListener(self.event_listener, lldb.SBTarget.eBroadcastBitBreakpointChanged)
return target
Expand Down Expand Up @@ -324,7 +324,7 @@ def configure_stdio(self, args):
title = 'Debug - ' + args.get('name', '?')
self.terminal = terminal.create(
lambda args: self.spawn_vscode_terminal(kind=term_type, args=args, title=title))
term_fd = self.terminal.tty
term_fd = to_lldb_str(self.terminal.tty)
else:
term_fd = None # that'll send them to VSCode debug console
else: # Windows
Expand Down Expand Up @@ -845,7 +845,11 @@ def DEBUG_stackTrace(self, args):
fs = le.GetFileSpec()
local_path = self.map_filespec_to_local(fs)
if local_path is not None:
stack_frame['source'] = { 'name': fs.GetFilename(), 'path': local_path }
stack_frame['source'] = {
'name': fs.GetFilename(),
'path': local_path,
'origin': frame.GetModule().GetFileSpec().GetFilename()
}
stack_frame['line'] = le.GetLine()
stack_frame['column'] = le.GetColumn()
else:
Expand All @@ -854,7 +858,11 @@ def DEBUG_stackTrace(self, args):
if not dasm:
dasm = self.disassembly.create_from_address(pc_addr)
if dasm:
stack_frame['source'] = { 'name': dasm.source_name, 'sourceReference': dasm.source_ref }
stack_frame['source'] = {
'name': dasm.source_name,
'sourceReference': dasm.source_ref,
'origin': frame.GetModule().GetFileSpec().GetFilename()
}
stack_frame['line'] = dasm.line_num_by_address(pc_addr.GetLoadAddress(self.target))
stack_frame['column'] = 0

Expand Down
9 changes: 4 additions & 5 deletions adapter/terminal.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import socket
import subprocess
import string
import logging

log = logging.getLogger('terminal')
Expand All @@ -21,9 +20,9 @@ def create(spawn_terminal=None):
ls.bind(('127.0.0.1', 0))
ls.listen(1)
addr, port = ls.getsockname()
# terminal.sh opens a TCP connection, sends output of `tty`,
# terminal.sh opens a TCP connection, sends output of `tty`,
# waits till the socket gets closed from our end
args = [os.path.join(os.path.dirname(__file__), 'terminal.sh'), str(port)]
args = ['/bin/bash', '-c', 'exec 3<>/dev/tcp/127.0.0.1/%d; tty >&3; clear; read <&3' % port]
if spawn_terminal is not None:
spawn_terminal(args)
else:
Expand All @@ -40,8 +39,8 @@ def create(spawn_terminal=None):
reason = 'connection aborted'
break
log.info('received %s', data)
output += data
lines = string.split(output, '\n')
output += data.decode('utf8')
lines = output.split('\n')
if len(lines) > 1:
return Terminal(lines[0], conn)
except (OSError, socket.timeout):
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
"default": null
},
"terminal": {
"description": "Terminal type to use for the program.",
"description": "Terminal type to use.",
"type": "string",
"enum": [
"integrated",
Expand Down

0 comments on commit 5977bac

Please sign in to comment.