Skip to content

Commit e84d8aa

Browse files
authored
Make available the environment vars in an idd debug session. (#4)
1 parent a35a33f commit e84d8aa

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

debuggers/gdb/gdb_mi_driver.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import json
33

4-
from pygdbmi.gdbcontroller import GdbController
4+
from debuggers.gdb.idd_gdb_controller import IDDGdbController
55
from driver import Driver
66

77
from debuggers.gdb.utils import parse_gdb_line
@@ -11,16 +11,14 @@
1111

1212
class GDBMiDebugger(Driver):
1313
base_gdb_instance = None
14-
base_gdbmi_instance = GdbController()
1514

1615
regressed_gdb_instance = None
17-
regressed_gdbmi_instance = GdbController()
1816

1917
gdb_instances = None
2018

2119
def __init__(self, base_args, regression_args):
22-
self.base_gdb_instance = GdbController()
23-
self.regressed_gdb_instance = GdbController()
20+
self.base_gdb_instance = IDDGdbController()
21+
self.regressed_gdb_instance = IDDGdbController()
2422

2523
self.gdb_instances = { 'base': self.base_gdb_instance, 'regressed': self.regressed_gdb_instance }
2624

debuggers/gdb/idd_gdb_controller.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import logging
2+
import subprocess
3+
import os
4+
from distutils.spawn import find_executable
5+
from typing import Union, List, Optional
6+
from pygdbmi.gdbcontroller import GdbController
7+
from pygdbmi.IoManager import IoManager
8+
from pygdbmi.constants import (
9+
DEFAULT_GDB_TIMEOUT_SEC,
10+
DEFAULT_TIME_TO_CHECK_FOR_ADDITIONAL_OUTPUT_SEC,
11+
)
12+
13+
DEFAULT_GDB_LAUNCH_COMMAND = ["gdb", "--nx", "--quiet", "--interpreter=mi3"]
14+
logger = logging.getLogger(__name__)
15+
16+
class IDDGdbController(GdbController):
17+
def spawn_new_gdb_subprocess(self) -> int:
18+
if self.gdb_process:
19+
logger.debug(
20+
"Killing current gdb subprocess (pid %d)" % self.gdb_process.pid
21+
)
22+
self.exit()
23+
24+
logger.debug(f'Launching gdb: {" ".join(self.command)}')
25+
26+
my_env = os.environ.copy()
27+
28+
# Use pipes to the standard streams
29+
self.gdb_process = subprocess.Popen(
30+
self.command,
31+
shell=False,
32+
stdout=subprocess.PIPE,
33+
stdin=subprocess.PIPE,
34+
stderr=subprocess.PIPE,
35+
bufsize=0,
36+
env=my_env
37+
)
38+
39+
self.io_manager = IoManager(
40+
self.gdb_process.stdin,
41+
self.gdb_process.stdout,
42+
self.gdb_process.stderr,
43+
self.time_to_check_for_additional_output_sec,
44+
)
45+
return self.gdb_process.pid

0 commit comments

Comments
 (0)