Skip to content

Commit 5aec34f

Browse files
author
Prakash Surya
authored
Merge pull request #241 from delphix/master
Merge branch 'master' into '6.0/stage'
2 parents 31100eb + 76813d8 commit 5aec34f

File tree

14 files changed

+29
-37
lines changed

14 files changed

+29
-37
lines changed

sdb/command.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ def call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
328328
yield from self.__invalid_memory_objects_check(
329329
result, not issubclass(self.__class__, SingleInputCommand))
330330
except drgn.FaultError as err:
331-
raise CommandError(self.name, f"invalid memory access: {str(err)}")
331+
raise CommandError(self.name,
332+
f"invalid memory access: {str(err)}") from err
332333

333334

334335
class SingleInputCommand(Command):
@@ -409,15 +410,16 @@ def __init__(self,
409410
tname = " ".join(self.args.type)
410411
try:
411412
self.type = target.get_type(tname)
412-
except LookupError:
413-
raise CommandError(self.name, f"could not find type '{tname}'")
413+
except LookupError as err:
414+
raise CommandError(self.name,
415+
f"could not find type '{tname}'") from err
414416

415417
def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
416418
for obj in objs:
417419
try:
418420
yield drgn.cast(self.type, obj)
419421
except TypeError as err:
420-
raise CommandError(self.name, str(err))
422+
raise CommandError(self.name, str(err)) from err
421423

422424

423425
class Dereference(Command):
@@ -546,8 +548,8 @@ def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
546548
for symbol in self.args.symbols:
547549
try:
548550
yield Address.resolve_for_address(symbol)
549-
except KeyError:
550-
raise SymbolNotFoundError(self.name, symbol)
551+
except KeyError as err:
552+
raise SymbolNotFoundError(self.name, symbol) from err
551553

552554

553555
class Walk(Command):

sdb/commands/echo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
4343
for addr in self.args.addrs:
4444
try:
4545
value_ = int(addr, 0)
46-
except ValueError:
47-
raise sdb.CommandInvalidInputError(self.name, addr)
46+
except ValueError as err:
47+
raise sdb.CommandInvalidInputError(self.name, addr) from err
4848
yield sdb.create_object("void *", value_)

sdb/commands/help.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def _call(self, objs: Iterable[drgn.Object]) -> None:
3939
if self.args.cmd is not None:
4040
try:
4141
all_cmds[self.args.cmd].help(self.args.cmd)
42-
except KeyError:
43-
raise sdb.error.CommandNotFoundError(self.args.cmd)
42+
except KeyError as err:
43+
raise sdb.error.CommandNotFoundError(self.args.cmd) from err
4444
else:
4545
cmds: Dict[str, Type[sdb.Command]] = {}
4646
for k, v in all_cmds.items():

sdb/commands/internal/table.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ class Table:
2727

2828
__slots__ = "fields", "rjustfields", "formatters", "maxfieldlen", "lines"
2929

30-
#
31-
# The "yapf" tool expects 4 spaces for the continuation lines here,
32-
# where "pylint" expects 8 spaces. To reconcile the difference in
33-
# expectations of both tools, we disable the pylint error, and
34-
# adhere to the yapf format.
35-
#
36-
# pylint: disable=bad-continuation
3730
def __init__(
3831
self,
3932
fields: List[str],

sdb/commands/linux/per_cpu.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class LxPerCpuCounterSum(sdb.SingleInputCommand):
9898
def _call_one(self, obj: drgn.Object) -> Iterable[drgn.Object]:
9999
try:
100100
sum_ = drgn_percpu.percpu_counter_sum(obj)
101-
except AttributeError:
102-
raise sdb.CommandError(self.name, "input is not a percpu_counter")
101+
except AttributeError as err:
102+
raise sdb.CommandError(self.name,
103+
"input is not a percpu_counter") from err
103104
yield drgn.Object(sdb.get_prog(), type="s64", value=sum_)

sdb/commands/stacks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,10 @@ def validate_args(self) -> None:
295295
#
296296
func = sdb.get_object(self.args.function)
297297
sym = sdb.get_symbol(func.address_of_())
298-
except KeyError:
298+
except KeyError as err:
299299
raise sdb.CommandError(
300-
self.name, f"symbol '{self.args.function}' does not exist")
300+
self.name,
301+
f"symbol '{self.args.function}' does not exist") from err
301302
if func.type_.kind != drgn.TypeKind.FUNCTION:
302303
raise sdb.CommandError(
303304
self.name, f"'{self.args.function}' is not a function")
@@ -356,10 +357,9 @@ def print_header(self) -> None:
356357
# task state and program counters. Return a collection sorted by number
357358
# of tasks per stack.
358359
#
359-
# Note: we disabled pyline C0330 due to https://github.com/PyCQA/pylint/issues/289
360360
@staticmethod
361361
def aggregate_stacks(
362-
objs: Iterable[drgn.Object] # pylint: disable=C0330
362+
objs: Iterable[drgn.Object]
363363
) -> List[Tuple[Tuple[str, Tuple[int, ...]], List[drgn.Object]]]:
364364
stack_aggr: Dict[Tuple[str, Tuple[int, ...]],
365365
List[drgn.Object]] = defaultdict(list)

sdb/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def invoke(myprog: drgn.Program, first_input: Iterable[drgn.Object],
107107
raise CommandNotFoundError(name)
108108
try:
109109
pipeline.append(get_registered_commands()[name](args, name))
110-
except SystemExit:
110+
except SystemExit as cmd_exit:
111111
#
112112
# The passed in arguments to each command will be parsed in
113113
# the command object's constructor. We use "argparse" to do
@@ -116,7 +116,7 @@ def invoke(myprog: drgn.Program, first_input: Iterable[drgn.Object],
116116
# SDB session, we only abort this specific pipeline by raising
117117
# a CommandArgumentsError.
118118
#
119-
raise CommandArgumentsError(name)
119+
raise CommandArgumentsError(name) from cmd_exit
120120
else:
121121
assert cmd_type == parser.ExpressionType.SHELL_CMD
122122
shell_cmd = cmd

sdb/target.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,13 @@ def type_canonicalize(t: drgn.Type) -> drgn.Type:
104104
105105
Note: function type's arguments and return types are not canonicalized.
106106
"""
107+
global prog
107108
if t.kind == drgn.TypeKind.TYPEDEF:
108109
return type_canonicalize(t.type)
109110
if t.kind == drgn.TypeKind.POINTER:
110-
return drgn.pointer_type(t.size, type_canonicalize(t.type))
111+
return prog.pointer_type(type_canonicalize(t.type), t.size)
111112
if t.kind == drgn.TypeKind.ARRAY:
112-
return drgn.array_type(t.length, type_canonicalize(t.type))
113+
return prog.array_type(type_canonicalize(t.type), t.length)
113114
return t.unqualified()
114115

115116

tests/integration/test_core_generic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
# pylint: disable=missing-module-docstring
1818
# pylint: disable=missing-function-docstring
19-
# pylint: disable=not-callable
2019

2120
from typing import Any
2221

tests/integration/test_linux_generic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# pylint: disable=missing-module-docstring
1818
# pylint: disable=missing-function-docstring
1919
# pylint: disable=line-too-long
20-
# pylint: disable=not-callable
2120

2221
from typing import Any
2322

0 commit comments

Comments
 (0)