Skip to content

[wip] Fix all linter issues with idd picked up by ruff #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/idd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import argparse
import sys
import os
from asyncio import sleep

from textual import on
from textual import events
Expand Down Expand Up @@ -127,7 +126,7 @@ async def compare_contents(self, raw_base_contents, raw_regression_contents):
self.diff_area2.append(diff2)

async def set_pframes_result(self, state, version) -> None:
if state == None or "stack_frames" not in state:
if state is None or "stack_frames" not in state:
return

file_contents = state["stack_frames"]
Expand All @@ -137,7 +136,7 @@ async def set_pframes_result(self, state, version) -> None:
self.diff_frames2.text(file_contents)

async def set_pframes_command_result(self, state) -> None:
if state["base"] == None or "stack_frames" not in state["base"] or state["regressed"] == None or "stack_frames" not in state["regressed"]:
if state["base"] is None or "stack_frames" not in state["base"] or state["regressed"] is None or "stack_frames" not in state["regressed"]:
return

base_file_contents = state["base"]["stack_frames"]
Expand All @@ -150,7 +149,7 @@ async def set_pframes_command_result(self, state) -> None:
self.diff_frames2.text(diff2)

async def set_plocals_result(self, state, version) -> None:
if state == None or "locals" not in state:
if state is None or "locals" not in state:
return

file_contents = state["locals"]
Expand All @@ -161,7 +160,7 @@ async def set_plocals_result(self, state, version) -> None:


async def set_plocals_command_result(self, state) -> None:
if state["base"] == None or "locals" not in state["base"] or state["regressed"] == None or "locals" not in state["regressed"]:
if state["base"] is None or "locals" not in state["base"] or state["regressed"] is None or "locals" not in state["regressed"]:
return

base_file_contents = state["base"]["locals"]
Expand All @@ -174,7 +173,7 @@ async def set_plocals_command_result(self, state) -> None:
self.diff_locals2.text(diff2)

async def set_pargs_result(self, state, version) -> None:
if state == None or "args" not in state:
if state is None or "args" not in state:
return

file_contents = state["args"]
Expand All @@ -184,7 +183,7 @@ async def set_pargs_result(self, state, version) -> None:
self.diff_args2.text(file_contents)

async def set_pargs_command_result(self, state) -> None:
if state["base"] == None or "args" not in state["base"] or state["regressed"] == None or "args" not in state["regressed"]:
if state["base"] is None or "args" not in state["base"] or state["regressed"] is None or "args" not in state["regressed"]:
return

base_file_contents = state["base"]["args"]
Expand All @@ -197,7 +196,7 @@ async def set_pargs_command_result(self, state) -> None:
self.diff_args2.text(diff2)

async def set_pasm_result(self, state, version) -> None:
if state == None or "instructions" not in state:
if state is None or "instructions" not in state:
return

file_contents = state["instructions"]
Expand All @@ -207,7 +206,7 @@ async def set_pasm_result(self, state, version) -> None:
self.diff_asm2.text(file_contents)

async def set_pasm_command_result(self, state) -> None:
if state["base"] == None or "instructions" not in state["base"] or state["regressed"] == None or "instructions" not in state["regressed"]:
if state["base"] is None or "instructions" not in state["base"] or state["regressed"] is None or "instructions" not in state["regressed"]:
return

base_file_contents = state["base"]["instructions"]
Expand All @@ -220,7 +219,7 @@ async def set_pasm_command_result(self, state) -> None:
self.diff_asm2.text(diff2)

async def set_pregisters_result(self, state, version) -> None:
if state == None or "registers" not in state:
if state is None or "registers" not in state:
return

file_contents = state["registers"]
Expand All @@ -230,7 +229,7 @@ async def set_pregisters_result(self, state, version) -> None:
self.diff_reg2.text(file_contents)

async def set_pregisters_command_result(self, state) -> None:
if state["base"] == None or "registers" not in state["base"] or state["regressed"] == None or "registers" not in state["regressed"]:
if state["base"] is None or "registers" not in state["base"] or state["regressed"] is None or "registers" not in state["regressed"]:
return

base_file_contents = state["base"]["registers"]
Expand Down Expand Up @@ -531,7 +530,7 @@ def main() -> None:
Debugger = GDBMiDebugger(ba, bs, ra, rs, base_pid=bpid, regression_pid=rpid)

elif comparator == 'lldb':
from idd.debuggers.lldb.lldb_driver import LLDBParallelDebugger, LLDBDebugger
from idd.debuggers.lldb.lldb_driver import LLDBDebugger
from idd.debuggers.lldb.lldb_new_driver import LLDBNewDriver

if ra == "" and rpid is None:
Expand Down
10 changes: 5 additions & 5 deletions src/idd/debuggers/gdb/gdb_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ def invoke (self, arg, from_tty):
# get locals
if (symbol.is_variable):
name = symbol.name
if not name in names:
if name not in names:
locals.append('{} = {}'.format(name, symbol.value(frame)).replace('"',''))

# get args
if (symbol.is_argument):
name = symbol.name
if not name in names:
if name not in names:
args.append('{} = {}\n'.format(name, symbol.value(frame)).replace('"',''))
block = block.superblock

Expand Down Expand Up @@ -136,7 +136,7 @@ def invoke (self, arg, from_tty):
for symbol in block:
if (symbol.is_variable):
name = symbol.name
if not name in names:
if name not in names:
print('{} = {}'.format(name, symbol.value(frame)))
names.add(name)
block = block.superblock
Expand All @@ -153,7 +153,7 @@ def invoke (self, arg, from_tty):
for symbol in block:
if (symbol.is_argument):
name = symbol.name
if not name in names:
if name not in names:
print('{} = {}\n'.format(name, symbol.value(frame)))
names.add(name)
block = block.superblock
Expand Down Expand Up @@ -216,7 +216,7 @@ def invoke (self, arg, from_tty):
try:
result = gdb.execute(arg, to_string=True)
print(result)
except Exception as ex:
except Exception:
ex_type, ex_value, ex_traceback = sys.exc_info()
# Extract unformatter stack traces as tuples
trace_back = traceback.extract_tb(ex_traceback)
Expand Down
15 changes: 5 additions & 10 deletions src/idd/debuggers/gdb/gdb_driver.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
from pygdbmi.gdbcontroller import GdbController
from pprint import pprint
from idd.driver import Driver

import io
import time
import subprocess
import selectors
import sys
import os, fcntl
import select, time
import threading, queue
import os
import fcntl
import threading

base_response = ""
regressed_response = ""
Expand Down Expand Up @@ -266,14 +261,14 @@ def run_single_raw_command(self, command, version):

if version == "base":
while True:
if base_response != None:
if base_response is not None:
temp = base_response
base_response = ""
break

if version == "regressed":
while True:
if regressed_response != None:
if regressed_response is not None:
temp = regressed_response
regressed_response = ""
break
Expand Down
7 changes: 4 additions & 3 deletions src/idd/debuggers/gdb/gdb_mi_driver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import logging, threading
import logging
import threading

from pygdbmi import gdbmiparser

Expand Down Expand Up @@ -122,7 +123,7 @@ def run_single_command(self, command, version):
self.gdb_instances[version].write(command)
raw_result = self.gdb_instances[version].read_until_prompt()

except Exception as e:
except Exception:
logger.exception(f"Error executing GDB command: {command}")
# self.handle_gdb_crash()
return []
Expand All @@ -137,7 +138,7 @@ def run_single_special_command(self, command, version):
#self.gdb_instances[version].flush_debuggee_output()
self.gdb_instances[version].write(command)
raw_result = self.gdb_instances[version].read_until_prompt()
except Exception as e:
except Exception:
logger.exception(f"Error executing GDB command: {command}")
# self.handle_gdb_crash()
return []
Expand Down
3 changes: 0 additions & 3 deletions src/idd/debuggers/gdb/idd_gdb_controller.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import os
import logging
import select
import fcntl
import pty
import signal
import threading
import time

from idd.driver import IDDParallelTerminate
from idd.debuggers.gdb.utils import parse_gdb_line

from pygdbmi.gdbcontroller import GdbController

Expand Down
15 changes: 5 additions & 10 deletions src/idd/debuggers/lldb/lldb_commands.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import lldb
import sys
import os
import time
from six import StringIO as SixStringIO
import six
import lldb_utils
import json

Expand Down Expand Up @@ -70,8 +65,8 @@ def print_list(debugger, args, result, internal_dict):

print(result)
print("end_command")
except:
print("exception")
except Exception:
print("exception {e}")
print("end_command")

def run_wrapper(debugger, args, result, internal_dict):
Expand All @@ -83,13 +78,13 @@ def run_wrapper(debugger, args, result, internal_dict):

print(command_result)
print("end_command")
except:
print("exception")
except Exception:
print("exception {e}")
print("end_command")

def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('command script add -f lldb_commands.get_locals plocals')
debugger.HandleCommand('command script add -f lldb_commands.get_args pargs')
debugger.HandleCommand('command script add -f lldb_commands.get_stacktrace pframe')
debugger.HandleCommand('command script add -f lldb_commands.print_list plist')
debugger.HandleCommand('command script add -f lldb_commands.run_wrapper run-wrapper')
debugger.HandleCommand('command script add -f lldb_commands.run_wrapper run-wrapper')
4 changes: 3 additions & 1 deletion src/idd/debuggers/lldb/lldb_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os, sys, pty, tty, select, threading
import os
import select
import threading
import platform
import lldb
from lldb import eLaunchFlagStopAtEntry
Expand Down
2 changes: 1 addition & 1 deletion src/idd/debuggers/lldb/lldb_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import lldb

from idd.driver import Driver, IDDParallelTerminate
from idd.debuggers.lldb.lldb_extensions import *
from idd.debuggers.lldb.lldb_extensions import get_current_stack_frame_from_target,get_args_as_list,get_local_vars_as_list,get_instructions_as_list,get_registers_as_list,get_call_instructions
from multiprocessing import Process, Pipe


Expand Down
2 changes: 1 addition & 1 deletion src/idd/debuggers/lldb/lldb_new_driver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from idd.driver import Driver
from idd.debuggers.lldb.lldb_controller import IDDLLDBController
from idd.debuggers.lldb.lldb_extensions import *
from idd.debuggers.lldb.lldb_extensions import get_current_stack_frame_from_target,get_args_as_list,get_local_vars_as_list,get_instructions_as_list,get_registers_as_list
from concurrent.futures import ThreadPoolExecutor


Expand Down