This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] XFAIL bigcore.exp on some GNU/Linux targets


Why not ask the program the heap size? it's in total_allocated, just make that a static.

+# Traverse part of bigcore's linked list of memory chunks, finding the total
+# size.  Note that we use GDB to do the math; TCL is not reliable with
+# extremely large integers.
+
+proc heap_size { } {
+    global gdb_prompt
+    global expect_out
+    set test "find heap size"
+    set lim 0
+    gdb_test "set \$size = 0" ""
+    gdb_test_multiple "print heap.next" "$test" {
+	-re " = \\(struct list \\*\\) 0x0.*$gdb_prompt $" {
+	    pass "$test"
+	}
+	-re " = \\(struct list \\*\\) (0x\[0-9a-f\]*).*$gdb_prompt $" {
+	    if { $lim >= 50 } {
+		pass "$test (stop at $lim)"
+	    } else {
+		incr lim
+		gdb_test "set \$size = \$size + \$.size" ""
+		send_gdb "print \$.next\n"
+		exp_continue
+	    }
+	}
+	-re ".*$gdb_prompt $" {
+	    fail "$test (entry $lim)"
+	}
+	timeout {
+	    fail "$test (timeout)"
+	}
+    }
+    gdb_test_multiple "print \$size" "print \$size" {
+	-re " = (\[0-9\]*)\r\n$gdb_prompt $" {
+	    set size $expect_out(1,string)
+	    pass "print \$size"
+	}
+    }
+    return $size;
+}
+


Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]