This is an automated email from the ASF dual-hosted git repository.

avamingli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 89c63d90daf928e0321ba7349dfe4502d86d93f1
Author: Alexandra Wang <[email protected]>
AuthorDate: Wed Apr 26 10:55:34 2023 -0700

    Add a gdb script for debugging purposes
    
    Add a custom gdb script (src/tools/gdb/.gdbinit) for Greenplum to help
    debugging. Hopefully in the future, we can add more functions into the gdb
    script to help the developers debug Greenplum easier.
    
    Proposed-by: Ashwin Agrawal <aashwin@vmware>
    Co-authored-by: Ashwin Agrawal <aashwin@vmware>
    Co-authored-by: Marbin Tan <[email protected]>
    Reviewed-by: Ashwin Agrawal <aashwin@vmware>
    Reviewed-by: Soumyadeep Chakraborty <[email protected]>
---
 src/tools/gdb/.gdbinit | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/tools/gdb/.gdbinit b/src/tools/gdb/.gdbinit
new file mode 100644
index 0000000000..6e066e4a3c
--- /dev/null
+++ b/src/tools/gdb/.gdbinit
@@ -0,0 +1,38 @@
+# USAGE:
+# 1. Save this script as .gdbinit in your home directory or GPDB project 
directory.
+# 2. Launch GDB with the appropriate binary.
+# 3. GDB will automatically load this script during startup.
+# 4. Use the custom GDB commands to examine the relevant data structures 
during debugging.
+#
+# NOTE: Modify this script according to your specific debugging needs.
+# This is just a starting point and can be customized to better suit your 
workflow.
+
+define dump_procs
+    set $i=0
+    print procArray->numProcs
+    while ($i < procArray->numProcs)
+        set $pgprocno = procArray->pgprocnos[$i]
+        set $proc = &allProcs[$pgprocno]
+        set $pgxact = &allPgXact[$pgprocno]
+        printf "pgprocnos:%d\tprocArray index:%d\t", $pgprocno, $i
+        printf "pid:%d\tbackendID:%d\tlxid:%d\tdelayChkpt:%d", $proc->pid, 
$proc->backendId, $proc->lxid, $pgxact->delayChkpt
+        printf "\n"
+        set $i = $i + 1
+    end
+end
+
+define dump_delayChkpt_procs
+    set $i=0
+    print procArray->numProcs
+    while ($i < procArray->numProcs)
+        set $pgprocno = procArray->pgprocnos[$i]
+        set $proc = &allProcs[$pgprocno]
+        set $pgxact = &allPgXact[$pgprocno]
+        if ($pgxact->delayChkpt)
+           printf "pgprocnos:%d\tprocArray index:%d\t", $pgprocno, $i
+           printf "pid:%d\tbackendID:%d\tlxid:%d", $proc->pid, 
$proc->backendId, $proc->lxid
+           printf "\n"
+        end
+        set $i = $i + 1
+    end
+end


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to