]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.5-gcore-buffer-limit-test.patch
- obsolete file
[packages/gdb.git] / gdb-6.5-gcore-buffer-limit-test.patch
1 diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.c gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.c
2 --- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.c     1970-01-01 01:00:00.000000000 +0100
3 +++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.c     2008-01-08 11:25:45.000000000 +0100
4 @@ -0,0 +1,37 @@
5 +/* This testcase is part of GDB, the GNU debugger.
6 +
7 +   Copyright 2008 Free Software Foundation, Inc.
8 +
9 +   This program is free software; you can redistribute it and/or modify
10 +   it under the terms of the GNU General Public License as published by
11 +   the Free Software Foundation; either version 2 of the License, or
12 +   (at your option) any later version.
13 +
14 +   This program is distributed in the hope that it will be useful,
15 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
16 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 +   GNU General Public License for more details.
18
19 +   You should have received a copy of the GNU General Public License
20 +   along with this program; if not, write to the Free Software
21 +   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 +
23 +   Please email any bugs, comments, and/or additions to this file to:
24 +   bug-gdb@prep.ai.mit.edu  */
25 +
26 +#include <unistd.h>
27 +#include <stdlib.h>
28 +
29 +#define MEGS 64
30 +
31 +int main()
32 +{
33 +  void *mem;
34 +  
35 +  mem = malloc (MEGS * 1024ULL * 1024ULL);
36 +
37 +  for (;;)
38 +    sleep (1);
39 +
40 +  return 0;
41 +}
42 diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
43 --- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp   1970-01-01 01:00:00.000000000 +0100
44 +++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp   2008-01-08 11:47:32.000000000 +0100
45 @@ -0,0 +1,101 @@
46 +# Copyright 2008 Free Software Foundation, Inc.
47 +
48 +# This program is free software; you can redistribute it and/or modify
49 +# it under the terms of the GNU General Public License as published by
50 +# the Free Software Foundation; either version 2 of the License, or
51 +# (at your option) any later version.
52 +# 
53 +# This program is distributed in the hope that it will be useful,
54 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
55 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
56 +# GNU General Public License for more details.
57 +# 
58 +# You should have received a copy of the GNU General Public License
59 +# along with this program; if not, write to the Free Software
60 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
61 +
62 +if $tracelevel then {
63 +    strace $tracelevel
64 +}
65 +
66 +set prms_id 0
67 +set bug_id 0
68 +
69 +set testfile gcore-excessive-memory
70 +set srcfile ${testfile}.c
71 +set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
72 +set corefile ${objdir}/${subdir}/${testfile}.core
73 +set binfile ${objdir}/${subdir}/${testfile}
74 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
75 +    untested "Couldn't compile test program"
76 +    return -1
77 +}
78 +
79 +set f [open "|getconf PAGESIZE" "r"]
80 +gets $f pagesize
81 +close $f
82 +
83 +set pid_of_bin [eval exec $binfile &]
84 +sleep 2
85 +
86 +# Get things started.
87 +
88 +gdb_exit
89 +gdb_start
90 +gdb_reinitialize_dir $srcdir/$subdir
91 +gdb_load ${binfile}
92 +
93 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
94 +
95 +gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
96 +gdb_test "up 99" "in main .*" "verify we can get to main"
97 +
98 +proc memory_v_pages_get {} {
99 +    global pid_of_gdb pagesize
100 +    set fd [open "/proc/$pid_of_gdb/statm"]
101 +    gets $fd line
102 +    close $fd
103 +    # number of pages of virtual memory
104 +    scan $line "%d" drs
105 +    return $drs
106 +}
107 +
108 +set pages_found [memory_v_pages_get]
109 +
110 +# It must be definitely less than `MEGS' of `gcore-excessive-memory.c'.
111 +set mb_gcore_reserve 4
112 +verbose -log "pages_found = $pages_found, mb_gcore_reserve = $mb_gcore_reserve"
113 +set kb_found [expr $pages_found * $pagesize / 1024]
114 +set kb_permit [expr $kb_found + 1 * 1024 + $mb_gcore_reserve * 1024]
115 +verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
116 +
117 +# Create the ulimit wrapper.
118 +set f [open $shfile "w"]
119 +puts $f "#! /bin/sh"
120 +puts $f "ulimit -v $kb_permit"
121 +puts $f "exec $GDB \"\$@\""
122 +close $f
123 +remote_exec host "chmod +x $shfile"
124 +
125 +gdb_exit
126 +set GDBold $GDB
127 +set GDB "$shfile"
128 +gdb_start
129 +set GDB $GDBold
130 +
131 +gdb_reinitialize_dir $srcdir/$subdir
132 +gdb_load ${binfile}
133 +
134 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
135 +
136 +gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
137 +gdb_test "up 99" "in main .*" "verify we can get to main"
138 +
139 +verbose -log "kb_found before gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
140 +
141 +gdb_test "gcore $corefile" "Saved corefile \[^\n\r\]*" "Save the core file"
142 +
143 +verbose -log "kb_found after gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
144 +
145 +# Cleanup.
146 +exec kill -9 $pid_of_bin
This page took 0.045606 seconds and 3 git commands to generate.