public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/scripts gdbinit
@ 2011-09-28 16:32 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-09-28 16:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-28 16:32:22

Modified files:
	scripts        : gdbinit 

Log message:
	New handy gdb debugging function, "dm_list_size"
	
	Example:
	(gdb) dm_list_size &split_images
	1 list items

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.10&r2=1.11

--- LVM2/scripts/gdbinit	2011/09/13 13:57:02	1.10
+++ LVM2/scripts/gdbinit	2011/09/28 16:32:22	1.11
@@ -16,6 +16,7 @@
 
 printf "\n\n"
 printf "Loading commands:\n"
+printf " - dm_list_size <list ptr>\n"
 printf " - first_seg <LV ptr>\n"
 printf " - lv_status <LV ptr>\n"
 printf " - lv_status_r <LV ptr>\n"
@@ -27,8 +28,8 @@
 printf "Use 'help <command>' for more info\n"
 printf "\n\n"
 printf "Popular breakpoints:\n"
-printf "break _raid_add_images\n"
-printf "run --type raid1 -m 1 vg/lv\n"
+printf "break _get_udev_flags\n"
+printf "run --splitmirrors 1 -n split vg/lv\n"
 printf "\n\n"
 
 set follow-fork-mode child
@@ -40,6 +41,24 @@
 # External functions should have a corresponding 'document'
 # section.  Internal functions should have leading comments
 
+define dm_list_size
+	set $_DLS_list_head = (struct dm_list *)$arg0
+	set $_DLS_list = $_DLS_list_head->n
+	set $_DLS_size = 0
+	
+	while (($_DLS_list != $_DLS_list_head) && ($_DLS_size < 100))
+		set $_DLS_list = $_DLS_list->n
+		set $_DLS_size++
+	end
+
+	printf "%d list items\n", $_DLS_size
+end
+
+document dm_list_size
+Returns the number of elements in the dm_list
+
+	Usage: dm_list_size <list ptr>
+end
 
 #
 # __first_seg <return> <LV>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2012-04-10 23:24 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2012-04-10 23:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2012-04-10 23:24:00

Modified files:
	scripts        : gdbinit 

Log message:
	Add a couple new functions to gdbinit file and decode a couple lv->status flags
	New functions:
	- seg_pvs: Print a list of PVs in a seg_pvs list
	- pv_dev_name: print name of a PV

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.11&r2=1.12

--- LVM2/scripts/gdbinit	2011/09/28 16:32:22	1.11
+++ LVM2/scripts/gdbinit	2012/04/10 23:24:00	1.12
@@ -17,6 +17,7 @@
 printf "\n\n"
 printf "Loading commands:\n"
 printf " - dm_list_size <list ptr>\n"
+printf " - pv_dev_name <PV ptr>\n"
 printf " - first_seg <LV ptr>\n"
 printf " - lv_status <LV ptr>\n"
 printf " - lv_status_r <LV ptr>\n"
@@ -24,12 +25,13 @@
 printf " - seg_item <seg ptr> <index>\n"
 printf " - seg_status <seg ptr>\n"
 printf " - segs_using_this_lv <seg ptr>\n"
+printf " - seg_pvs <list ptr>\n"
 printf " - \n"
 printf "Use 'help <command>' for more info\n"
 printf "\n\n"
 printf "Popular breakpoints:\n"
-printf "break _get_udev_flags\n"
-printf "run --splitmirrors 1 -n split vg/lv\n"
+printf "break _alloc_image_components\n"
+printf "run --repair --use-policies vg/lv\n"
 printf "\n\n"
 
 set follow-fork-mode child
@@ -41,6 +43,8 @@
 # External functions should have a corresponding 'document'
 # section.  Internal functions should have leading comments
 
+
+
 define dm_list_size
 	set $_DLS_list_head = (struct dm_list *)$arg0
 	set $_DLS_list = $_DLS_list_head->n
@@ -60,6 +64,41 @@
 	Usage: dm_list_size <list ptr>
 end
 
+define pv_dev_name
+	set $_PDN_pv = (struct physical_volume *)$arg0
+	set $_PDN_dev = $_PDN_pv->dev
+	set $_PDN_strl = (struct str_list *)$_PDN_dev->aliases.n
+
+	printf "%s\n", $_PDN_strl->str
+end
+
+document pv_dev_name
+Print the name of the PV for the given PV pointer
+
+	Usage: pv_dev_name <PV ptr>
+end
+
+define seg_pvs
+	set $_SP_list_head = (struct dm_list *)$arg0
+	set $_SP_list = $_SP_list_head->n
+	
+	while (($_SP_list != $_SP_list_head) && ($_SP_size < 100))
+		set $_SP_spv = (struct seg_pvs *)$_SP_list
+
+		printf "* Can't print PV list\n"
+
+		set $_SP_list = $_SP_list->n
+	end
+
+	printf "%d list items\n", $_SP_size
+end
+
+document seg_pvs
+Print the elements of a seg_pvs list
+
+	Usage: seg_pvs <list ptr>
+end
+
 #
 # __first_seg <return> <LV>
 define __first_seg
@@ -270,6 +309,16 @@
 		set $_s_status = $_s_status & ~0x00400000U
 		printf " CONVERTING"
 	end
+#	if ($_s_status & LV_REBUILD)
+	if ($_s_status & 0x100000U)
+		set $_s_status = $_s_status & ~0x100000U
+		printf " LV_REBUILD"
+	end
+#	if ($_s_status & PARTIAL_LV)
+	if ($_s_status & 0x1000000U)
+		set $_s_status = $_s_status & ~0x1000000U
+		printf " PARTIAL_LV"
+	end
 #	if ($_s_status & MERGING)
 	if ($_s_status & 0x10000000U)
 		set $_s_status = $_s_status & ~0x10000000U


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-09-13 13:57 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-09-13 13:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-13 13:57:02

Modified files:
	scripts        : gdbinit 

Log message:
	reorder some status flag printing in gdbinit file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.9&r2=1.10

--- LVM2/scripts/gdbinit	2011/09/08 22:19:45	1.9
+++ LVM2/scripts/gdbinit	2011/09/13 13:57:02	1.10
@@ -189,6 +189,21 @@
 		set $_s_status = $_s_status & ~0x0000000400000000LU
 		printf " RAID_IMAGE"
 	end
+#	if ($_s_status & MIRRORED)
+	if ($_s_status & 0x00008000U)
+		set $_s_status = $_s_status & ~0x00008000U
+		printf " MIRRORED"
+	end
+#	if ($_s_status & MIRROR_LOG)
+	if ($_s_status & 0x00020000U)
+		set $_s_status = $_s_status & ~0x00020000U
+		printf " MIRROR_LOG"
+	end
+#	if ($_s_status & MIRROR_IMAGE)
+	if ($_s_status & 0x00040000U)
+		set $_s_status = $_s_status & ~0x00040000U
+		printf " MIRROR_IMAGE"
+	end
 #	if ($_s_status & VISIBLE_LV)
 	if ($_s_status & 0x00000040U)
 		printf " VISIBLE_LV"
@@ -226,21 +241,6 @@
 		set $_s_status = $_s_status & ~0x00004000U
 		printf " LOCKED"
 	end
-#	if ($_s_status & MIRRORED)
-	if ($_s_status & 0x00008000U)
-		set $_s_status = $_s_status & ~0x00008000U
-		printf " MIRRORED"
-	end
-#	if ($_s_status & MIRROR_LOG)
-	if ($_s_status & 0x00020000U)
-		set $_s_status = $_s_status & ~0x00020000U
-		printf " MIRROR_LOG"
-	end
-#	if ($_s_status & MIRROR_IMAGE)
-	if ($_s_status & 0x00040000U)
-		set $_s_status = $_s_status & ~0x00040000U
-		printf " MIRROR_IMAGE"
-	end
 #	if ($_s_status & LV_NOTSYNCED)
 	if ($_s_status & 0x00080000U)
 		set $_s_status = $_s_status & ~0x00080000U


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-09-08 22:19 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-09-08 22:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-08 22:19:45

Modified files:
	scripts        : gdbinit 

Log message:
	Adjust gdbinit script to new RAID status flag values.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.8&r2=1.9

--- LVM2/scripts/gdbinit	2011/09/01 21:01:12	1.8
+++ LVM2/scripts/gdbinit	2011/09/08 22:19:45	1.9
@@ -27,8 +27,8 @@
 printf "Use 'help <command>' for more info\n"
 printf "\n\n"
 printf "Popular breakpoints:\n"
-printf "break _split_mirror_images\n"
-printf "run --splitmirrors 2 -n new vg/lv\n"
+printf "break _raid_add_images\n"
+printf "run --type raid1 -m 1 vg/lv\n"
 printf "\n\n"
 
 set follow-fork-mode child
@@ -175,18 +175,18 @@
 #	Constants defined in metadata-exported.h
 
 #	if ($_s_status & RAID)
-	if ($_s_status & 0x00000001U)
-		set $_s_status = $_s_status & ~0x00000001U
+	if ($_s_status & 0x0000000100000000LU)
+		set $_s_status = $_s_status & ~0x0000000100000000LU
 		printf " RAID"
 	end
 #	if ($_s_status & RAID_META)
-	if ($_s_status & 0x00000002U)
-		set $_s_status = $_s_status & ~0x00000002U
+	if ($_s_status & 0x0000000200000000LU)
+		set $_s_status = $_s_status & ~0x0000000200000000LU
 		printf " RAID_META"
 	end
 #	if ($_s_status & RAID_IMAGE)
-	if ($_s_status & 0x00000004U)
-		set $_s_status = $_s_status & ~0x00000004U
+	if ($_s_status & 0x0000000400000000LU)
+		set $_s_status = $_s_status & ~0x0000000400000000LU
 		printf " RAID_IMAGE"
 	end
 #	if ($_s_status & VISIBLE_LV)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-09-01 21:01 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-09-01 21:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-01 21:01:12

Modified files:
	scripts        : gdbinit 

Log message:
	Updates to gdbinit file
	
	1) Add more status flags for printing
	2) Fix bug in lv_status_r processing for mirror segment type

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.7&r2=1.8

--- LVM2/scripts/gdbinit	2011/07/01 16:15:25	1.7
+++ LVM2/scripts/gdbinit	2011/09/01 21:01:12	1.8
@@ -27,8 +27,8 @@
 printf "Use 'help <command>' for more info\n"
 printf "\n\n"
 printf "Popular breakpoints:\n"
-printf "break lv_raid_change_image_count\n"
-printf "run -m1 vg/lv\n"
+printf "break _split_mirror_images\n"
+printf "run --splitmirrors 2 -n new vg/lv\n"
 printf "\n\n"
 
 set follow-fork-mode child
@@ -114,7 +114,7 @@
 	set $_SMI_seg  = (struct lv_segment *)$arg1
 	set $_SMI_index= $arg2
 
-	if ($_SMI_index < $_SMI_seg->area_count)
+	if (($_SMI_index < $_SMI_seg->area_count) && $_SMI_seg->meta_areas)
 		set $_SMI_area = $_SMI_seg->meta_areas[$_SMI_index]
 		set $_SMI_type = $_SMI_area.type
 
@@ -174,6 +174,21 @@
 
 #	Constants defined in metadata-exported.h
 
+#	if ($_s_status & RAID)
+	if ($_s_status & 0x00000001U)
+		set $_s_status = $_s_status & ~0x00000001U
+		printf " RAID"
+	end
+#	if ($_s_status & RAID_META)
+	if ($_s_status & 0x00000002U)
+		set $_s_status = $_s_status & ~0x00000002U
+		printf " RAID_META"
+	end
+#	if ($_s_status & RAID_IMAGE)
+	if ($_s_status & 0x00000004U)
+		set $_s_status = $_s_status & ~0x00000004U
+		printf " RAID_IMAGE"
+	end
 #	if ($_s_status & VISIBLE_LV)
 	if ($_s_status & 0x00000040U)
 		printf " VISIBLE_LV"
@@ -186,6 +201,16 @@
 		set $_s_status = $_s_status & ~0x00000080U
 		printf " FIXED_MINOR"
 	end
+#	if ($_s_status & LVM_READ)
+	if ($_s_status & 0x00000100U)
+		set $_s_status = $_s_status & ~0x00000100U
+		printf " LVM_READ"
+	end
+#	if ($_s_status & LVM_WRITE)
+	if ($_s_status & 0x00000200U)
+		set $_s_status = $_s_status & ~0x00000200U
+		printf " LVM_WRITE"
+	end
 #	if ($_s_status & SNAPSHOT)
 	if ($_s_status & 0x00001000U)
 		set $_s_status = $_s_status & ~0x00001000U
@@ -216,21 +241,6 @@
 		set $_s_status = $_s_status & ~0x00040000U
 		printf " MIRROR_IMAGE"
 	end
-#	if ($_s_status & RAID)
-	if ($_s_status & 0x00000001U)
-		set $_s_status = $_s_status & ~0x00000001U
-		printf " RAID"
-	end
-#	if ($_s_status & RAID_META)
-	if ($_s_status & 0x00000002U)
-		set $_s_status = $_s_status & ~0x00000002U
-		printf " RAID_META"
-	end
-#	if ($_s_status & RAID_IMAGE)
-	if ($_s_status & 0x00000004U)
-		set $_s_status = $_s_status & ~0x00000004U
-		printf " RAID_IMAGE"
-	end
 #	if ($_s_status & LV_NOTSYNCED)
 	if ($_s_status & 0x00080000U)
 		set $_s_status = $_s_status & ~0x00080000U
@@ -241,15 +251,10 @@
 		set $_s_status = $_s_status & ~0x00400000U
 		printf " CONVERTING"
 	end
-#	if ($_s_status & LVM_READ)
-	if ($_s_status & 0x00000100U)
-		set $_s_status = $_s_status & ~0x00000100U
-		printf " LVM_READ"
-	end
-#	if ($_s_status & LVM_WRITE)
-	if ($_s_status & 0x00000200U)
-		set $_s_status = $_s_status & ~0x00000200U
-		printf " LVM_WRITE"
+#	if ($_s_status & MERGING)
+	if ($_s_status & 0x10000000U)
+		set $_s_status = $_s_status & ~0x10000000U
+		printf " MERGING"
 	end
 
 	if ($_s_status)
@@ -417,7 +422,9 @@
 # __lv_status_r <LV>
 # Decend tree, printing LV and seg status as we go.  This
 # performs a depth first approach (but can't come up) 
+#
 # or
+#
 # __lv_status_r <sub_lv> <seg using sub_lv>
 # Try continuing decent of tree by first shifting to the
 # next 'area' in the seg ($arg1).  If no more areas, then
@@ -464,7 +471,6 @@
 		if (!$_area_index)
 			seg_status $_seg $indent
 		end
-
 		__seg_type $_type $_seg $_area_index
 		if ($_type == AREA_LV)
 			set $indent++


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-07-01 16:15 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-07-01 16:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-07-01 16:15:25

Modified files:
	scripts        : gdbinit 

Log message:
	RAID updates for gdbinit file

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.6&r2=1.7

--- LVM2/scripts/gdbinit	2011/03/29 12:53:13	1.6
+++ LVM2/scripts/gdbinit	2011/07/01 16:15:25	1.7
@@ -27,12 +27,8 @@
 printf "Use 'help <command>' for more info\n"
 printf "\n\n"
 printf "Popular breakpoints:\n"
-printf "break lv_extend\n"
-printf "break check_lv_segments\n"
-printf "break text_import_areas\n"
-printf "run --type raid1 -L 200M -n lv vg\n"
-printf "run -m1 -L 200M -n lv vg\n"
-printf "lv_status_r lv\n"
+printf "break lv_raid_change_image_count\n"
+printf "run -m1 vg/lv\n"
 printf "\n\n"
 
 set follow-fork-mode child
@@ -79,7 +75,7 @@
 end
 
 #
-# __seg_item <return> <seg> <index>
+# __seg_type <return> <seg> <index>
 define __seg_type
 	set $arg0  = 0x0
 	set $_ST_seg  = (struct lv_segment *)$arg1
@@ -111,6 +107,27 @@
 	end
 end
 
+#
+# __seg_metaitem <return> <seg> <index>
+define __seg_metaitem
+	set $arg0  = 0x0
+	set $_SMI_seg  = (struct lv_segment *)$arg1
+	set $_SMI_index= $arg2
+
+	if ($_SMI_index < $_SMI_seg->area_count)
+		set $_SMI_area = $_SMI_seg->meta_areas[$_SMI_index]
+		set $_SMI_type = $_SMI_area.type
+
+		if ($_SMI_type == AREA_PV)
+			set $arg0 = $_SMI_area.u.pv.pvseg->pv
+		else
+			if ($_SMI_type == AREA_LV)
+				set $arg0 = $_SMI_area.u.lv.lv
+			end
+		end
+	end
+end
+
 define seg_item
 	set $_item = 0x0
 
@@ -122,6 +139,17 @@
 	end
 end
 
+define seg_metaitem
+	set $_metaitem = 0x0
+
+	__seg_metaitem $_metaitem $arg0 $arg1	
+	if ($_metaitem)
+		p $_metaitem
+	else
+		printf "AREA_UNASSIGNED or invalid\n"
+	end
+end
+
 document seg_item
 Returns the pointer to the LV or PV for the indexed area of a segment
 
@@ -142,62 +170,91 @@
 end
 
 define __status
+	set $_s_status = $arg0->status
+
 #	Constants defined in metadata-exported.h
 
-#	if ($arg0->status & VISIBLE_LV)
-	if ($arg0->status & 0x00000040U)
+#	if ($_s_status & VISIBLE_LV)
+	if ($_s_status & 0x00000040U)
 		printf " VISIBLE_LV"
+		set $_s_status = $_s_status & ~0x00000040U
 	else
 		printf " *HIDDEN_LV*"
 	end
-#	if ($arg0->status & FIXED_MINOR)
-	if ($arg0->status & 0x00000080U)
+#	if ($_s_status & FIXED_MINOR)
+	if ($_s_status & 0x00000080U)
+		set $_s_status = $_s_status & ~0x00000080U
 		printf " FIXED_MINOR"
 	end
-#	if ($arg0->status & SNAPSHOT)
-	if ($arg0->status & 0x00001000U)
+#	if ($_s_status & SNAPSHOT)
+	if ($_s_status & 0x00001000U)
+		set $_s_status = $_s_status & ~0x00001000U
 		printf " SNAPSHOT"
 	end
-#	if ($arg0->status & PVMOVE)
-	if ($arg0->status & 0x00002000U)
+#	if ($_s_status & PVMOVE)
+	if ($_s_status & 0x00002000U)
+		set $_s_status = $_s_status & ~0x00002000U
 		printf " PVMOVE"
 	end
-#	if ($arg0->status & LOCKED)
-	if ($arg0->status & 0x00004000U)
+#	if ($_s_status & LOCKED)
+	if ($_s_status & 0x00004000U)
+		set $_s_status = $_s_status & ~0x00004000U
 		printf " LOCKED"
 	end
-#	if ($arg0->status & MIRRORED)
-	if ($arg0->status & 0x00008000U)
+#	if ($_s_status & MIRRORED)
+	if ($_s_status & 0x00008000U)
+		set $_s_status = $_s_status & ~0x00008000U
 		printf " MIRRORED"
 	end
-#	if ($arg0->status & MIRROR_LOG)
-	if ($arg0->status & 0x00020000U)
+#	if ($_s_status & MIRROR_LOG)
+	if ($_s_status & 0x00020000U)
+		set $_s_status = $_s_status & ~0x00020000U
 		printf " MIRROR_LOG"
 	end
-#	if ($arg0->status & MIRROR_IMAGE)
-	if ($arg0->status & 0x00040000U)
+#	if ($_s_status & MIRROR_IMAGE)
+	if ($_s_status & 0x00040000U)
+		set $_s_status = $_s_status & ~0x00040000U
 		printf " MIRROR_IMAGE"
 	end
-#	if ($arg0->status & RAID)
-	if ($arg0->status & 0x00000001U)
+#	if ($_s_status & RAID)
+	if ($_s_status & 0x00000001U)
+		set $_s_status = $_s_status & ~0x00000001U
 		printf " RAID"
 	end
-#	if ($arg0->status & RAID_META)
-	if ($arg0->status & 0x00000002U)
+#	if ($_s_status & RAID_META)
+	if ($_s_status & 0x00000002U)
+		set $_s_status = $_s_status & ~0x00000002U
 		printf " RAID_META"
 	end
-#	if ($arg0->status & RAID_IMAGE)
-	if ($arg0->status & 0x00000004U)
+#	if ($_s_status & RAID_IMAGE)
+	if ($_s_status & 0x00000004U)
+		set $_s_status = $_s_status & ~0x00000004U
 		printf " RAID_IMAGE"
 	end
-#	if ($arg0->status & LV_NOTSYNCED)
-	if ($arg0->status & 0x00080000U)
+#	if ($_s_status & LV_NOTSYNCED)
+	if ($_s_status & 0x00080000U)
+		set $_s_status = $_s_status & ~0x00080000U
 		printf " LV_NOTSYNCED"
 	end
-#	if ($arg0->status & CONVERTING)
-	if ($arg0->status & 0x00400000U)
+#	if ($_s_status & CONVERTING)
+	if ($_s_status & 0x00400000U)
+		set $_s_status = $_s_status & ~0x00400000U
 		printf " CONVERTING"
 	end
+#	if ($_s_status & LVM_READ)
+	if ($_s_status & 0x00000100U)
+		set $_s_status = $_s_status & ~0x00000100U
+		printf " LVM_READ"
+	end
+#	if ($_s_status & LVM_WRITE)
+	if ($_s_status & 0x00000200U)
+		set $_s_status = $_s_status & ~0x00000200U
+		printf " LVM_WRITE"
+	end
+
+	if ($_s_status)
+		printf " 0x%x", $_s_status
+	end
 end
 
 #
@@ -411,6 +468,22 @@
 		__seg_type $_type $_seg $_area_index
 		if ($_type == AREA_LV)
 			set $indent++
+
+			__seg_metaitem $_lv $_seg $_area_index
+			if ($_lv)
+				set $rindent = $indent
+				set $rseg = $_seg
+				set $rarea_index = $_area_index
+				set $rlv = $_lv
+
+				__lv_status_r $_lv
+
+				set $indent = $rindent
+				set $_seg = $rseg
+				set $_area_index = $rarea_index
+				set $_lv = $rlv
+			end
+
 			__seg_item $_lv $_seg $_area_index
 			__lv_status_r $_lv
 		else


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-03-29 12:53 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-03-29 12:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-03-29 12:53:13

Modified files:
	scripts        : gdbinit 

Log message:
	gdbinit update
	
	When doing lv_status_r on a sub_lv, do not climb the tree up past the
	starting point.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.5&r2=1.6

--- LVM2/scripts/gdbinit	2011/03/14 18:05:56	1.5
+++ LVM2/scripts/gdbinit	2011/03/29 12:53:13	1.6
@@ -31,6 +31,7 @@
 printf "break check_lv_segments\n"
 printf "break text_import_areas\n"
 printf "run --type raid1 -L 200M -n lv vg\n"
+printf "run -m1 -L 200M -n lv vg\n"
 printf "lv_status_r lv\n"
 printf "\n\n"
 
@@ -390,8 +391,15 @@
 
 	if ($_s == $_seg_list_head)
 		if ($argc == 1)
+			__print_indent $indent 1
 			printf "[ No segments for %s ]\n", $_lv->name
 		end
+		__get_only_segment_using_this_lv $_seg $_lv
+
+		if ($_seg && $indent)
+			set $indent--
+			__lv_status_r $_lv $_seg
+		end
 	else
 		set $_seg = (struct lv_segment *)$_s
 		set $_type = 0x0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-03-14 18:05 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-03-14 18:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-03-14 18:05:56

Modified files:
	scripts        : gdbinit 

Log message:
	Watch out for collisions in GDB global namespace.
	Better 'lv_status_r' printing.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.4&r2=1.5

--- LVM2/scripts/gdbinit	2011/03/11 22:25:36	1.4
+++ LVM2/scripts/gdbinit	2011/03/14 18:05:56	1.5
@@ -28,6 +28,8 @@
 printf "\n\n"
 printf "Popular breakpoints:\n"
 printf "break lv_extend\n"
+printf "break check_lv_segments\n"
+printf "break text_import_areas\n"
 printf "run --type raid1 -L 200M -n lv vg\n"
 printf "lv_status_r lv\n"
 printf "\n\n"
@@ -46,10 +48,10 @@
 # __first_seg <return> <LV>
 define __first_seg
 	set $arg0 = 0x0
-	set $_lv  = (struct logical_volume *)$arg1
+	set $_FS_lv  = (struct logical_volume *)$arg1
 
-	if ($_lv->segments.n != &$_lv->segments)
-		set $arg0 = (struct lv_segment *)$_lv->segments.n
+	if ($_FS_lv->segments.n != &$_FS_lv->segments)
+		set $arg0 = (struct lv_segment *)$_FS_lv->segments.n
 	end
 end
 
@@ -79,30 +81,30 @@
 # __seg_item <return> <seg> <index>
 define __seg_type
 	set $arg0  = 0x0
-	set $_seg  = (struct lv_segment *)$arg1
-	set $_index= $arg2
-	set $_area = $_seg->areas[$_index]
-	set $_type = $_area.type
+	set $_ST_seg  = (struct lv_segment *)$arg1
+	set $_ST_index= $arg2
+	set $_ST_area = $_ST_seg->areas[$_ST_index]
+	set $_ST_type = $_ST_area.type
 
-	set $arg0 = $_type
+	set $arg0 = $_ST_type
 end
 
 #
 # __seg_item <return> <seg> <index>
 define __seg_item
 	set $arg0  = 0x0
-	set $_seg  = (struct lv_segment *)$arg1
-	set $_index= $arg2
+	set $_SI_seg  = (struct lv_segment *)$arg1
+	set $_SI_index= $arg2
 
-	if ($_index < $_seg->area_count)
-		set $_area = $_seg->areas[$_index]
-		set $_type = $_area.type
+	if ($_SI_index < $_SI_seg->area_count)
+		set $_SI_area = $_SI_seg->areas[$_SI_index]
+		set $_SI_type = $_SI_area.type
 
-		if ($_type == AREA_PV)
-			set $arg0 = $_area.u.pv.pvseg->pv
+		if ($_SI_type == AREA_PV)
+			set $arg0 = $_SI_area.u.pv.pvseg->pv
 		else
-			if ($_type == AREA_LV)
-				set $arg0 = $_area.u.lv.lv
+			if ($_SI_type == AREA_LV)
+				set $arg0 = $_SI_area.u.lv.lv
 			end
 		end
 	end
@@ -197,10 +199,38 @@
 	end
 end
 
+#
+# __print_indent <num indents> [No marks]
+define __print_indent
+	set $_PI_indent = $arg0
+	set $_PI_lead_mark = 0
+
+	while ($_PI_indent)
+		if ($_PI_indent == 1)
+			if ($argc > 1)
+				if ($_PI_lead_mark)
+					printf "        "
+				else
+					printf "|       "
+				end
+			else
+				printf "|-----> "
+			end
+		else
+			printf "|       "
+			set $_PI_lead_mark = 1
+		end
+		set $_PI_indent--
+	end
+end
+
 define lv_status
 	# Use __lv because we don't want to overwrite higher functions
 	set $__lv = (struct logical_volume *)$arg0
 
+	if ($argc == 2)
+		__print_indent $arg1
+	end
 	printf "%s->status:", $__lv->name
 	__status $__lv
 	printf "\n"
@@ -215,6 +245,9 @@
 define seg_status
 	set $_seg=(struct lv_segment *)$arg0
 
+	if ($argc == 2)
+		__print_indent $arg1 1
+	end
 	printf "[ (%s) seg->status:", $_seg->lv->name
 	__status $_seg
 	printf " ]\n"
@@ -223,7 +256,7 @@
 document seg_status
 Display the flags that are set on an lv_segment.
 
-        Usage: lv_status <(struct lv_segment *)>
+        Usage: seg_status <(struct lv_segment *)>
 end
 
 #
@@ -338,8 +371,8 @@
 		set $_s = $_lv->segments.n
 		set $_area_index = 0
 
-		printf "\n"
-		lv_status $_lv
+#		printf "\n"
+		lv_status $_lv $indent
 	else
 		set $_seg = (struct lv_segment *)$arg1
 
@@ -364,20 +397,28 @@
 		set $_type = 0x0
 
 		if (!$_area_index)
-			seg_status $_seg
+			seg_status $_seg $indent
 		end
 
 		__seg_type $_type $_seg $_area_index
 		if ($_type == AREA_LV)
+			set $indent++
 			__seg_item $_lv $_seg $_area_index
 			__lv_status_r $_lv
 		else
 			if ($_seg->log_lv)
-				printf "[LOG OF %s] ", $_lv->name
-				lv_status $_seg->log_lv
+				set $indent++
+				set $_log_seg = 0x0
+
+				__first_seg $_log_seg $_seg->log_lv
+				lv_status $_seg->log_lv $indent
+				seg_status $_log_seg $indent
+
+				set $indent--
 			end
 			__get_only_segment_using_this_lv $_seg $_lv
 			if ($_seg)
+				set $indent--
 				__lv_status_r $_lv $_seg
 			end
 		end
@@ -385,6 +426,7 @@
 end
 
 define lv_status_r
+	set $indent = 0
 	__lv_status_r $arg0
 end
 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-03-11 22:25 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-03-11 22:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-03-11 22:25:36

Modified files:
	scripts        : gdbinit 

Log message:
	lv_status_r now prints out status of attached log LVs
	
	(Print layout could be nicer... :(

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.3&r2=1.4

--- LVM2/scripts/gdbinit	2011/03/11 22:16:38	1.3
+++ LVM2/scripts/gdbinit	2011/03/11 22:25:36	1.4
@@ -198,10 +198,11 @@
 end
 
 define lv_status
-	set $_lv=(struct logical_volume *)$arg0
+	# Use __lv because we don't want to overwrite higher functions
+	set $__lv = (struct logical_volume *)$arg0
 
-	printf "%s->status:", $_lv->name
-	__status $_lv
+	printf "%s->status:", $__lv->name
+	__status $__lv
 	printf "\n"
 end
 
@@ -371,6 +372,10 @@
 			__seg_item $_lv $_seg $_area_index
 			__lv_status_r $_lv
 		else
+			if ($_seg->log_lv)
+				printf "[LOG OF %s] ", $_lv->name
+				lv_status $_seg->log_lv
+			end
 			__get_only_segment_using_this_lv $_seg $_lv
 			if ($_seg)
 				__lv_status_r $_lv $_seg


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-03-11 22:16 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-03-11 22:16 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-03-11 22:16:38

Modified files:
	scripts        : gdbinit 

Log message:
	lv_status_r has been fixed-up so that it supports infinite LV stacking
	
	(It does not yet follow 'log_lv' or 'origin' links.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.2&r2=1.3

--- LVM2/scripts/gdbinit	2011/03/11 18:22:39	1.2
+++ LVM2/scripts/gdbinit	2011/03/11 22:16:38	1.3
@@ -34,13 +34,35 @@
 
 set follow-fork-mode child
 
+# Conventions:
+# foo     : function named 'foo' available to user
+# __foo   : an internal function
+#
+# External functions should have a corresponding 'document'
+# section.  Internal functions should have leading comments
+
+
+#
+# __first_seg <return> <LV>
+define __first_seg
+	set $arg0 = 0x0
+	set $_lv  = (struct logical_volume *)$arg1
+
+	if ($_lv->segments.n != &$_lv->segments)
+		set $arg0 = (struct lv_segment *)$_lv->segments.n
+	end
+end
+
 define first_seg
-	set $__lv=(struct logical_volume *)$arg0
+	set $_seg = 0
+	set $_lv=(struct logical_volume *)$arg0
 
-	if ($__lv->segments.n == &$__lv->segments)
-		printf "No segments (list empty)\n"
+	__first_seg $_seg $_lv
+
+	if ($_seg)
+		p $_seg
 	else
-		p (struct lv_segment *)$__lv->segments.n
+		printf "No segments (list empty)\n"
 	end
 end
 
@@ -53,23 +75,50 @@
 	 this function will be wrong.
 end
 
-define seg_item
-	set $__seg=(struct lv_segment *)$arg0
-	set $__index=$arg1
-	set $__area=$__seg->areas[$__index]
-	set $__type=$__area.type
+#
+# __seg_item <return> <seg> <index>
+define __seg_type
+	set $arg0  = 0x0
+	set $_seg  = (struct lv_segment *)$arg1
+	set $_index= $arg2
+	set $_area = $_seg->areas[$_index]
+	set $_type = $_area.type
+
+	set $arg0 = $_type
+end
+
+#
+# __seg_item <return> <seg> <index>
+define __seg_item
+	set $arg0  = 0x0
+	set $_seg  = (struct lv_segment *)$arg1
+	set $_index= $arg2
+
+	if ($_index < $_seg->area_count)
+		set $_area = $_seg->areas[$_index]
+		set $_type = $_area.type
 
-	if ($__type == AREA_PV)
-		p $__area.u.pv.pvseg->pv
-	else
-		if ($__type == AREA_LV)
-			p $__area.u.lv.lv
+		if ($_type == AREA_PV)
+			set $arg0 = $_area.u.pv.pvseg->pv
 		else
-			printf "AREA_UNASSIGNED or invalid\n"
+			if ($_type == AREA_LV)
+				set $arg0 = $_area.u.lv.lv
+			end
 		end
 	end
 end
 
+define seg_item
+	set $_item = 0x0
+
+	__seg_item $_item $arg0 $arg1	
+	if ($_item)
+		p $_item
+	else
+		printf "AREA_UNASSIGNED or invalid\n"
+	end
+end
+
 document seg_item
 Returns the pointer to the LV or PV for the indexed area of a segment
 
@@ -165,9 +214,9 @@
 define seg_status
 	set $_seg=(struct lv_segment *)$arg0
 
-	printf "(%s) seg->status:", $_seg->lv->name
+	printf "[ (%s) seg->status:", $_seg->lv->name
 	__status $_seg
-	printf "\n"
+	printf " ]\n"
 end
 
 document seg_status
@@ -176,67 +225,29 @@
         Usage: lv_status <(struct lv_segment *)>
 end
 
-define __lv_status_r
-        set $_lv=(struct logical_volume *)$arg0
-	set $_seg_list_head = &$_lv->segments
-	set $_s = $_lv->segments.n
+#
+# get_only_segment_using_this_lv <return> <LV>
+define __get_only_segment_using_this_lv
+	set $arg0 = 0x0
+	set $_lv=(struct logical_volume *)$arg1
+	set $_seg_list_head = &$_lv->segs_using_this_lv
+	set $_s = $_lv->segs_using_this_lv.n
 	set $_i = 0
 
-	# lv_status $_lv
-	printf "%s%s->status:", $arg1, $_lv->name
-	__status $_lv
-	printf "\n"
+	while (($_s != $_seg_list_head) && ($_i < 100))
+		set $_seg_list = (struct seg_list *)$_s
+		set $_seg = (struct lv_segment *)$_seg_list->seg
 
-	if ($_s == $_seg_list_head)
-		printf "[ No segments for %s ]\n", $_lv->name
-	else
-		set $_seg = (struct lv_segment *)$_s
-		while ($_s != $_seg_list_head)
-			printf "%s[ %s->seg(%d)->status:", $arg1, $_lv->name, $_i
-			__status $_seg
-			printf " ]\n"
-
-			set $_j = 0
-			while ($_j < $_seg->area_count)
-				set $_area=$_seg->areas[$_j]
-				set $_type=$_area.type
-				if ($_type == AREA_LV)
-# Damn it, gdb does not have scoping so functions are not reentrant
-#					__lv_status_r $_area.u.lv.lv "    "
-
-# Next couple lines will get us through a non-stacked mirror...
-printf "*    "
-lv_status $_area.u.lv.lv
-set $barf = (struct lv_segment *)($_area.u.lv.lv)->segments.n
-if ($barf != &($_area.u.lv.lv)->segments)
-printf "*    "
-printf "[ %s->seg(0)->status:", $_lv->name
-__status $barf
-printf " ]\n"
-end
-				end
-				set $_j++
-			end
-			set $_s = $_s->n
-			set $_seg = (struct lv_segment *)$_s
-			set $_i++
-		end
+		set $_i++
+		set $_s = $_s->n
 	end
-	printf "\n"	
-end
-
-define lv_status_r
-	__lv_status_r $arg0 ""
-end
 
-document lv_status_r
-Display the status flags of an LV and its sub_lvs.
-
-	Usage: lv_status_r <LV ptr>
-
-This function is useful for checking that all the LVs that
-compose a logical volume have the correct flags set (and also
-their associated lv_segments)
+	if ($_i > 1)
+		printf "More than %s using %s\n", ($_i > 99) ? "100 segments" : "one segment", $_lv->name
+	end
+	if ($_i == 1)
+		set $arg0 = $_seg
+	end
 end
 
 define segs_using_this_lv
@@ -259,8 +270,8 @@
 		else
 			printf "  [seg found in %s]\n", $_seg->lv->name
 		end
+		set $_i++
 		set $_s = $_s->n
-		set $_i = $_i + 1
 	end
 end
 
@@ -287,6 +298,101 @@
 	  0) seg: 0x92d360  [seg found in lv]
 end
 
+#
+# __next_area_index <return> <seg> <seg_item>
+define __next_area_index
+	set $arg0 = 0x0
+	set $_seg = (struct lv_segment *)$arg1
+	set $_item = 0x0
+	set $_i = 0
+
+	__seg_item $_item $_seg $_i
+	while ($_item && ($_item != $arg2))
+		set $_i++
+		__seg_item $_item $_seg $_i
+	end
+
+	# $_i points to current, now get next (if there)
+	set $_i++
+	__seg_item $_item $_seg $_i
+
+	if ($_item)
+		set $arg0 = $_i
+	end
+end
+
+#
+# __lv_status_r <LV>
+# Decend tree, printing LV and seg status as we go.  This
+# performs a depth first approach (but can't come up) 
+# or
+# __lv_status_r <sub_lv> <seg using sub_lv>
+# Try continuing decent of tree by first shifting to the
+# next 'area' in the seg ($arg1).  If no more areas, then
+# try going to the next segment.
+define __lv_status_r
+	if ($argc == 1)
+	        set $_lv=(struct logical_volume *)$arg0
+		set $_seg_list_head = &$_lv->segments
+		set $_s = $_lv->segments.n
+		set $_area_index = 0
+
+		printf "\n"
+		lv_status $_lv
+	else
+		set $_seg = (struct lv_segment *)$arg1
+
+		__next_area_index $_area_index $_seg $arg0
+
+		# Don't fuck this up.  We need the next two lines here.
+	        set $_lv=(struct logical_volume *)$_seg->lv
+		set $_seg_list_head = &$_lv->segments
+		set $_s = (struct dm_list *)$_seg
+
+		if (!$_area_index)
+			set $_s = $_s->n
+		end
+	end
+
+	if ($_s == $_seg_list_head)
+		if ($argc == 1)
+			printf "[ No segments for %s ]\n", $_lv->name
+		end
+	else
+		set $_seg = (struct lv_segment *)$_s
+		set $_type = 0x0
+
+		if (!$_area_index)
+			seg_status $_seg
+		end
+
+		__seg_type $_type $_seg $_area_index
+		if ($_type == AREA_LV)
+			__seg_item $_lv $_seg $_area_index
+			__lv_status_r $_lv
+		else
+			__get_only_segment_using_this_lv $_seg $_lv
+			if ($_seg)
+				__lv_status_r $_lv $_seg
+			end
+		end
+	end
+end
+
+define lv_status_r
+	__lv_status_r $arg0
+end
+
+document lv_status_r
+Display the status flags of an LV and its sub_lvs.
+
+	Usage: lv_status_r <LV ptr>
+
+This function is useful for checking that all the LVs that
+compose a logical volume have the correct flags set (and also
+their associated lv_segments)
+end
+
 define lv_is_mirrored
 	set $_lv=(struct logical_volume *)$arg0
 	set $_fs=(struct lv_segment *)$_lv->segments.n


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-03-11 18:22 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-03-11 18:22 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-03-11 18:22:39

Modified files:
	scripts        : gdbinit 

Log message:
	detect RAID* LV and segment flags.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.1&r2=1.2

--- LVM2/scripts/gdbinit	2011/03/10 13:45:12	1.1
+++ LVM2/scripts/gdbinit	2011/03/11 18:22:39	1.2
@@ -28,7 +28,7 @@
 printf "\n\n"
 printf "Popular breakpoints:\n"
 printf "break lv_extend\n"
-printf "run -m1 -L 200M -n lv vg\n"
+printf "run --type raid1 -L 200M -n lv vg\n"
 printf "lv_status_r lv\n"
 printf "\n\n"
 
@@ -126,9 +126,21 @@
 	if ($arg0->status & 0x00040000U)
 		printf " MIRROR_IMAGE"
 	end
-#	if ($arg0->status & MIRROR_NOTSYNCED)
+#	if ($arg0->status & RAID)
+	if ($arg0->status & 0x00000001U)
+		printf " RAID"
+	end
+#	if ($arg0->status & RAID_META)
+	if ($arg0->status & 0x00000002U)
+		printf " RAID_META"
+	end
+#	if ($arg0->status & RAID_IMAGE)
+	if ($arg0->status & 0x00000004U)
+		printf " RAID_IMAGE"
+	end
+#	if ($arg0->status & LV_NOTSYNCED)
 	if ($arg0->status & 0x00080000U)
-		printf " MIRROR_NOTSYNCED"
+		printf " LV_NOTSYNCED"
 	end
 #	if ($arg0->status & CONVERTING)
 	if ($arg0->status & 0x00400000U)
@@ -178,8 +190,8 @@
 	if ($_s == $_seg_list_head)
 		printf "[ No segments for %s ]\n", $_lv->name
 	else
+		set $_seg = (struct lv_segment *)$_s
 		while ($_s != $_seg_list_head)
-			set $_seg = (struct lv_segment *)$_s
 			printf "%s[ %s->seg(%d)->status:", $arg1, $_lv->name, $_i
 			__status $_seg
 			printf " ]\n"
@@ -203,10 +215,11 @@
 printf " ]\n"
 end
 				end
-				set $_j = $_j + 1
+				set $_j++
 			end
 			set $_s = $_s->n
-			set $_i = $_i + 1
+			set $_seg = (struct lv_segment *)$_s
+			set $_i++
 		end
 	end
 	printf "\n"	


^ permalink raw reply	[flat|nested] 12+ messages in thread

* LVM2/scripts gdbinit
@ 2011-03-10 13:45 jbrassow
  0 siblings, 0 replies; 12+ messages in thread
From: jbrassow @ 2011-03-10 13:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-03-10 13:45:13

Added files:
	scripts        : gdbinit 

Log message:
	gdbinit - A GDB init file to help while debugging LVM.
	
	Copy this file as '.gdbinit' to your home directory or your working
	directory.  It adds the following commands to gdb:
	- first_seg
	- lv_status
	- lv_status_r
	- lv_is_mirrored
	- seg_item
	- seg_status
	- segs_using_this_lv
	
	You can get a list of these user-defined commands by typing:
	(gdb) help user-defined
	
	You can get more information on each command by typing:
	(gdb) help <command>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=NONE&r2=1.1

/cvs/lvm2/LVM2/scripts/gdbinit,v  -->  standard output
revision 1.1
--- LVM2/scripts/gdbinit
+++ -	2011-03-10 13:45:14.261207000 +0000
@@ -0,0 +1,303 @@
+# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+# This file is part of LVM2.
+
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU Lesser General Public License v.2.1.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# Author(s):
+#	Jonathan Brassow <jbrassow@redhat.com>
+#
+# Copy this file to ~/.gdbinit or <working_dir>/.gdbinit
+
+printf "\n\n"
+printf "Loading commands:\n"
+printf " - first_seg <LV ptr>\n"
+printf " - lv_status <LV ptr>\n"
+printf " - lv_status_r <LV ptr>\n"
+printf " - lv_is_mirrored <LV ptr>\n"
+printf " - seg_item <seg ptr> <index>\n"
+printf " - seg_status <seg ptr>\n"
+printf " - segs_using_this_lv <seg ptr>\n"
+printf " - \n"
+printf "Use 'help <command>' for more info\n"
+printf "\n\n"
+printf "Popular breakpoints:\n"
+printf "break lv_extend\n"
+printf "run -m1 -L 200M -n lv vg\n"
+printf "lv_status_r lv\n"
+printf "\n\n"
+
+set follow-fork-mode child
+
+define first_seg
+	set $__lv=(struct logical_volume *)$arg0
+
+	if ($__lv->segments.n == &$__lv->segments)
+		printf "No segments (list empty)\n"
+	else
+		p (struct lv_segment *)$__lv->segments.n
+	end
+end
+
+document first_seg
+Returns the pointer to the first segment of an LV
+
+	Usage: first_seg <LV ptr>
+
+WARNING: If the list pointer in 'struct lv_segment' moves,
+	 this function will be wrong.
+end
+
+define seg_item
+	set $__seg=(struct lv_segment *)$arg0
+	set $__index=$arg1
+	set $__area=$__seg->areas[$__index]
+	set $__type=$__area.type
+
+	if ($__type == AREA_PV)
+		p $__area.u.pv.pvseg->pv
+	else
+		if ($__type == AREA_LV)
+			p $__area.u.lv.lv
+		else
+			printf "AREA_UNASSIGNED or invalid\n"
+		end
+	end
+end
+
+document seg_item
+Returns the pointer to the LV or PV for the indexed area of a segment
+
+	Usage: seg_item <struct lv_segment *> <index>
+
+Example - Getting to the sub-lv of a mirror:
+	(gdb) p lv->name
+	$1 = 0x712548 "lv"
+
+	(gdb) first_seg lv
+	$2 = (struct lv_segment *) 0x7128b8
+
+	(gdb) seg_item $2 0
+	$3 = (struct logical_volume *) 0x712688
+
+	(gdb) p $3->name
+	$4 = 0x712770 "lv_mimage_0"
+end
+
+define __status
+#	Constants defined in metadata-exported.h
+
+#	if ($arg0->status & VISIBLE_LV)
+	if ($arg0->status & 0x00000040U)
+		printf " VISIBLE_LV"
+	else
+		printf " *HIDDEN_LV*"
+	end
+#	if ($arg0->status & FIXED_MINOR)
+	if ($arg0->status & 0x00000080U)
+		printf " FIXED_MINOR"
+	end
+#	if ($arg0->status & SNAPSHOT)
+	if ($arg0->status & 0x00001000U)
+		printf " SNAPSHOT"
+	end
+#	if ($arg0->status & PVMOVE)
+	if ($arg0->status & 0x00002000U)
+		printf " PVMOVE"
+	end
+#	if ($arg0->status & LOCKED)
+	if ($arg0->status & 0x00004000U)
+		printf " LOCKED"
+	end
+#	if ($arg0->status & MIRRORED)
+	if ($arg0->status & 0x00008000U)
+		printf " MIRRORED"
+	end
+#	if ($arg0->status & MIRROR_LOG)
+	if ($arg0->status & 0x00020000U)
+		printf " MIRROR_LOG"
+	end
+#	if ($arg0->status & MIRROR_IMAGE)
+	if ($arg0->status & 0x00040000U)
+		printf " MIRROR_IMAGE"
+	end
+#	if ($arg0->status & MIRROR_NOTSYNCED)
+	if ($arg0->status & 0x00080000U)
+		printf " MIRROR_NOTSYNCED"
+	end
+#	if ($arg0->status & CONVERTING)
+	if ($arg0->status & 0x00400000U)
+		printf " CONVERTING"
+	end
+end
+
+define lv_status
+	set $_lv=(struct logical_volume *)$arg0
+
+	printf "%s->status:", $_lv->name
+	__status $_lv
+	printf "\n"
+end
+
+document lv_status
+Display the flags that are set on an LV.
+
+	Usage: lv_status <LV ptr>
+end
+
+define seg_status
+	set $_seg=(struct lv_segment *)$arg0
+
+	printf "(%s) seg->status:", $_seg->lv->name
+	__status $_seg
+	printf "\n"
+end
+
+document seg_status
+Display the flags that are set on an lv_segment.
+
+        Usage: lv_status <(struct lv_segment *)>
+end
+
+define __lv_status_r
+        set $_lv=(struct logical_volume *)$arg0
+	set $_seg_list_head = &$_lv->segments
+	set $_s = $_lv->segments.n
+	set $_i = 0
+
+	# lv_status $_lv
+	printf "%s%s->status:", $arg1, $_lv->name
+	__status $_lv
+	printf "\n"
+
+	if ($_s == $_seg_list_head)
+		printf "[ No segments for %s ]\n", $_lv->name
+	else
+		while ($_s != $_seg_list_head)
+			set $_seg = (struct lv_segment *)$_s
+			printf "%s[ %s->seg(%d)->status:", $arg1, $_lv->name, $_i
+			__status $_seg
+			printf " ]\n"
+
+			set $_j = 0
+			while ($_j < $_seg->area_count)
+				set $_area=$_seg->areas[$_j]
+				set $_type=$_area.type
+				if ($_type == AREA_LV)
+# Damn it, gdb does not have scoping so functions are not reentrant
+#					__lv_status_r $_area.u.lv.lv "    "
+
+# Next couple lines will get us through a non-stacked mirror...
+printf "*    "
+lv_status $_area.u.lv.lv
+set $barf = (struct lv_segment *)($_area.u.lv.lv)->segments.n
+if ($barf != &($_area.u.lv.lv)->segments)
+printf "*    "
+printf "[ %s->seg(0)->status:", $_lv->name
+__status $barf
+printf " ]\n"
+end
+				end
+				set $_j = $_j + 1
+			end
+			set $_s = $_s->n
+			set $_i = $_i + 1
+		end
+	end
+	printf "\n"	
+end
+
+define lv_status_r
+	__lv_status_r $arg0 ""
+end
+
+document lv_status_r
+Display the status flags of an LV and its sub_lvs.
+
+	Usage: lv_status_r <LV ptr>
+
+This function is useful for checking that all the LVs that
+compose a logical volume have the correct flags set (and also
+their associated lv_segments)
+end
+
+define segs_using_this_lv
+	set $_lv=(struct logical_volume *)$arg0
+	set $_seg_list_head = &$_lv->segs_using_this_lv
+	set $_s = $_lv->segs_using_this_lv.n
+	set $_i = 0
+
+	if ($_s != $_seg_list_head)
+		printf "Segments using %s\n", $_lv->name
+	else
+		printf "No segments using %s\n", $_lv->name
+	end
+	while ($_s != $_seg_list_head)
+		set $_seg_list = (struct seg_list *)$_s
+		set $_seg = (struct lv_segment *)$_seg_list->seg
+		printf "  %d) seg: %p", $_i, $_seg
+		if ($_seg->lv < 0x200)
+			printf "  [BAD LV POINTER FROM THIS SEG]\n"
+		else
+			printf "  [seg found in %s]\n", $_seg->lv->name
+		end
+		set $_s = $_s->n
+		set $_i = $_i + 1
+	end
+end
+
+document segs_using_this_lv
+Display the segments (and their associated LV) using an LV
+
+	Usage: segs_using_this_lv <LV ptr>
+
+Example:
+	(gdb) lv_is_mirrored lv
+	lv is mirrored ('core' log)
+
+	(gdb) segs_using_this_lv lv
+	No segments using lv
+
+	(gdb) first_seg lv
+	$1 = (struct lv_segment *) 0x92d360
+
+	(gdb) seg_item $1 0
+	$2 = (struct logical_volume *) 0x928f58
+
+	(gdb) segs_using_this_lv $2
+	Segments using lv_mimage_0
+	  0) seg: 0x92d360  [seg found in lv]
+end
+
+define lv_is_mirrored
+	set $_lv=(struct logical_volume *)$arg0
+	set $_fs=(struct lv_segment *)$_lv->segments.n
+	set $_log_lv=(struct logical_volume *)$_fs->log_lv
+
+#	if ($_lv->status & MIRRORED)
+	if ($_lv->status & 0x00008000U)
+		printf "%s is mirrored (", $_lv->name
+		if ($_log_lv)
+			if ($_log_lv->status & 0x00008000U)
+				printf "'mirrored' log)\n"
+			else
+				printf "'disk' log)\n"
+			end
+		else
+			printf "'core' log)\n"
+		end
+	else
+		printf "%s is not mirrored\n", $_lv->name
+	end
+end
+
+document lv_is_mirrored
+Report whether the given LV is mirrored (and its log type).
+
+	Usage: lv_is_mirrored <LV ptr>
+end


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-04-10 23:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-28 16:32 LVM2/scripts gdbinit jbrassow
  -- strict thread matches above, loose matches on Subject: below --
2012-04-10 23:24 jbrassow
2011-09-13 13:57 jbrassow
2011-09-08 22:19 jbrassow
2011-09-01 21:01 jbrassow
2011-07-01 16:15 jbrassow
2011-03-29 12:53 jbrassow
2011-03-14 18:05 jbrassow
2011-03-11 22:25 jbrassow
2011-03-11 22:16 jbrassow
2011-03-11 18:22 jbrassow
2011-03-10 13:45 jbrassow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).