Scripted frames that materialize Python functions or other non-native code are PC-less by design, meaning they don't have valid program counter values. Previously, these frames would display invalid addresses (`0xffffffffffffffff`) in backtrace output. This patch updates `FormatEntity` to detect and suppress invalid address display for PC-less frames, adds fallback to frame methods when symbol context is unavailable, and modifies `StackFrame::GetSymbolContext` to skip PC-based symbol resolution for invalid addresses. The changes enable PC-less frames to display cleanly with proper function names, file paths, and line numbers, and allow for source display of foreign sources (like Python). Includes comprehensive test coverage demonstrating frames pointing to Python source files. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
37 lines
777 B
Python
37 lines
777 B
Python
"""
|
|
Sample Python module to demonstrate Python source display in scripted frames.
|
|
"""
|
|
|
|
|
|
def compute_fibonacci(n):
|
|
"""Compute the nth Fibonacci number."""
|
|
if n <= 1:
|
|
return n
|
|
a, b = 0, 1
|
|
for _ in range(n - 1):
|
|
a, b = b, a + b
|
|
return b
|
|
|
|
|
|
def process_data(data):
|
|
"""Process some data and return result."""
|
|
result = []
|
|
for item in data:
|
|
if isinstance(item, int):
|
|
result.append(item * 2)
|
|
elif isinstance(item, str):
|
|
result.append(item.upper())
|
|
return result
|
|
|
|
|
|
def main():
|
|
"""Main entry point for testing."""
|
|
fib_10 = compute_fibonacci(10)
|
|
data = [1, 2, "hello", 3, "world"]
|
|
processed = process_data(data)
|
|
return fib_10, processed
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|