Search code examples
assemblygdbmprotect

How can I force GDB to execute code for which there are no symbols


I have a C program that (for good reason) allocates memory, copies some code to it, uses mprotect() to give it execute privileges, and then calls that code. Yes I know this is unportable and unsafe, but there's a good reason. Anyway, I need to single-step with gdb through the assembly code (using si command) but it won't let me -- it keeps saying: "No function contains program counter for selected frame"

Is there a way to force gdb to execute this code? Is there another debugger that I should be using instead for this type of thing?

Thanks!


Solution

  • Seems like you want the add-symbol-file', oradd-symbol-file-from-memory' commands to let gdb know about the code that has been copied to that memory location.