MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / get_function_id

Function get_function_id

tools/wasm-sourcemap.py:530–548  ·  view source on GitHub ↗
(address)

Source from the content-addressed store, hash-verified

528
529 # Get the function name ID that the given address falls into
530 def get_function_id(address):
531 nonlocal active_funcs
532 nonlocal next_func_range_id
533
534 # Maintain a list of "active functions" whose ranges currently cover the
535 # address. As the address advances, it adds new functions that start and
536 # removes functions that end. The last function remaining in the active list
537 # at any point is the innermost function.
538 while next_func_range_id < len(func_ranges) and func_ranges[next_func_range_id].low_pc <= address:
539 # active_funcs contains (high_pc, id) pair
540 active_funcs.append((func_ranges[next_func_range_id].high_pc, next_func_range_id))
541 next_func_range_id += 1
542 active_funcs = [f for f in active_funcs if f[0] > address]
543
544 if active_funcs:
545 func_range_id = active_funcs[-1][1]
546 name = func_ranges[func_range_id].name
547 return name_to_id[name]
548 return None
549
550 for entry in entries:
551 line = entry['line']

Callers 1

build_sourcemapFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected