Skip to content
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

substring not found #3

Open
fr0zenrain opened this issue Jan 19, 2022 · 2 comments · May be fixed by #5
Open

substring not found #3

fr0zenrain opened this issue Jan 19, 2022 · 2 comments · May be fixed by #5

Comments

@fr0zenrain
Copy link

Executing action: lucid:view_microcode (View microcode)
Traceback (most recent call last):
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\util\ida.py", line 51, in activate
self.action_function(ctx)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\core.py", line 119, in interactive_view_microcode
self.explorer.show(current_address)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\ui\explorer.py", line 48, in show
self.select_function(address)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\ui\explorer.py", line 98, in select_function
mtext = MicrocodeText(mba, self.model.verbose)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 463, in init
self.refresh()
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 471, in refresh
self._generate_from_mba()
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 483, in _generate_from_mba
blk_token = MicroBlockText(blk, self.verbose)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 275, in init
self.refresh()
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 283, in refresh
self._generate_from_blk()
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 298, in _generate_from_blk
insn_token = MicroInstructionToken(insn, insn_idx, self)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 166, in init
self._generate_from_insn()
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 177, in _generate_from_insn
self._create_subop(mop)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 191, in _create_subop
subop = MicroOperandToken(mop, parent=self)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 100, in init
self._generate_from_op()
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 112, in _generate_from_op
self._create_subop(mop.d.r)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 147, in _create_subop
subop = MicroOperandToken(mop, parent=self)
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\microtext.py", line 101, in init
self._generate_token_ranges()
File "C:/Program Files/IDA_Pro_v7.5_Portable/plugins\lucid\text.py", line 92, in _generate_token_ranges
token_index = self.text[parsing_offset:].index(token.text)
ValueError: substring not found

@funlennysub
Copy link

also happens on ida 7.7 with 3.9 python when trying to view microcode for a large function

Traceback (most recent call last):
  File "/plugins\lucid\util\ida.py", line 51, in activate
    self.action_function(ctx)
  File "/plugins\lucid\core.py", line 118, in interactive_view_microcode
    self.explorer = MicrocodeExplorer()
  File "/plugins\lucid\ui\explorer.py", line 40, in __init__
    self.view._code_sync.enable_sync(True) # XXX/HACK
  File "/plugins\lucid\ui\sync.py", line 84, in enable_sync
    self._sync_microtext(self._last_vdui)
  File "/plugins\lucid\ui\sync.py", line 319, in _sync_microtext
    self.controller.select_function(vdui.cfunc.entry_ea)
  File "/plugins\lucid\ui\explorer.py", line 98, in select_function
    mtext = MicrocodeText(mba, self.model.verbose)
  File "/plugins\lucid\microtext.py", line 463, in __init__
    self.refresh()
  File "/plugins\lucid\microtext.py", line 471, in refresh
    self._generate_from_mba()
  File "/plugins\lucid\microtext.py", line 483, in _generate_from_mba
    blk_token = MicroBlockText(blk, self.verbose)
  File "/plugins\lucid\microtext.py", line 275, in __init__
    self.refresh()
  File "/plugins\lucid\microtext.py", line 283, in refresh
    self._generate_from_blk()
  File "/plugins\lucid\microtext.py", line 298, in _generate_from_blk
    insn_token = MicroInstructionToken(insn, insn_idx, self)
  File "/plugins\lucid\microtext.py", line 166, in __init__
    self._generate_from_insn()
  File "/plugins\lucid\microtext.py", line 177, in _generate_from_insn
    self._create_subop(mop)
  File "/plugins\lucid\microtext.py", line 191, in _create_subop
    subop = MicroOperandToken(mop, parent=self)
  File "/plugins\lucid\microtext.py", line 101, in __init__
    self._generate_token_ranges()
  File "/plugins\lucid\text.py", line 92, in _generate_token_ranges
    token_index = self.text[parsing_offset:].index(token.text)
ValueError: substring not found

@Fireboyd78
Copy link

Fireboyd78 commented Jan 30, 2024

I ran into this same issue - here was the fix that worked for me:

# lucid/text.py, ~line 84
def _generate_token_ranges(self):
	"""
	Generate the text span indexes (start:end) for each child token.
	"""
	token_ranges = []
	parsing_offset = 0

	for token in self.items:
		token_index = self.text[parsing_offset:].index(token.text)
		token_start = parsing_offset + token_index
		token_end = token_start + len(token.text)
		token_ranges.append((range(token_start, token_end), token))
		
		if token_start > 2 and self.text.find(',', parsing_offset, token_start) > parsing_offset:
			continue
					
		parsing_offset = token_end
		

	self._token_ranges = token_ranges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants