()
return filename, formatted_source
Returns formatted, lines limited and highlighted source as list
    or if it isn't there - an empty list
Returns formatted, lines limited and highlighted source as list
    or if it isn't there - an empty list
Returns formatted lines limited and highlighted source as list or if it isn t there - an empty list
def get_filename_and_formatted_source():
    """
    Returns formatted, lines limited and highlighted source as list
    or if it isn't there - an empty list
    """
    sal = gdb.selected_frame().find_sal()  # gdb.Symtab_and_line

    # Check if source code is available
    if sal.symtab is None:
        return '', []

    # Get the full source code
    closest_line = sal.line
    filename = sal.symtab.fullname()

    try:
        source = get_highlight_source(filename)
    except IOError:
        return '', []

    if not source:
        return '', []

    n = int(source_code_lines)

    # Compute the line range
    start = max(closest_line - 1 - n//2, 0)
    end = min(closest_line - 1 + n//2 + 1, len(source))
    num_width = len(str(end))

    # split the code
    source = source[start:end]

    # Compute the prefix_sign length
    prefix_sign = pwndbg.config.code_prefix
    prefix_width = len(prefix_sign)

    # Format the output
    formatted_source = []
    for line_number, code in enumerate(source, start=start + 1):
        fmt = ' {prefix_sign:{prefix_width}} {line_number:>{num_width}} {code}'
        if pwndbg.config.highlight_source and line_number == closest_line:
            fmt = C.highlight(fmt)

        line = fmt.format(
            prefix_sign=C.prefix(prefix_sign) if line_number == closest_line else '',
            prefix_width=prefix_width,
            line_number=line_number,
            num_width=num_width,
            code=code
        )
        formatted_source.append(line)

    return filename, formatted_source
def get_filename_and_formatted_source ( ) : sal = gdb . selected_frame ( ) . find_sal ( ) # gdb.Symtab_and_line # Check if source code is available if sal . symtab is None : return '' , [ ] # Get the full source code closest_line = sal . line filename = sal . symtab . fullname ( ) try : source = get_highlight_source ( filename ) except IOError : return '' , [ ] if not source : return '' , [ ] n = int ( source_code_lines ) # Compute the line range start = max ( closest_line - 1 - n // 2 , 0 ) end = min ( closest_line - 1 + n // 2 + 1 , len ( source ) ) num_width = len ( str ( end ) ) # split the code source = source [ start : end ] # Compute the prefix_sign length prefix_sign = pwndbg . config . code_prefix prefix_width = len ( prefix_sign ) # Format the output formatted_source = [ ] for line_number , code in enumerate ( source , start = start + 1 ) : fmt = ' {prefix_sign:{prefix_width}} {line_number:>{num_width}} {code}' if pwndbg . config . highlight_source and line_number == closest_line : fmt = C . highlight ( fmt ) line = fmt . format ( prefix_sign = C . prefix ( prefix_sign ) if line_number == closest_line else '' , prefix_width = prefix_width , line_number = line_number , num_width = num_width , code = code ) formatted_source . append ( line ) return filename , formatted_source