PCSX2 Documentation/GNU Debugger Tips: Difference between revisions

From PCSX2 Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(13 intermediate revisions by 2 users not shown)
Line 12: Line 12:
*limit the trace to the Nth lastest: <code>backtrace <N></code>
*limit the trace to the Nth lastest: <code>backtrace <N></code>
*go to a specific stack: <code>frame <STACK_ID></code>
*go to a specific stack: <code>frame <STACK_ID></code>
*go up 1 frame: up
*go up 1 frame: <code>up</code>
*go down 1 frame: down
*go down 1 frame: <code>down</code>


==Step by step execution==
==Step by step execution==
execute 1 instruction :step
*execute 1 instruction: <code>step</code>
execute 1 C line of instruction, functions are a 1 line instruction:next
*execute 1 C line of instruction, functions are a 1 line instruction: <code>next</code>
Same for ASM: nexti and stepi
*Same for ASM: <code>nexti</code> and <code>stepi</code>
continue execution: continue
*continue execution: <code>continue</code>
Add breakpoint to stop program:
*Add breakpoint to stop program: <code>break <file>:<line></code> or <code>break <function></code>
break <file>:<line>
*add a condition: <code>break <file>:<line> if <ARG> == 0</code>
break <function>
*Print variable/memory/register basic var: <code>print <nowiki><var></nowiki> </code>
add a condition: break <file>:<line> if <ARG> == 0
*pointer var: <code>print <*var></code>
Print variable/memory/register
*print memory: <code>x <Oxlocation></code>
basic var: print <var>
*print register: <code>print $<register_name></code>
pointer var: print <*var>
 
print memory: x <Oxlocation>
==SIGSEGV/Segmentation fault==
print register: print $<register_name>
SIGSEGV/Segmentation fault
A program have a limited range of memory that it can access. When you try to read/write outside, the kernel generate an error named segmentation fault. It is a critical error and generally it just crash. It is a bit difficult on PCSX2 because recompiler use this mechanism for optimization. So segmentation fault inside recompiler are normal and expected.
A program have a limited range of memory that it can access. When you try to read/write outside, the kernel generate an error named segmentation fault. It is a critical error and generally it just crash. It is a bit difficult on PCSX2 because recompiler use this mechanism for optimization. So segmentation fault inside recompiler are normal and expected.
You can control signal behavior with the handle command for example.
You can control signal behavior with the handle command for example.
don't stop on SIGSEGV: handle SIGSEGV nostop
*don't stop on SIGSEGV: <code>handle SIGSEGV nostop</code>
GDB basic gui
 
==GDB basic gui==
You can attach gdb to any process of your system. It will stop the process and show the current execution.
You can attach gdb to any process of your system. It will stop the process and show the current execution.
hint: to get the pcsx2 process id: ps aux |grep pcsx2
*hint: <code>to get the pcsx2 process id: ps aux |grep pcsx2</code>
attach the process: attach <Process_ID>
*attach the process: <code>attach <Process_ID></code>
 
GDB contains several views. You can see code source, ASM or register.
GDB contains several views. You can see code source, ASM or register.
source code: ctrl x ctrl A
*source code: <code>ctrl x ctrl A</code>
2 panels: ctrl x ctrl 1
*2 panels: <code>ctrl x ctrl 1</code>
3 panels: ctrl x ctrl 2
*3 panels: <code>ctrl x ctrl 2</code>
 
 
{{PCSX2 Documentation Navbox}}

Latest revision as of 17:04, 19 July 2015

Thread

  • PCSX2 contains multi threads. Each thread can be run in parallel.
  • Get thread info: info threads
  • Select a thread: thread <ID>
  • Apply a command to a specific thread: thread apply <ID> <GDB_COMMAND>
  • Apply a command to all thread: thread apply all <GDB_COMMAND>

Stack/Frame

A standard human can understand a limited code size at once. So generally the code is split-ed in small unit (AKA functions). Functions call others functions which call others and so for. The full stack of called function give you an overview of what is going on your program

  • print the stack: backtrace
  • print local variable inside the stack: backtrace full
  • limit the trace to the Nth lastest: backtrace <N>
  • go to a specific stack: frame <STACK_ID>
  • go up 1 frame: up
  • go down 1 frame: down

Step by step execution

  • execute 1 instruction: step
  • execute 1 C line of instruction, functions are a 1 line instruction: next
  • Same for ASM: nexti and stepi
  • continue execution: continue
  • Add breakpoint to stop program: break <file>:<line> or break <function>
  • add a condition: break <file>:<line> if <ARG> == 0
  • Print variable/memory/register basic var: print <var>
  • pointer var: print <*var>
  • print memory: x <Oxlocation>
  • print register: print $<register_name>

SIGSEGV/Segmentation fault

A program have a limited range of memory that it can access. When you try to read/write outside, the kernel generate an error named segmentation fault. It is a critical error and generally it just crash. It is a bit difficult on PCSX2 because recompiler use this mechanism for optimization. So segmentation fault inside recompiler are normal and expected. You can control signal behavior with the handle command for example.

  • don't stop on SIGSEGV: handle SIGSEGV nostop

GDB basic gui

You can attach gdb to any process of your system. It will stop the process and show the current execution.

  • hint: to get the pcsx2 process id: ps aux |grep pcsx2
  • attach the process: attach <Process_ID>

GDB contains several views. You can see code source, ASM or register.

  • source code: ctrl x ctrl A
  • 2 panels: ctrl x ctrl 1
  • 3 panels: ctrl x ctrl 2