Skip to content
Merged
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
9 changes: 5 additions & 4 deletions elftools/dwarf/callframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import IO, TYPE_CHECKING, Any, Literal, NamedTuple, cast
from warnings import warn

from ..common.exceptions import DWARFError
from ..common.utils import (
struct_parse, dwarf_assert, preserve_stream_pos)
from ..construct import Struct, Switch
Expand Down Expand Up @@ -267,7 +268,7 @@ def _parse_instructions(
case DW_CFA.GNU_args_size:
args = [struct_parse(structs.the_Dwarf_uleb128, self.stream)]
case _:
dwarf_assert(False, f'Unknown CFI opcode: {raw_opcode:#04x}')
raise DWARFError(f"Unknown CFI opcode: {raw_opcode:#04x}")

instructions.append(CallFrameInstruction(opcode=opcode, args=args))
offset = self.stream.tell()
Expand Down Expand Up @@ -526,7 +527,7 @@ def __init__(
instructions: list[CallFrameInstruction],
offset: int,
augmentation_dict: Augmentation | None = None,
augmentation_bytes: bytes | None = b'',
augmentation_bytes: bytes = b"",
cie: CIE | None = None,
) -> None:
self.header = header
Expand Down Expand Up @@ -670,7 +671,7 @@ def _add_to_order(regnum: int) -> None:
case DW_CFA.nop | DW_CFA.AARCH64_negate_ra_state:
pass
case _:
dwarf_assert(False, f"Unknown CFI opcode: {instr.opcode:#02x}")
raise DWARFError(f"Unknown CFI opcode: {instr.opcode:#02x}")

# The current line is appended to the table after all instructions
# have ended, if there were instructions.
Expand All @@ -696,7 +697,7 @@ def __init__(
structs: DWARFStructs,
instructions: list[CallFrameInstruction],
offset: int,
augmentation_bytes: bytes | None = None,
augmentation_bytes: bytes = b"",
cie: CIE | None = None,
lsda_pointer: int | None = None,
) -> None:
Expand Down
6 changes: 3 additions & 3 deletions elftools/dwarf/lineprogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from functools import cached_property
from typing import IO, TYPE_CHECKING, Any, NamedTuple

from ..common.utils import struct_parse, dwarf_assert
from ..common.exceptions import DWARFError
from ..common.utils import struct_parse
from .constants import DW_LNE, DW_LNS

if TYPE_CHECKING:
Expand Down Expand Up @@ -274,7 +275,6 @@ def add_entry_old_state(cmd: int, args: list[int], is_extended: bool = False) ->
state.isa = operand
add_entry_old_state(opcode, [operand])
else:
dwarf_assert(False, 'Invalid standard line program opcode: %s' % (
opcode,))
raise DWARFError(f"Invalid standard line program opcode: {opcode}")
offset = self.stream.tell()
return entries
2 changes: 1 addition & 1 deletion elftools/dwarf/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def _parse(self, stream: IO[bytes], context: Container) -> Any:
context[self.format_field + "_parser"] = parser
return parser._parse(stream, context)

def ver5(ctx):
def ver5(ctx: Container) -> bool:
return ctx.version >= 5

self.Dwarf_lineprog_header = Struct('Dwarf_lineprog_header',
Expand Down
Loading