pythongdbsymbolsremote-debuggingcoredump

Remote Debugging a Core dump file with gdb


I have a use case where my customer has a core dump (in 10s to 100s of GBs) and I want to analyze it from my system as migrating the core dump may take huge amount of time in cases where the debugging is urgent or case is a P1.

I can of course set up some communication where I can remotely give commands on the user system but I cannot transfer the source file or the symbol table on the customer side. What options does this leave me with ?

So considering I have 2 GDB sessions, one on the customer end with the core file and one of my side with the exec file and the symbol file, Can I do something from the outputs I get on the customer side to bring it on my side and map it with the symbol table (symtab) present on my gdb session to produce a detailed output. Eg -

A backtrace on customer's system might return me with -

(gdb) bt
#0  0x000055e3eb1b92dd in ?? ()
#1  0x0000000700000000 in ?? ()
#2  0x000055e3eb5b22a0 in ?? ()
#3  0x00000007eb5b22a0 in ?? ()
#4  0x0000000000000000 in ?? ()

And if I have all the core file, symbol file and exec file then the backtrace returns me with -

(gdb) bt
#0  0x000055e3eb1b92dd in print_list (list=0x55e3eb5b22a0, length=7) at broken_linked_list.c:52
#1  0x000055e3eb1b91db in main () at broken_linked_list.c:19

So I am assuming that this mapping is done with the help of struct symtab in gdb/symtab.c

I want to realize the same output by taking the results of customer side bt and put it in my gdb session for mapping.

Is there a way to do this ? and is this possible or is there any way for me to remotely debug the core file without giving out the exec file and the symbol file.

I am relatively new but would be ready to dive into the source code if any possible way ...

I tried using python API, something like this - but couldn't actually more forward with anyway with it -

import gdb

def map_addresses_to_symbols(addresses):
    mapped_data = {}
    for address in addresses:
        try:
            # Convert address to hexadecimal string
            address_str = hex(address)
            # Lookup global symbol using the address as a string
            sym = gdb.lookup_global_symbol(address_str)
            if sym is not None:
                symbol_name = sym.name
                mapped_data[address] = symbol_name
        except gdb.error:
            pass
    return mapped_data

def generate_output(mapped_information):
    for address, symbol_name in mapped_information.items():
        print(f"Address: {hex(address)}, Symbol: {symbol_name}")

# Specify the received data from customer machine.. output of bt or anything (addresses that need to be mapped)
received_data = [0x000055e3eb1b92dd] 

# Map addresses to symbols
mapped_information = map_addresses_to_symbols(received_data)

# Generate and print the comprehensive output
generate_output(mapped_information)

Solution

  • I want to realize the same output by taking the results of customer side bt and put it in my gdb session for mapping.

    This can not be done. The mapping in GDB is a complicated part and it requires the core file exec file and symbol file all together for mapping.

    Since the stack would not be present on the other side, it would not be possible to do anything here.