source: rtems/contrib/crossrpms/patches/gdb-6.8-rtems4.10-20090312.diff @ 4022445

4.104.115
Last change on this file since 4022445 was 4022445, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/12/09 at 08:59:26

Add psim/configure.

  • Property mode set to 100644
File size: 65.9 KB
RevLine 
[4022445]1diff -Naur gdb-6.8.orig/bfd/config.bfd gdb-6.8-rtems4.10-20090312/bfd/config.bfd
2--- gdb-6.8.orig/bfd/config.bfd 2008-02-14 16:20:24.000000000 +0100
3+++ gdb-6.8-rtems4.10-20090312/bfd/config.bfd   2009-03-12 04:56:03.000000000 +0100
4@@ -712,7 +712,7 @@
5     targ_defvec=bfd_elf32_iq2000_vec
6     ;;
7 
8-  m32c-*-elf)
9+  m32c-*-elf | m32c-*-rtems*)
10     targ_defvec=bfd_elf32_m32c_vec
11     ;;
12 
13@@ -728,6 +728,9 @@
14     targ_defvec=bfd_elf32_m32rle_vec
15     targ_selvecs="bfd_elf32_m32r_vec bfd_elf32_m32rle_vec"
16     ;;
17+  m32r-*-rtems*)
18+    targ_defvec=bfd_elf32_m32r_vec
19+    ;;
20   m32r-*-*)
21     targ_defvec=bfd_elf32_m32r_vec
22     ;;
23diff -Naur gdb-6.8.orig/gdb/breakpoint.c gdb-6.8-rtems4.10-20090312/gdb/breakpoint.c
24--- gdb-6.8.orig/gdb/breakpoint.c       2008-02-26 09:14:11.000000000 +0100
25+++ gdb-6.8-rtems4.10-20090312/gdb/breakpoint.c 2009-03-12 04:56:03.000000000 +0100
26@@ -55,6 +55,7 @@
27 #include "memattr.h"
28 #include "ada-lang.h"
29 #include "top.h"
30+#include "wrapper.h"
31 
32 #include "gdb-events.h"
33 #include "mi/mi-common.h"
34@@ -826,7 +827,65 @@
35          || bpt->type == bp_access_watchpoint);
36 }
37 
38-/* Assuming that B is a hardware breakpoint:
39+/* Find the current value of a watchpoint on EXP.  Return the value in
40+   *VALP and *RESULTP and the chain of intermediate and final values
41+   in *VAL_CHAIN.  RESULTP and VAL_CHAIN may be NULL if the caller does
42+   not need them.
43+
44+   If an error occurs while evaluating the expression, *RESULTP will
45+   be set to NULL.  *RESULTP may be a lazy value, if the result could
46+   not be read from memory.  It is used to determine whether a value
47+   is user-specified (we should watch the whole value) or intermediate
48+   (we should watch only the bit used to locate the final value).
49+
50+   If the final value, or any intermediate value, could not be read
51+   from memory, *VALP will be set to NULL.  *VAL_CHAIN will still be
52+   set to any referenced values.  *VALP will never be a lazy value.
53+   This is the value which we store in struct breakpoint.
54+
55+   If VAL_CHAIN is non-NULL, *VAL_CHAIN will be released from the
56+   value chain.  The caller must free the values individually.  If
57+   VAL_CHAIN is NULL, all generated values will be left on the value
58+   chain.  */
59+
60+static void
61+fetch_watchpoint_value (struct expression *exp, struct value **valp,
62+                       struct value **resultp, struct value **val_chain)
63+{
64+  struct value *mark, *new_mark, *result;
65+
66+  *valp = NULL;
67+  if (resultp)
68+    *resultp = NULL;
69+  if (val_chain)
70+    *val_chain = NULL;
71+
72+  /* Evaluate the expression.  */
73+  mark = value_mark ();
74+  result = NULL;
75+  gdb_evaluate_expression (exp, &result);
76+  new_mark = value_mark ();
77+  if (mark == new_mark)
78+    return;
79+  if (resultp)
80+    *resultp = result;
81+
82+  /* Make sure it's not lazy, so that after the target stops again we
83+     have a non-lazy previous value to compare with.  */
84+  if (result != NULL
85+      && (!value_lazy (result) || gdb_value_fetch_lazy (result)))
86+    *valp = result;
87+
88+  if (val_chain)
89+    {
90+      /* Return the chain of intermediate values.  We use this to
91+        decide which addresses to watch.  */
92+      *val_chain = new_mark;
93+      value_release_to_mark (mark);
94+    }
95+}
96+
97+/* Assuming that B is a hardware watchpoint:
98    - Reparse watchpoint expression, is REPARSE is non-zero
99    - Evaluate expression and store the result in B->val
100    - Update the list of values that must be watched in B->loc.
101@@ -837,7 +896,6 @@
102 update_watchpoint (struct breakpoint *b, int reparse)
103 {
104   int within_current_scope;
105-  struct value *mark = value_mark ();
106   struct frame_id saved_frame_id;
107   struct bp_location *loc;
108   bpstat bs;
109@@ -889,9 +947,9 @@
110         to the user when the old value and the new value may actually
111         be completely different objects.  */
112       value_free (b->val);
113-      b->val = NULL;     
114+      b->val = NULL;
115+      b->val_valid = 0;
116     }
117
118 
119   /* If we failed to parse the expression, for example because
120      it refers to a global variable in a not-yet-loaded shared library,
121@@ -900,43 +958,37 @@
122      is different from out-of-scope watchpoint.  */
123   if (within_current_scope && b->exp)
124     {
125-      struct value *v, *next;
126+      struct value *val_chain, *v, *result, *next;
127+
128+      fetch_watchpoint_value (b->exp, &v, &result, &val_chain);
129 
130-      /* Evaluate the expression and make sure it's not lazy, so that
131-        after target stops again, we have a non-lazy previous value
132-        to compare with. Also, making the value non-lazy will fetch
133-        intermediate values as needed, which we use to decide which
134-        addresses to watch.
135-
136-        The value returned by evaluate_expression is stored in b->val.
137-        In addition, we look at all values which were created
138-        during evaluation, and set watchoints at addresses as needed.
139-        Those values are explicitly deleted here.  */
140-      v = evaluate_expression (b->exp);
141       /* Avoid setting b->val if it's already set.  The meaning of
142         b->val is 'the last value' user saw, and we should update
143         it only if we reported that last value to user.  As it
144         happens, the code that reports it updates b->val directly.  */
145-      if (b->val == NULL)
146-       b->val = v;
147-      value_contents (v);
148-      value_release_to_mark (mark);
149+      if (!b->val_valid)
150+       {
151+         b->val = v;
152+         b->val_valid = 1;
153+       }
154 
155       /* Look at each value on the value chain.  */
156-      for (; v; v = next)
157+      for (v = val_chain; v; v = next)
158        {
159          /* If it's a memory location, and GDB actually needed
160             its contents to evaluate the expression, then we
161-            must watch it.  */
162+            must watch it.  If the first value returned is
163+            still lazy, that means an error occurred reading it;
164+            watch it anyway in case it becomes readable.  */
165          if (VALUE_LVAL (v) == lval_memory
166-             && ! value_lazy (v))
167+             && (v == val_chain || ! value_lazy (v)))
168            {
169              struct type *vtype = check_typedef (value_type (v));
170 
171              /* We only watch structs and arrays if user asked
172                 for it explicitly, never if they just happen to
173                 appear in the middle of some value chain.  */
174-             if (v == b->val
175+             if (v == result
176                  || (TYPE_CODE (vtype) != TYPE_CODE_STRUCT
177                      && TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
178                {
179@@ -1681,6 +1733,7 @@
180            if (b->val)
181              value_free (b->val);
182            b->val = NULL;
183+           b->val_valid = 0;
184          }
185        break;
186       default:
187@@ -2103,6 +2156,17 @@
188   do_cleanups (old_chain);
189 }
190 
191+/* Print out the (old or new) value associated with a watchpoint.  */
192+
193+static void
194+watchpoint_value_print (struct value *val, struct ui_file *stream)
195+{
196+  if (val == NULL)
197+    fprintf_unfiltered (stream, _("<unreadable>"));
198+  else
199+    value_print (val, stream, 0, Val_pretty_default);
200+}
201+
202 /* This is the normal print function for a bpstat.  In the future,
203    much of this logic could (should?) be moved to bpstat_stop_status,
204    by having it set different print_it values.
205@@ -2221,26 +2285,21 @@
206 
207     case bp_watchpoint:
208     case bp_hardware_watchpoint:
209-      if (bs->old_val != NULL)
210-       {
211-         annotate_watchpoint (b->number);
212-         if (ui_out_is_mi_like_p (uiout))
213-           ui_out_field_string
214-             (uiout, "reason",
215-              async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
216-         mention (b);
217-         ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
218-         ui_out_text (uiout, "\nOld value = ");
219-         value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
220-         ui_out_field_stream (uiout, "old", stb);
221-         ui_out_text (uiout, "\nNew value = ");
222-         value_print (b->val, stb->stream, 0, Val_pretty_default);
223-         ui_out_field_stream (uiout, "new", stb);
224-         do_cleanups (ui_out_chain);
225-         ui_out_text (uiout, "\n");
226-         value_free (bs->old_val);
227-         bs->old_val = NULL;
228-       }
229+      annotate_watchpoint (b->number);
230+      if (ui_out_is_mi_like_p (uiout))
231+       ui_out_field_string
232+         (uiout, "reason",
233+          async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
234+      mention (b);
235+      ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
236+      ui_out_text (uiout, "\nOld value = ");
237+      watchpoint_value_print (bs->old_val, stb->stream);
238+      ui_out_field_stream (uiout, "old", stb);
239+      ui_out_text (uiout, "\nNew value = ");
240+      watchpoint_value_print (b->val, stb->stream);
241+      ui_out_field_stream (uiout, "new", stb);
242+      do_cleanups (ui_out_chain);
243+      ui_out_text (uiout, "\n");
244       /* More than one watchpoint may have been triggered.  */
245       return PRINT_UNKNOWN;
246       break;
247@@ -2253,7 +2312,7 @@
248       mention (b);
249       ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
250       ui_out_text (uiout, "\nValue = ");
251-      value_print (b->val, stb->stream, 0, Val_pretty_default);
252+      watchpoint_value_print (b->val, stb->stream);
253       ui_out_field_stream (uiout, "value", stb);
254       do_cleanups (ui_out_chain);
255       ui_out_text (uiout, "\n");
256@@ -2261,7 +2320,7 @@
257       break;
258 
259     case bp_access_watchpoint:
260-      if (bs->old_val != NULL)     
261+      if (bs->old_val != NULL)
262        {
263          annotate_watchpoint (b->number);
264          if (ui_out_is_mi_like_p (uiout))
265@@ -2271,10 +2330,8 @@
266          mention (b);
267          ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
268          ui_out_text (uiout, "\nOld value = ");
269-         value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
270+         watchpoint_value_print (bs->old_val, stb->stream);
271          ui_out_field_stream (uiout, "old", stb);
272-         value_free (bs->old_val);
273-         bs->old_val = NULL;
274          ui_out_text (uiout, "\nNew value = ");
275        }
276       else
277@@ -2287,7 +2344,7 @@
278          ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
279          ui_out_text (uiout, "\nValue = ");
280        }
281-      value_print (b->val, stb->stream, 0,Val_pretty_default);
282+      watchpoint_value_print (b->val, stb->stream);
283       ui_out_field_stream (uiout, "new", stb);
284       do_cleanups (ui_out_chain);
285       ui_out_text (uiout, "\n");
286@@ -2574,13 +2631,20 @@
287          we might be in the middle of evaluating a function call.  */
288 
289       struct value *mark = value_mark ();
290-      struct value *new_val = evaluate_expression (b->exp);
291-      if (!value_equal (b->val, new_val))
292+      struct value *new_val;
293+
294+      fetch_watchpoint_value (b->exp, &new_val, NULL, NULL);
295+      if ((b->val != NULL) != (new_val != NULL)
296+         || (b->val != NULL && !value_equal (b->val, new_val)))
297        {
298-         release_value (new_val);
299-         value_free_to_mark (mark);
300+         if (new_val != NULL)
301+           {
302+             release_value (new_val);
303+             value_free_to_mark (mark);
304+           }
305          bs->old_val = b->val;
306          b->val = new_val;
307+         b->val_valid = 1;
308          /* We will stop here */
309          return WP_VALUE_CHANGED;
310        }
311@@ -5722,10 +5786,9 @@
312   exp_end = arg;
313   exp_valid_block = innermost_block;
314   mark = value_mark ();
315-  val = evaluate_expression (exp);
316-  release_value (val);
317-  if (value_lazy (val))
318-    value_fetch_lazy (val);
319+  fetch_watchpoint_value (exp, &val, NULL, NULL);
320+  if (val != NULL)
321+    release_value (val);
322 
323   tok = arg;
324   while (*tok == ' ' || *tok == '\t')
325@@ -5814,6 +5877,7 @@
326   b->exp_valid_block = exp_valid_block;
327   b->exp_string = savestring (exp_start, exp_end - exp_start);
328   b->val = val;
329+  b->val_valid = 1;
330   b->loc->cond = cond;
331   if (cond_start)
332     b->cond_string = savestring (cond_start, cond_end - cond_start);
333@@ -7697,11 +7761,11 @@
334       if (bpt->val)
335        value_free (bpt->val);
336       mark = value_mark ();
337-      bpt->val = evaluate_expression (bpt->exp);
338-      release_value (bpt->val);
339-      if (value_lazy (bpt->val))
340-       value_fetch_lazy (bpt->val);
341-     
342+      fetch_watchpoint_value (bpt->exp, &bpt->val, NULL, NULL);
343+      if (bpt->val)
344+       release_value (bpt->val);
345+      bpt->val_valid = 1;
346+
347       if (bpt->type == bp_hardware_watchpoint ||
348          bpt->type == bp_read_watchpoint ||
349          bpt->type == bp_access_watchpoint)
350diff -Naur gdb-6.8.orig/gdb/breakpoint.h gdb-6.8-rtems4.10-20090312/gdb/breakpoint.h
351--- gdb-6.8.orig/gdb/breakpoint.h       2008-02-01 17:24:46.000000000 +0100
352+++ gdb-6.8-rtems4.10-20090312/gdb/breakpoint.h 2009-03-12 04:56:03.000000000 +0100
353@@ -391,8 +391,13 @@
354     /* The largest block within which it is valid, or NULL if it is
355        valid anywhere (e.g. consists just of global symbols).  */
356     struct block *exp_valid_block;
357-    /* Value of the watchpoint the last time we checked it.  */
358+    /* Value of the watchpoint the last time we checked it, or NULL
359+       when we do not know the value yet or the value was not
360+       readable.  VAL is never lazy.  */
361     struct value *val;
362+    /* Nonzero if VAL is valid.  If VAL_VALID is set but VAL is NULL,
363+       then an error occurred reading the value.  */
364+    int val_valid;
365 
366     /* Holds the address of the related watchpoint_scope breakpoint
367        when using watchpoints on local variables (might the concept
368diff -Naur gdb-6.8.orig/gdb/NEWS gdb-6.8-rtems4.10-20090312/gdb/NEWS
369--- gdb-6.8.orig/gdb/NEWS       2008-03-27 19:14:10.000000000 +0100
370+++ gdb-6.8-rtems4.10-20090312/gdb/NEWS 2009-03-12 04:56:03.000000000 +0100
371@@ -1,6 +1,9 @@
372                What has changed in GDB?
373             (Organized release by release)
374 
375+* Watchpoints can now be set on unreadable memory locations, e.g. addresses
376+which will be allocated using malloc later in program execution.
377+
378 *** Changes in GDB 6.8
379 
380 * New native configurations
381diff -Naur gdb-6.8.orig/gdb/testsuite/gdb.base/watchpoint.c gdb-6.8-rtems4.10-20090312/gdb/testsuite/gdb.base/watchpoint.c
382--- gdb-6.8.orig/gdb/testsuite/gdb.base/watchpoint.c    2003-03-17 20:51:58.000000000 +0100
383+++ gdb-6.8-rtems4.10-20090312/gdb/testsuite/gdb.base/watchpoint.c      2009-03-12 04:56:03.000000000 +0100
384@@ -39,6 +39,8 @@
385 
386 int doread = 0;
387 
388+char *global_ptr;
389+
390 void marker1 ()
391 {
392 }
393@@ -110,6 +112,14 @@
394   return 73;
395 }
396 
397+void
398+func4 ()
399+{
400+  buf[0] = 3;
401+  global_ptr = buf;
402+  buf[0] = 7;
403+}
404+
405 int main ()
406 {
407 #ifdef usestubs
408@@ -185,5 +195,7 @@
409 
410   func3 ();
411 
412+  func4 ();
413+
414   return 0;
415 }
416diff -Naur gdb-6.8.orig/gdb/testsuite/gdb.base/watchpoint.exp gdb-6.8-rtems4.10-20090312/gdb/testsuite/gdb.base/watchpoint.exp
417--- gdb-6.8.orig/gdb/testsuite/gdb.base/watchpoint.exp  2008-01-01 23:53:19.000000000 +0100
418+++ gdb-6.8-rtems4.10-20090312/gdb/testsuite/gdb.base/watchpoint.exp    2009-03-12 04:56:03.000000000 +0100
419@@ -645,6 +645,30 @@
420     }
421 }
422     
423+proc test_inaccessible_watchpoint {} {
424+    global gdb_prompt
425+
426+    # This is a test for watchpoints on currently inaccessible (but later
427+    # valid) memory.
428+
429+    if [runto func4] then {
430+       gdb_test "watch *global_ptr" ".*atchpoint \[0-9\]+: \\*global_ptr"
431+       gdb_test "next" ".*global_ptr = buf.*"
432+       gdb_test_multiple "next" "next over ptr init" {
433+           -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = .*\r\nNew value = 3 .*\r\n.*$gdb_prompt $" {
434+               # We can not test for <unknown> here because NULL may be readable.
435+               # This test does rely on *NULL != 3.
436+               pass "next over ptr init"
437+           }
438+       }
439+       gdb_test_multiple "next" "next over buffer set" {
440+           -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = 3 .*\r\nNew value = 7 .*\r\n.*$gdb_prompt $" {
441+               pass "next over buffer set"
442+           }
443+       }
444+    }
445+}
446+   
447 # Start with a fresh gdb.
448 
449 gdb_exit
450@@ -797,6 +821,8 @@
451       }
452     }
453 
454+    test_inaccessible_watchpoint
455+
456     # See above.
457     if [istarget "mips-idt-*"] then {
458        gdb_exit
459diff -Naur gdb-6.8.orig/sim/common/aclocal.m4 gdb-6.8-rtems4.10-20090312/sim/common/aclocal.m4
460--- gdb-6.8.orig/sim/common/aclocal.m4  2006-06-13 10:06:48.000000000 +0200
461+++ gdb-6.8-rtems4.10-20090312/sim/common/aclocal.m4    2009-03-12 04:56:03.000000000 +0100
462@@ -18,7 +18,7 @@
463 #
464 # SIM_AC_OUTPUT
465 
466-AC_DEFUN(SIM_AC_COMMON,
467+AC_DEFUN([SIM_AC_COMMON],
468 [
469 # autoconf.info says this should be called right after AC_INIT.
470 AC_CONFIG_HEADER(ifelse([$1],,config.h,[$1]):config.in)
471@@ -245,7 +245,7 @@
472 dnl supported.
473 dnl ??? Until there is demonstrable value in doing something more complicated,
474 dnl let's not.
475-AC_DEFUN(SIM_AC_OPTION_ENVIRONMENT,
476+AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
477 [
478 AC_ARG_ENABLE(sim-environment,
479 [  --enable-sim-environment=environment        Specify mixed, user, virtual or operating environment.],
480@@ -269,7 +269,7 @@
481 dnl Without this option all possible alignment restrictions are accommodated.
482 dnl arg[1] is hardwired target alignment
483 dnl arg[2] is default target alignment
484-AC_DEFUN(SIM_AC_OPTION_ALIGNMENT,
485+AC_DEFUN([SIM_AC_OPTION_ALIGNMENT],
486 wire_alignment="[$1]"
487 default_alignment="[$2]"
488 [
489@@ -318,7 +318,7 @@
490 
491 
492 dnl Conditionally compile in assertion statements.
493-AC_DEFUN(SIM_AC_OPTION_ASSERT,
494+AC_DEFUN([SIM_AC_OPTION_ASSERT],
495 [
496 AC_ARG_ENABLE(sim-assert,
497 [  --enable-sim-assert                 Specify whether to perform random assertions.],
498@@ -342,7 +342,7 @@
499 dnl arg[3] is the number of bits in an address
500 dnl arg[4] is the number of bits in an OpenFirmware cell.
501 dnl FIXME: this information should be obtained from bfd/archure
502-AC_DEFUN(SIM_AC_OPTION_BITSIZE,
503+AC_DEFUN([SIM_AC_OPTION_BITSIZE],
504 wire_word_bitsize="[$1]"
505 wire_word_msb="[$2]"
506 wire_address_bitsize="[$3]"
507@@ -408,7 +408,7 @@
508 dnl that support both big and little endian targets.
509 dnl arg[1] is hardwired target endianness.
510 dnl arg[2] is default target endianness.
511-AC_DEFUN(SIM_AC_OPTION_ENDIAN,
512+AC_DEFUN([SIM_AC_OPTION_ENDIAN],
513 [
514 wire_endian="[$1]"
515 default_endian="[$2]"
516@@ -458,7 +458,7 @@
517 dnl --enable-sim-hostendian is for users of the simulator when
518 dnl they find that AC_C_BIGENDIAN does not function correctly
519 dnl (for instance in a canadian cross)
520-AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
521+AC_DEFUN([SIM_AC_OPTION_HOSTENDIAN],
522 [
523 AC_ARG_ENABLE(sim-hostendian,
524 [  --enable-sim-hostendian=end         Specify host byte endian orientation.],
525@@ -490,7 +490,7 @@
526 dnl And optionally the bitsize of the floating point register.
527 dnl arg[1] specifies the presence (or absence) of floating point hardware
528 dnl arg[2] specifies the number of bits in a floating point register
529-AC_DEFUN(SIM_AC_OPTION_FLOAT,
530+AC_DEFUN([SIM_AC_OPTION_FLOAT],
531 [
532 default_sim_float="[$1]"
533 default_sim_float_bitsize="[$2]"
534@@ -519,7 +519,7 @@
535 
536 
537 dnl The argument is the default cache size if none is specified.
538-AC_DEFUN(SIM_AC_OPTION_SCACHE,
539+AC_DEFUN([SIM_AC_OPTION_SCACHE],
540 [
541 default_sim_scache="ifelse([$1],,0,[$1])"
542 AC_ARG_ENABLE(sim-scache,
543@@ -539,7 +539,7 @@
544 
545 
546 dnl The argument is the default model if none is specified.
547-AC_DEFUN(SIM_AC_OPTION_DEFAULT_MODEL,
548+AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL],
549 [
550 default_sim_default_model="ifelse([$1],,0,[$1])"
551 AC_ARG_ENABLE(sim-default-model,
552@@ -559,7 +559,7 @@
553 dnl arg[1] Enable sim-hw by default? ("yes" or "no")
554 dnl arg[2] is a space separated list of devices that override the defaults
555 dnl arg[3] is a space separated list of extra target specific devices.
556-AC_DEFUN(SIM_AC_OPTION_HARDWARE,
557+AC_DEFUN([SIM_AC_OPTION_HARDWARE],
558 [
559 if test x"[$1]" = x"yes"; then
560   sim_hw_p=yes
561@@ -621,7 +621,7 @@
562 dnl performance by inlining functions.
563 dnl Guarantee that unconfigured simulators do not do any inlining
564 sim_inline="-DDEFAULT_INLINE=0"
565-AC_DEFUN(SIM_AC_OPTION_INLINE,
566+AC_DEFUN([SIM_AC_OPTION_INLINE],
567 [
568 default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
569 AC_ARG_ENABLE(sim-inline,
570@@ -666,7 +666,7 @@
571 AC_SUBST(sim_inline)
572 
573 
574-AC_DEFUN(SIM_AC_OPTION_PACKAGES,
575+AC_DEFUN([SIM_AC_OPTION_PACKAGES],
576 [
577 AC_ARG_ENABLE(sim-packages,
578 [  --enable-sim-packages=list          Specify the packages to be included in the build.],
579@@ -692,7 +692,7 @@
580 AC_SUBST(sim_packages)
581 
582 
583-AC_DEFUN(SIM_AC_OPTION_REGPARM,
584+AC_DEFUN([SIM_AC_OPTION_REGPARM],
585 [
586 AC_ARG_ENABLE(sim-regparm,
587 [  --enable-sim-regparm=nr-parm                Pass parameters in registers instead of on the stack - x86/GCC specific.],
588@@ -709,7 +709,7 @@
589 AC_SUBST(sim_regparm)
590 
591 
592-AC_DEFUN(SIM_AC_OPTION_RESERVED_BITS,
593+AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
594 [
595 default_sim_reserved_bits="ifelse([$1],,1,[$1])"
596 AC_ARG_ENABLE(sim-reserved-bits,
597@@ -726,7 +726,7 @@
598 AC_SUBST(sim_reserved_bits)
599 
600 
601-AC_DEFUN(SIM_AC_OPTION_SMP,
602+AC_DEFUN([SIM_AC_OPTION_SMP],
603 [
604 default_sim_smp="ifelse([$1],,5,[$1])"
605 AC_ARG_ENABLE(sim-smp,
606@@ -746,7 +746,7 @@
607 AC_SUBST(sim_smp)
608 
609 
610-AC_DEFUN(SIM_AC_OPTION_STDCALL,
611+AC_DEFUN([SIM_AC_OPTION_STDCALL],
612 [
613 AC_ARG_ENABLE(sim-stdcall,
614 [  --enable-sim-stdcall=type           Use an alternative function call/return mechanism - x86/GCC specific.],
615@@ -763,7 +763,7 @@
616 AC_SUBST(sim_stdcall)
617 
618 
619-AC_DEFUN(SIM_AC_OPTION_XOR_ENDIAN,
620+AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
621 [
622 default_sim_xor_endian="ifelse([$1],,8,[$1])"
623 AC_ARG_ENABLE(sim-xor-endian,
624@@ -782,7 +782,7 @@
625 
626 dnl --enable-build-warnings is for developers of the simulator.
627 dnl it enables extra GCC specific warnings.
628-AC_DEFUN(SIM_AC_OPTION_WARNINGS,
629+AC_DEFUN([SIM_AC_OPTION_WARNINGS],
630 [
631 # NOTE: Don't add -Wall or -Wunused, they both include
632 # -Wunused-parameter which reports bogus warnings.
633@@ -866,7 +866,7 @@
634 dnl one afterwards.  The two pieces of the common fragment are inserted into
635 dnl the target's fragment at the appropriate points.
636 
637-AC_DEFUN(SIM_AC_OUTPUT,
638+AC_DEFUN([SIM_AC_OUTPUT],
639 [
640 AC_LINK_FILES($sim_link_files, $sim_link_links)
641 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
642@@ -895,7 +895,7 @@
643 sinclude(../../config/gettext-sister.m4)
644 
645 dnl --enable-cgen-maint support
646-AC_DEFUN(SIM_AC_OPTION_CGEN_MAINT,
647+AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
648 [
649 cgen_maint=no
650 dnl Default is to use one in build tree.
651diff -Naur gdb-6.8.orig/sim/common/gentmap.c gdb-6.8-rtems4.10-20090312/sim/common/gentmap.c
652--- gdb-6.8.orig/sim/common/gentmap.c   2006-11-07 20:29:59.000000000 +0100
653+++ gdb-6.8-rtems4.10-20090312/sim/common/gentmap.c     2009-03-12 04:56:03.000000000 +0100
654@@ -2,6 +2,7 @@
655 
656 #include <stdio.h>
657 #include <stdlib.h>
658+#include <string.h>
659 
660 struct tdefs {
661   char *symbol;
662diff -Naur gdb-6.8.orig/sim/common/sim-signal.c gdb-6.8-rtems4.10-20090312/sim/common/sim-signal.c
663--- gdb-6.8.orig/sim/common/sim-signal.c        2008-01-01 23:53:23.000000000 +0100
664+++ gdb-6.8-rtems4.10-20090312/sim/common/sim-signal.c  2009-03-12 04:56:03.000000000 +0100
665@@ -26,7 +26,7 @@
666    to not think the process has died (so it can be debugged at the point of
667    failure).  */
668 
669-#ifdef _MSC_VER
670+#ifdef _WIN32
671 #ifndef SIGTRAP
672 #define SIGTRAP 5
673 #endif
674diff -Naur gdb-6.8.orig/sim/erc32/configure gdb-6.8-rtems4.10-20090312/sim/erc32/configure
675--- gdb-6.8.orig/sim/erc32/configure    2006-12-20 23:35:51.000000000 +0100
676+++ gdb-6.8-rtems4.10-20090312/sim/erc32/configure      2009-03-12 04:56:03.000000000 +0100
677@@ -309,7 +309,7 @@
678 # include <unistd.h>
679 #endif"
680 
681-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS sim_environment sim_alignment sim_assert sim_bitsize sim_endian sim_hostendian sim_float sim_scache sim_default_model sim_hw_cflags sim_hw_objs sim_hw sim_inline sim_packages sim_regparm sim_reserved_bits sim_smp sim_stdcall sim_xor_endian WARN_CFLAGS WERROR_CFLAGS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC_FOR_BUILD HDEFINES AR RANLIB ac_ct_RANLIB USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT CPP EGREP MAINT sim_bswap sim_cflags sim_debug sim_stdio sim_trace sim_profile TERMCAP READLINE cgen_breaks LIBOBJS LTLIBOBJS'
682+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS sim_environment sim_alignment sim_assert sim_bitsize sim_endian sim_hostendian sim_float sim_scache sim_default_model sim_hw_cflags sim_hw_objs sim_hw sim_inline sim_packages sim_regparm sim_reserved_bits sim_smp sim_stdcall sim_xor_endian WARN_CFLAGS WERROR_CFLAGS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC_FOR_BUILD HDEFINES AR RANLIB ac_ct_RANLIB USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT CPP EGREP MAINT sim_bswap sim_cflags sim_debug sim_stdio sim_trace sim_profile READLINE READLINE_DEPS READLINE_CFLAGS cgen_breaks LIBOBJS LTLIBOBJS'
683 ac_subst_files=''
684 
685 # Initialize some variables set by options.
686@@ -858,6 +858,11 @@
687   --enable-sim-trace=opts              Enable tracing flags
688   --enable-sim-profile=opts            Enable profiling flags
689 
690+Optional Packages:
691+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
692+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
693+  --with-system-readline  use installed readline library
694+
695 Some influential environment variables:
696   CC          C compiler command
697   CFLAGS      C compiler flags
698@@ -4493,57 +4498,36 @@
699 done
700 
701 
702-# In the Cygwin environment, we need some additional flags.
703-echo "$as_me:$LINENO: checking for cygwin" >&5
704-echo $ECHO_N "checking for cygwin... $ECHO_C" >&6
705-if test "${sim_cv_os_cygwin+set}" = set; then
706-  echo $ECHO_N "(cached) $ECHO_C" >&6
707-else
708-  cat >conftest.$ac_ext <<_ACEOF
709-/* confdefs.h.  */
710-_ACEOF
711-cat confdefs.h >>conftest.$ac_ext
712-cat >>conftest.$ac_ext <<_ACEOF
713-/* end confdefs.h.  */
714 
715-#ifdef __CYGWIN__
716-lose
717-#endif
718-_ACEOF
719-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
720-  $EGREP "lose" >/dev/null 2>&1; then
721-  sim_cv_os_cygwin=yes
722-else
723-  sim_cv_os_cygwin=no
724-fi
725-rm -f conftest*
726+# Check whether --with-system-readline or --without-system-readline was given.
727+if test "${with_system_readline+set}" = set; then
728+  withval="$with_system_readline"
729 
730-fi
731-echo "$as_me:$LINENO: result: $sim_cv_os_cygwin" >&5
732-echo "${ECHO_T}$sim_cv_os_cygwin" >&6
733+fi;
734 
735-if test x$sim_cv_os_cygwin = xyes; then
736-  TERMCAP='`if test -r ../../libtermcap/libtermcap.a; then echo ../../libtermcap/libtermcap.a; else echo -ltermcap; fi` -luser32'
737-else
738-  echo "$as_me:$LINENO: checking for main in -ltermcap" >&5
739-echo $ECHO_N "checking for main in -ltermcap... $ECHO_C" >&6
740-if test "${ac_cv_lib_termcap_main+set}" = set; then
741-  echo $ECHO_N "(cached) $ECHO_C" >&6
742-else
743-  ac_check_lib_save_LIBS=$LIBS
744-LIBS="-ltermcap  $LIBS"
745-cat >conftest.$ac_ext <<_ACEOF
746+if test "$with_system_readline" = yes; then
747+  echo "$as_me:$LINENO: checking for readline" >&5
748+echo $ECHO_N "checking for readline... $ECHO_C" >&6
749+  save_LIBS="$LIBS"
750+  LIBS="-lreadline $save_LIBS"
751+  cat >conftest.$ac_ext <<_ACEOF
752 /* confdefs.h.  */
753 _ACEOF
754 cat confdefs.h >>conftest.$ac_ext
755 cat >>conftest.$ac_ext <<_ACEOF
756 /* end confdefs.h.  */
757 
758-
759+/* Override any gcc2 internal prototype to avoid an error.  */
760+#ifdef __cplusplus
761+extern "C"
762+#endif
763+/* We use char because int might match the return type of a gcc2
764+   builtin and then its argument prototype would still apply.  */
765+char add_history ();
766 int
767 main ()
768 {
769-main ();
770+add_history ();
771   ;
772   return 0;
773 }
774@@ -4570,41 +4554,13 @@
775   ac_status=$?
776   echo "$as_me:$LINENO: \$? = $ac_status" >&5
777   (exit $ac_status); }; }; then
778-  ac_cv_lib_termcap_main=yes
779+  READLINE=-lreadline
780 else
781   echo "$as_me: failed program was:" >&5
782 sed 's/^/| /' conftest.$ac_ext >&5
783 
784-ac_cv_lib_termcap_main=no
785-fi
786-rm -f conftest.err conftest.$ac_objext \
787-      conftest$ac_exeext conftest.$ac_ext
788-LIBS=$ac_check_lib_save_LIBS
789-fi
790-echo "$as_me:$LINENO: result: $ac_cv_lib_termcap_main" >&5
791-echo "${ECHO_T}$ac_cv_lib_termcap_main" >&6
792-if test $ac_cv_lib_termcap_main = yes; then
793-  TERMCAP=-ltermcap
794-else
795-  TERMCAP=""
796-fi
797-
798-fi
799-
800-
801-# We prefer the in-tree readline.  Top-level dependencies make sure
802-# src/readline (if it's there) is configured before src/sim.
803-if test -r ../../readline/Makefile; then
804-  READLINE=../../readline/libreadline.a
805-else
806-  echo "$as_me:$LINENO: checking for readline in -lreadline" >&5
807-echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6
808-if test "${ac_cv_lib_readline_readline+set}" = set; then
809-  echo $ECHO_N "(cached) $ECHO_C" >&6
810-else
811-  ac_check_lib_save_LIBS=$LIBS
812-LIBS="-lreadline $TERMCAP $LIBS"
813-cat >conftest.$ac_ext <<_ACEOF
814+ LIBS="-lreadline -lncurses $save_LIBS"
815+      cat >conftest.$ac_ext <<_ACEOF
816 /* confdefs.h.  */
817 _ACEOF
818 cat confdefs.h >>conftest.$ac_ext
819@@ -4617,11 +4573,11 @@
820 #endif
821 /* We use char because int might match the return type of a gcc2
822    builtin and then its argument prototype would still apply.  */
823-char readline ();
824+char add_history ();
825 int
826 main ()
827 {
828-readline ();
829+add_history ();
830   ;
831   return 0;
832 }
833@@ -4648,28 +4604,34 @@
834   ac_status=$?
835   echo "$as_me:$LINENO: \$? = $ac_status" >&5
836   (exit $ac_status); }; }; then
837-  ac_cv_lib_readline_readline=yes
838+  READLINE="-lreadline -lncurses"
839 else
840   echo "$as_me: failed program was:" >&5
841 sed 's/^/| /' conftest.$ac_ext >&5
842 
843-ac_cv_lib_readline_readline=no
844+{ { echo "$as_me:$LINENO: error: unable to detect readline" >&5
845+echo "$as_me: error: unable to detect readline" >&2;}
846+   { (exit 1); exit 1; }; }
847 fi
848 rm -f conftest.err conftest.$ac_objext \
849       conftest$ac_exeext conftest.$ac_ext
850-LIBS=$ac_check_lib_save_LIBS
851+
852 fi
853-echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5
854-echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6
855-if test $ac_cv_lib_readline_readline = yes; then
856-  READLINE=-lreadline
857-else
858-  { { echo "$as_me:$LINENO: error: the required \"readline\" library is missing" >&5
859-echo "$as_me: error: the required \"readline\" library is missing" >&2;}
860-   { (exit 1); exit 1; }; }
861+rm -f conftest.err conftest.$ac_objext \
862+      conftest$ac_exeext conftest.$ac_ext
863+  LIBS="$save_LIBS"
864+  echo "$as_me:$LINENO: result: $READLINE" >&5
865+echo "${ECHO_T}$READLINE" >&6
866+  READLINE_DEPS=
867+  READLINE_CFLAGS=
868+else
869+  READLINE='$(READLINE_DIR)/libreadline.a'
870+  READLINE_DEPS='$(READLINE)'
871+  READLINE_CFLAGS='-I$(READLINE_SRC)/..'
872 fi
873 
874-fi
875+
876+
877 
878 
879 ac_sources="$sim_link_files"
880@@ -5389,8 +5351,9 @@
881 s,@sim_stdio@,$sim_stdio,;t t
882 s,@sim_trace@,$sim_trace,;t t
883 s,@sim_profile@,$sim_profile,;t t
884-s,@TERMCAP@,$TERMCAP,;t t
885 s,@READLINE@,$READLINE,;t t
886+s,@READLINE_DEPS@,$READLINE_DEPS,;t t
887+s,@READLINE_CFLAGS@,$READLINE_CFLAGS,;t t
888 s,@cgen_breaks@,$cgen_breaks,;t t
889 s,@LIBOBJS@,$LIBOBJS,;t t
890 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
891diff -Naur gdb-6.8.orig/sim/erc32/configure.ac gdb-6.8-rtems4.10-20090312/sim/erc32/configure.ac
892--- gdb-6.8.orig/sim/erc32/configure.ac 2006-12-20 23:35:51.000000000 +0100
893+++ gdb-6.8-rtems4.10-20090312/sim/erc32/configure.ac   2009-03-12 04:56:03.000000000 +0100
894@@ -11,27 +11,32 @@
895 
896 AC_CHECK_HEADERS(stdlib.h)
897 
898-# In the Cygwin environment, we need some additional flags.
899-AC_CACHE_CHECK([for cygwin], sim_cv_os_cygwin,
900-[AC_EGREP_CPP(lose, [
901-#ifdef __CYGWIN__
902-lose
903-#endif],[sim_cv_os_cygwin=yes],[sim_cv_os_cygwin=no])])
904+AC_ARG_WITH([system-readline],
905+  [AS_HELP_STRING([--with-system-readline],
906+                  [use installed readline library])])
907 
908-if test x$sim_cv_os_cygwin = xyes; then
909-  TERMCAP='`if test -r ../../libtermcap/libtermcap.a; then echo ../../libtermcap/libtermcap.a; else echo -ltermcap; fi` -luser32'
910+if test "$with_system_readline" = yes; then
911+  AC_MSG_CHECKING([for readline])
912+  save_LIBS="$LIBS"
913+  LIBS="-lreadline $save_LIBS"
914+  AC_LINK_IFELSE([AC_LANG_CALL([],
915+    [add_history])], [READLINE=-lreadline],
916+    [ LIBS="-lreadline -lncurses $save_LIBS"
917+      AC_LINK_IFELSE([AC_LANG_CALL([],
918+        [add_history])], [READLINE="-lreadline -lncurses"],
919+        [AC_MSG_ERROR([unable to detect readline])])
920+    ])
921+  LIBS="$save_LIBS"
922+  AC_MSG_RESULT($READLINE)
923+  READLINE_DEPS=
924+  READLINE_CFLAGS=
925 else
926-  AC_CHECK_LIB(termcap, main, TERMCAP=-ltermcap, TERMCAP="")
927-fi
928-AC_SUBST(TERMCAP)
929-
930-# We prefer the in-tree readline.  Top-level dependencies make sure
931-# src/readline (if it's there) is configured before src/sim.
932-if test -r ../../readline/Makefile; then
933-  READLINE=../../readline/libreadline.a
934-else
935-  AC_CHECK_LIB(readline, readline, READLINE=-lreadline,
936-              AC_ERROR([the required "readline" library is missing]), $TERMCAP)
937+  READLINE='$(READLINE_DIR)/libreadline.a'
938+  READLINE_DEPS='$(READLINE)'
939+  READLINE_CFLAGS='-I$(READLINE_SRC)/..'
940 fi
941 AC_SUBST(READLINE)
942+AC_SUBST(READLINE_DEPS)
943+AC_SUBST(READLINE_CFLAGS)
944+
945 SIM_AC_OUTPUT
946diff -Naur gdb-6.8.orig/sim/erc32/erc32.c gdb-6.8-rtems4.10-20090312/sim/erc32/erc32.c
947--- gdb-6.8.orig/sim/erc32/erc32.c      1999-04-16 03:35:00.000000000 +0200
948+++ gdb-6.8-rtems4.10-20090312/sim/erc32/erc32.c        2009-03-12 04:56:03.000000000 +0100
949@@ -24,6 +24,7 @@
950 
951 #include <sys/types.h>
952 #include <stdio.h>
953+#include <string.h>
954 #include <termios.h>
955 #include <sys/fcntl.h>
956 #include <sys/file.h>
957@@ -413,7 +414,7 @@
958     if (rom8) mec_memcfg &= ~0x20000;
959     else mec_memcfg |= 0x20000;
960 
961-    mem_ramsz = (256 * 1024) << ((mec_memcfg >> 10) & 7);
962+    mem_ramsz = (512 * 1024) << ((mec_memcfg >> 10) & 7);
963     mem_romsz = (128 * 1024) << ((mec_memcfg >> 18) & 7);
964 
965     if (sparclite_board) {
966@@ -1659,7 +1660,7 @@
967        errmec = 0;
968        return(1);
969     }
970-#endif;
971+#endif
972 
973     if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
974        fetch_bytes (asi, &ramb[addr & mem_rammask], data, sz);
975@@ -1736,7 +1737,7 @@
976        errmec = 0;
977        return(1);
978     }
979-#endif;
980+#endif
981 
982     if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
983        if (mem_accprot) {
984diff -Naur gdb-6.8.orig/sim/erc32/exec.c gdb-6.8-rtems4.10-20090312/sim/erc32/exec.c
985--- gdb-6.8.orig/sim/erc32/exec.c       2005-03-07 12:09:05.000000000 +0100
986+++ gdb-6.8-rtems4.10-20090312/sim/erc32/exec.c 2009-03-12 04:56:03.000000000 +0100
987@@ -1713,7 +1713,7 @@
988            sregs->fdp[rs2 | 1] = sregs->fs[rs2 & ~1];
989            sregs->fdp[rs2 & ~1] = sregs->fs[rs2 | 1];
990     default:
991-      ;
992+      break;
993     }
994 #endif
995 
996@@ -1886,7 +1886,7 @@
997        sregs->fs[rd & ~1] = sregs->fdp[rd | 1];
998        sregs->fs[rd | 1] = sregs->fdp[rd & ~1];
999     default:
1000-      ;
1001+      break;
1002     }
1003 #endif
1004     if (sregs->fpstate == FP_EXC_PE) {
1005diff -Naur gdb-6.8.orig/sim/erc32/Makefile.in gdb-6.8-rtems4.10-20090312/sim/erc32/Makefile.in
1006--- gdb-6.8.orig/sim/erc32/Makefile.in  2008-01-01 23:53:24.000000000 +0100
1007+++ gdb-6.8-rtems4.10-20090312/sim/erc32/Makefile.in    2009-03-12 04:56:03.000000000 +0100
1008@@ -18,12 +18,12 @@
1009 
1010 ## COMMON_PRE_CONFIG_FRAG
1011 
1012-TERMCAP_LIB = @TERMCAP@
1013+# TERMCAP_LIB = -lncurses
1014 READLINE_LIB = @READLINE@
1015 
1016 SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o
1017 SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) -lm
1018-SIM_EXTRA_ALL = sis
1019+SIM_EXTRA_ALL = sis$(EXEEXT)
1020 SIM_EXTRA_INSTALL = install-sis
1021 SIM_EXTRA_CLEAN = clean-sis
1022 
1023@@ -37,8 +37,8 @@
1024 # `sis' doesn't need interf.o.
1025 SIS_OFILES = exec.o erc32.o func.o help.o float.o
1026 
1027-sis: sis.o $(SIS_OFILES) $(COMMON_OBJS) $(LIBDEPS)
1028-       $(CC) $(ALL_CFLAGS) -o sis \
1029+sis$(EXEEXT): sis.o $(SIS_OFILES) $(COMMON_OBJS) $(LIBDEPS)
1030+       $(CC) $(ALL_CFLAGS) -o sis$(EXEEXT) \
1031          sis.o $(SIS_OFILES) $(COMMON_OBJS) $(EXTRA_LIBS)
1032 
1033 # FIXME: This computes the build host's endianness, doesn't it?
1034@@ -51,11 +51,11 @@
1035 
1036 # Copy the files into directories where they will be run.
1037 install-sis: installdirs
1038-       n=`echo sis | sed '$(program_transform_name)'`; \
1039-       $(INSTALL_PROGRAM) sis$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
1040+       n=`echo sis$(EXEEXT) | sed '$(program_transform_name)'`; \
1041+       $(INSTALL_PROGRAM) sis$(EXEEXT) $(DESTDIR)$(bindir)/$$n
1042 
1043 clean-sis:
1044-       rm -f sis end end.h
1045+       rm -f sis$(EXEEXT) end end.h
1046 
1047 configure:
1048        @echo "Rebuilding configure..."
1049diff -Naur gdb-6.8.orig/sim/h8300/compile.c gdb-6.8-rtems4.10-20090312/sim/h8300/compile.c
1050--- gdb-6.8.orig/sim/h8300/compile.c    2007-07-03 19:19:38.000000000 +0200
1051+++ gdb-6.8-rtems4.10-20090312/sim/h8300/compile.c      2009-03-12 04:56:03.000000000 +0100
1052@@ -38,6 +38,12 @@
1053 # define SIGTRAP 5
1054 #endif
1055 
1056+#ifdef _WIN32
1057+#ifndef SIGBUS
1058+#define SIGBUS 10
1059+#endif
1060+#endif
1061+
1062 int debug;
1063 
1064 host_callback *sim_callback;
1065@@ -599,7 +605,7 @@
1066   /* Find the exact opcode/arg combo.  */
1067   for (q = h8_opcodes; q->name; q++)
1068     {
1069-      op_type *nib = q->data.nib;
1070+      const op_type *nib = q->data.nib;
1071       unsigned int len = 0;
1072 
1073       if ((q->available == AV_H8SX && !h8300sxmode) ||
1074@@ -924,7 +930,7 @@
1075 #endif
1076                  /* Fill in the args.  */
1077                  {
1078-                   op_type *args = q->args.nib;
1079+                   const op_type *args = q->args.nib;
1080                    int hadone = 0;
1081                    int nargs;
1082 
1083diff -Naur gdb-6.8.orig/sim/m32c/gdb-if.c gdb-6.8-rtems4.10-20090312/sim/m32c/gdb-if.c
1084--- gdb-6.8.orig/sim/m32c/gdb-if.c      2008-01-01 23:53:25.000000000 +0100
1085+++ gdb-6.8-rtems4.10-20090312/sim/m32c/gdb-if.c        2009-03-12 04:56:03.000000000 +0100
1086@@ -534,8 +534,12 @@
1087 #endif
1088 
1089     case 5:
1090+#ifdef SIGTRAP
1091       return SIGTRAP;
1092-
1093+#else
1094+      return SIGSEGV;
1095+#endif
1096+   
1097     case 10:
1098 #ifdef SIGBUS
1099       return SIGBUS;
1100diff -Naur gdb-6.8.orig/sim/m32c/Makefile.in gdb-6.8-rtems4.10-20090312/sim/m32c/Makefile.in
1101--- gdb-6.8.orig/sim/m32c/Makefile.in   2008-01-01 23:53:24.000000000 +0100
1102+++ gdb-6.8-rtems4.10-20090312/sim/m32c/Makefile.in     2009-03-12 04:56:03.000000000 +0100
1103@@ -55,7 +55,7 @@
1104        ./opc2c -l m32c.out $(srcdir)/m32c.opc > m32c.c
1105 
1106 opc2c : opc2c.o safe-fgets.o
1107-       $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
1108+       $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $^ -o $@
1109 
1110 sample.x : $(srcdir)/sample.S $(srcdir)/sample.ld
1111        ../../gcc/xgcc $(CPUFLAGS) -B../../gcc/ -c $(srcdir)/sample.S -o sample.o
1112@@ -83,8 +83,10 @@
1113 mem.o : mem.h cpu.h syscalls.h
1114 misc.o : cpu.h misc.h
1115 opc2c.o : safe-fgets.h
1116+       $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ -c $(srcdir)/opc2c.c
1117 reg.o : cpu.h
1118 safe-fgets.o : safe-fgets.h
1119+       $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ -c $(srcdir)/safe-fgets.c
1120 srcdest.c : cpu.h mem.h
1121 syscalls.c : cpu.h mem.h syscalls.h
1122 
1123diff -Naur gdb-6.8.orig/sim/ppc/configure gdb-6.8-rtems4.10-20090312/sim/ppc/configure
1124--- gdb-6.8.orig/sim/ppc/configure      2008-03-14 22:35:27.000000000 +0100
1125+++ gdb-6.8-rtems4.10-20090312/sim/ppc/configure        2009-03-12 04:56:37.000000000 +0100
1126@@ -2709,10 +2709,263 @@
1127 
1128 fi;
1129 
1130+echo "$as_me:$LINENO: checking if union semun defined" >&5
1131+echo $ECHO_N "checking if union semun defined... $ECHO_C" >&6
1132+if test "${ac_cv_HAS_UNION_SEMUN+set}" = set; then
1133+  echo $ECHO_N "(cached) $ECHO_C" >&6
1134+else
1135+  cat >conftest.$ac_ext <<_ACEOF
1136+/* confdefs.h.  */
1137+_ACEOF
1138+cat confdefs.h >>conftest.$ac_ext
1139+cat >>conftest.$ac_ext <<_ACEOF
1140+/* end confdefs.h.  */
1141+
1142+#include <sys/types.h>
1143+#include <sys/ipc.h>
1144+#include <sys/sem.h>
1145+int
1146+main ()
1147+{
1148+union semun arg ;
1149+  ;
1150+  return 0;
1151+}
1152+_ACEOF
1153+rm -f conftest.$ac_objext
1154+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
1155+  (eval $ac_compile) 2>conftest.er1
1156+  ac_status=$?
1157+  grep -v '^ *+' conftest.er1 >conftest.err
1158+  rm -f conftest.er1
1159+  cat conftest.err >&5
1160+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1161+  (exit $ac_status); } &&
1162+        { ac_try='test -z "$ac_c_werror_flag"
1163+                        || test ! -s conftest.err'
1164+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1165+  (eval $ac_try) 2>&5
1166+  ac_status=$?
1167+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1168+  (exit $ac_status); }; } &&
1169+        { ac_try='test -s conftest.$ac_objext'
1170+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1171+  (eval $ac_try) 2>&5
1172+  ac_status=$?
1173+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1174+  (exit $ac_status); }; }; then
1175+  ac_cv_has_union_semun="yes"
1176+else
1177+  echo "$as_me: failed program was:" >&5
1178+sed 's/^/| /' conftest.$ac_ext >&5
1179+
1180+ac_cv_has_union_semun="no"
1181+fi
1182+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
1183+echo "$as_me:$LINENO: result: $ac_cv_has_union_semun" >&5
1184+echo "${ECHO_T}$ac_cv_has_union_semun" >&6
1185+
1186+fi
1187+echo "$as_me:$LINENO: result: $ac_cv_HAS_UNION_SEMUN" >&5
1188+echo "${ECHO_T}$ac_cv_HAS_UNION_SEMUN" >&6
1189+
1190+
1191+if test "$ac_cv_has_union_semun" = "yes"; then
1192+  echo "$as_me:$LINENO: checking whether System V semaphores are supported" >&5
1193+echo $ECHO_N "checking whether System V semaphores are supported... $ECHO_C" >&6
1194+if test "${ac_cv_sysv_sem+set}" = set; then
1195+  echo $ECHO_N "(cached) $ECHO_C" >&6
1196+else
1197+
1198+  if test "$cross_compiling" = yes; then
1199+  :
1200+else
1201+  cat >conftest.$ac_ext <<_ACEOF
1202+/* confdefs.h.  */
1203+_ACEOF
1204+cat confdefs.h >>conftest.$ac_ext
1205+cat >>conftest.$ac_ext <<_ACEOF
1206+/* end confdefs.h.  */
1207+
1208+  #include <sys/types.h>
1209+  #include <sys/ipc.h>
1210+  #include <sys/sem.h>
1211+  int main () {
1212+    union semun arg ;
1213+
1214+    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
1215+    if (id == -1)
1216+      exit(1);
1217+    arg.val = 0; /* avoid implicit type cast to union */
1218+    if (semctl(id, 0, IPC_RMID, arg) == -1)
1219+      exit(1);
1220+    exit(0);
1221+  }
1222+
1223+_ACEOF
1224+rm -f conftest$ac_exeext
1225+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
1226+  (eval $ac_link) 2>&5
1227+  ac_status=$?
1228+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1229+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
1230+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1231+  (eval $ac_try) 2>&5
1232+  ac_status=$?
1233+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1234+  (exit $ac_status); }; }; then
1235+  ac_cv_sysv_sem="yes"
1236+else
1237+  echo "$as_me: program exited with status $ac_status" >&5
1238+echo "$as_me: failed program was:" >&5
1239+sed 's/^/| /' conftest.$ac_ext >&5
1240+
1241+( exit $ac_status )
1242+ac_cv_sysv_sem="no"
1243+fi
1244+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
1245+fi
1246+
1247+fi
1248+echo "$as_me:$LINENO: result: $ac_cv_sysv_sem" >&5
1249+echo "${ECHO_T}$ac_cv_sysv_sem" >&6
1250+else  # semun is not defined
1251+  echo "$as_me:$LINENO: checking whether System V semaphores are supported" >&5
1252+echo $ECHO_N "checking whether System V semaphores are supported... $ECHO_C" >&6
1253+if test "${ac_cv_sysv_sem+set}" = set; then
1254+  echo $ECHO_N "(cached) $ECHO_C" >&6
1255+else
1256+
1257+  if test "$cross_compiling" = yes; then
1258+  :
1259+else
1260+  cat >conftest.$ac_ext <<_ACEOF
1261+/* confdefs.h.  */
1262+_ACEOF
1263+cat confdefs.h >>conftest.$ac_ext
1264+cat >>conftest.$ac_ext <<_ACEOF
1265+/* end confdefs.h.  */
1266+
1267+  #include <sys/types.h>
1268+  #include <sys/ipc.h>
1269+  #include <sys/sem.h>
1270+  union semun {
1271+    int val;
1272+    struct semid_ds *buf;
1273+    ushort *array;
1274+  };
1275+  int main () {
1276+    union semun arg ;
1277+
1278+    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
1279+    if (id == -1)
1280+      exit(1);
1281+    arg.val = 0; /* avoid implicit type cast to union */
1282+    if (semctl(id, 0, IPC_RMID, arg) == -1)
1283+      exit(1);
1284+    exit(0);
1285+  }
1286+
1287+_ACEOF
1288+rm -f conftest$ac_exeext
1289+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
1290+  (eval $ac_link) 2>&5
1291+  ac_status=$?
1292+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1293+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
1294+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1295+  (eval $ac_try) 2>&5
1296+  ac_status=$?
1297+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1298+  (exit $ac_status); }; }; then
1299+  ac_cv_sysv_sem="yes"
1300+else
1301+  echo "$as_me: program exited with status $ac_status" >&5
1302+echo "$as_me: failed program was:" >&5
1303+sed 's/^/| /' conftest.$ac_ext >&5
1304+
1305+( exit $ac_status )
1306+ac_cv_sysv_sem="no"
1307+fi
1308+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
1309+fi
1310+
1311+fi
1312+echo "$as_me:$LINENO: result: $ac_cv_sysv_sem" >&5
1313+echo "${ECHO_T}$ac_cv_sysv_sem" >&6
1314+fi
1315+
1316+echo "$as_me:$LINENO: checking whether System V shared memory is supported" >&5
1317+echo $ECHO_N "checking whether System V shared memory is supported... $ECHO_C" >&6
1318+if test "${ac_cv_sysv_shm+set}" = set; then
1319+  echo $ECHO_N "(cached) $ECHO_C" >&6
1320+else
1321+
1322+if test "$cross_compiling" = yes; then
1323+  :
1324+else
1325+  cat >conftest.$ac_ext <<_ACEOF
1326+/* confdefs.h.  */
1327+_ACEOF
1328+cat confdefs.h >>conftest.$ac_ext
1329+cat >>conftest.$ac_ext <<_ACEOF
1330+/* end confdefs.h.  */
1331+
1332+#include <sys/types.h>
1333+#include <sys/ipc.h>
1334+#include <sys/shm.h>
1335+int main () {
1336+  int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400);
1337+  if (id == -1)
1338+    exit(1);
1339+  if (shmctl(id, IPC_RMID, 0) == -1)
1340+    exit(1);
1341+  exit(0);
1342+}
1343+
1344+_ACEOF
1345+rm -f conftest$ac_exeext
1346+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
1347+  (eval $ac_link) 2>&5
1348+  ac_status=$?
1349+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1350+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
1351+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1352+  (eval $ac_try) 2>&5
1353+  ac_status=$?
1354+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
1355+  (exit $ac_status); }; }; then
1356+  ac_cv_sysv_shm="yes"
1357+else
1358+  echo "$as_me: program exited with status $ac_status" >&5
1359+echo "$as_me: failed program was:" >&5
1360+sed 's/^/| /' conftest.$ac_ext >&5
1361+
1362+( exit $ac_status )
1363+ac_cv_sysv_shm="no"
1364+fi
1365+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
1366+fi
1367+
1368+fi
1369+echo "$as_me:$LINENO: result: $ac_cv_sysv_shm" >&5
1370+echo "${ECHO_T}$ac_cv_sysv_shm" >&6
1371+
1372+if test x"$ac_cv_sysv_shm" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
1373+  sim_sysv_ipc_hw=",sem,shm";
1374+else
1375+  sim_sysv_ipc_hw="";
1376+fi
1377+
1378+if test x"$ac_cv_has_union_semun" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
1379+  sim_hwflags="-DHAS_UNION_SEMUN";
1380+fi
1381+
1382+
1383 # Check whether --enable-sim-hardware or --disable-sim-hardware was given.
1384 if test "${enable_sim_hardware+set}" = set; then
1385   enableval="$enable_sim_hardware"
1386-  hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
1387+  hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
1388 case "${enableval}" in
1389   yes) ;;
1390   no)  { { echo "$as_me:$LINENO: error: \"List of hardware must be specified for --enable-sim-hardware\"" >&5
1391@@ -2728,14 +2981,13 @@
1392   echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
1393 fi
1394 else
1395-  hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
1396+  hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
1397 sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
1398 sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
1399 if test x"$silent" != x"yes"; then
1400   echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
1401 fi
1402 fi;
1403-
1404 # Check whether --enable-sim-hostbitsize or --disable-sim-hostbitsize was given.
1405 if test "${enable_sim_hostbitsize+set}" = set; then
1406   enableval="$enable_sim_hostbitsize"
1407@@ -2752,7 +3004,6 @@
1408   sim_hostbitsize=""
1409 fi;
1410 
1411-
1412 # Check whether --enable-sim-hostendian or --disable-sim-hostendian was given.
1413 if test "${enable_sim_hostendian+set}" = set; then
1414   enableval="$enable_sim_hostendian"
1415diff -Naur gdb-6.8.orig/sim/ppc/configure.ac gdb-6.8-rtems4.10-20090312/sim/ppc/configure.ac
1416--- gdb-6.8.orig/sim/ppc/configure.ac   2008-03-14 22:35:27.000000000 +0100
1417+++ gdb-6.8-rtems4.10-20090312/sim/ppc/configure.ac     2009-03-12 04:56:03.000000000 +0100
1418@@ -209,10 +209,105 @@
1419 esac
1420 ])dnl
1421 
1422+AC_CACHE_CHECK([if union semun defined],
1423+  ac_cv_HAS_UNION_SEMUN,
1424+  [AC_TRY_COMPILE([
1425+#include <sys/types.h>
1426+#include <sys/ipc.h>
1427+#include <sys/sem.h>],
1428+[union semun arg ;],
1429+[ac_cv_has_union_semun="yes"],
1430+[ac_cv_has_union_semun="no"])
1431+AC_MSG_RESULT($ac_cv_has_union_semun)
1432+])
1433+
1434+
1435+if test "$ac_cv_has_union_semun" = "yes"; then
1436+  AC_CACHE_CHECK(whether System V semaphores are supported,
1437+  ac_cv_sysv_sem,
1438+  [
1439+  AC_TRY_RUN(
1440+  [
1441+  #include <sys/types.h>
1442+  #include <sys/ipc.h>
1443+  #include <sys/sem.h>
1444+  int main () {
1445+    union semun arg ;
1446+
1447+    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
1448+    if (id == -1)
1449+      exit(1);
1450+    arg.val = 0; /* avoid implicit type cast to union */
1451+    if (semctl(id, 0, IPC_RMID, arg) == -1)
1452+      exit(1);
1453+    exit(0);
1454+  }
1455+  ],
1456+  ac_cv_sysv_sem="yes", ac_cv_sysv_sem="no", :)
1457+  ])
1458+else  # semun is not defined
1459+  AC_CACHE_CHECK(whether System V semaphores are supported,
1460+  ac_cv_sysv_sem,
1461+  [
1462+  AC_TRY_RUN(
1463+  [
1464+  #include <sys/types.h>
1465+  #include <sys/ipc.h>
1466+  #include <sys/sem.h>
1467+  union semun {
1468+    int val;
1469+    struct semid_ds *buf;
1470+    ushort *array;
1471+  };
1472+  int main () {
1473+    union semun arg ;
1474+
1475+    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
1476+    if (id == -1)
1477+      exit(1);
1478+    arg.val = 0; /* avoid implicit type cast to union */
1479+    if (semctl(id, 0, IPC_RMID, arg) == -1)
1480+      exit(1);
1481+    exit(0);
1482+  }
1483+  ],
1484+  ac_cv_sysv_sem="yes", ac_cv_sysv_sem="no", :)
1485+  ])
1486+fi
1487+
1488+AC_CACHE_CHECK(whether System V shared memory is supported,
1489+ac_cv_sysv_shm,
1490+[
1491+AC_TRY_RUN([
1492+#include <sys/types.h>
1493+#include <sys/ipc.h>
1494+#include <sys/shm.h>
1495+int main () {
1496+  int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400);
1497+  if (id == -1)
1498+    exit(1);
1499+  if (shmctl(id, IPC_RMID, 0) == -1)
1500+    exit(1);
1501+  exit(0);
1502+}
1503+],
1504+ac_cv_sysv_shm="yes", ac_cv_sysv_shm="no", :)
1505+])
1506+
1507+if test x"$ac_cv_sysv_shm" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
1508+  sim_sysv_ipc_hw=",sem,shm";
1509+else
1510+  sim_sysv_ipc_hw="";
1511+fi
1512+
1513+if test x"$ac_cv_has_union_semun" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
1514+  sim_hwflags="-DHAS_UNION_SEMUN";
1515+fi
1516+
1517 
1518 AC_ARG_ENABLE(sim-hardware,
1519 [  --enable-sim-hardware=list          Specify the hardware to be included in the build.],
1520-[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
1521+[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
1522 case "${enableval}" in
1523   yes) ;;
1524   no)  AC_MSG_ERROR("List of hardware must be specified for --enable-sim-hardware"); hardware="";;
1525@@ -224,14 +319,13 @@
1526 sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
1527 if test x"$silent" != x"yes" && test x"$hardware" != x""; then
1528   echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
1529-fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
1530+fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
1531 sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
1532 sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
1533 if test x"$silent" != x"yes"; then
1534   echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
1535 fi])dnl
1536 
1537-
1538 AC_ARG_ENABLE(sim-hostbitsize,
1539 [  --enable-sim-hostbitsize=32|64      Specify host bitsize (32 or 64).],
1540 [case "${enableval}" in
1541diff -Naur gdb-6.8.orig/sim/ppc/debug.c gdb-6.8-rtems4.10-20090312/sim/ppc/debug.c
1542--- gdb-6.8.orig/sim/ppc/debug.c        1999-04-16 03:35:08.000000000 +0200
1543+++ gdb-6.8-rtems4.10-20090312/sim/ppc/debug.c  2009-03-12 04:56:03.000000000 +0100
1544@@ -70,6 +70,8 @@
1545   { trace_pass_device, "pass-device" },
1546   { trace_phb_device, "phb-device" },
1547   { trace_register_device, "register-device", "Device initializing registers" },
1548+  { trace_sem_device, "sem-device" },
1549+  { trace_shm_device, "shm-device" },
1550   { trace_stack_device, "stack-device" },
1551   { trace_vm_device, "vm-device" },
1552   /* packages */
1553diff -Naur gdb-6.8.orig/sim/ppc/debug.h gdb-6.8-rtems4.10-20090312/sim/ppc/debug.h
1554--- gdb-6.8.orig/sim/ppc/debug.h        1999-04-16 03:35:08.000000000 +0200
1555+++ gdb-6.8-rtems4.10-20090312/sim/ppc/debug.h  2009-03-12 04:56:03.000000000 +0100
1556@@ -51,6 +51,8 @@
1557   trace_pal_device,
1558   trace_pass_device,
1559   trace_phb_device,
1560+  trace_sem_device,
1561+  trace_shm_device,
1562   trace_stack_device,
1563   trace_register_device,
1564   trace_vm_device,
1565diff -Naur gdb-6.8.orig/sim/ppc/hw_sem.c gdb-6.8-rtems4.10-20090312/sim/ppc/hw_sem.c
1566--- gdb-6.8.orig/sim/ppc/hw_sem.c       1970-01-01 01:00:00.000000000 +0100
1567+++ gdb-6.8-rtems4.10-20090312/sim/ppc/hw_sem.c 2009-03-12 04:56:03.000000000 +0100
1568@@ -0,0 +1,301 @@
1569+/*  This file is part of the program psim.
1570+
1571+    Copyright (C) 1997,2008, Joel Sherrill <joel@OARcorp.com>
1572+
1573+    This program is free software; you can redistribute it and/or modify
1574+    it under the terms of the GNU General Public License as published by
1575+    the Free Software Foundation; either version 2 of the License, or
1576+    (at your option) any later version.
1577+
1578+    This program is distributed in the hope that it will be useful,
1579+    but WITHOUT ANY WARRANTY; without even the implied warranty of
1580+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1581+    GNU General Public License for more details.
1582+
1583+    You should have received a copy of the GNU General Public License
1584+    along with this program; if not, write to the Free Software
1585+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1586+
1587+    */
1588+
1589+
1590+#ifndef _HW_SEM_C_
1591+#define _HW_SEM_C_
1592+
1593+#include "device_table.h"
1594+
1595+#ifdef HAVE_STRING_H
1596+#include <string.h>
1597+#else
1598+#ifdef HAVE_STRINGS_H
1599+#include <strings.h>
1600+#endif
1601+#endif
1602+
1603+#include <sys/ipc.h>
1604+#include <sys/sem.h>
1605+
1606+#include <errno.h>
1607+
1608+/* DEVICE
1609+
1610+
1611+   sem - provide access to a unix semaphore
1612+
1613+
1614+   DESCRIPTION
1615+
1616+
1617+   This device implements an interface to a unix semaphore.
1618+
1619+
1620+   PROPERTIES
1621+
1622+
1623+   reg = <address> <size> (required)
1624+
1625+   Determine where the memory lives in the parents address space.
1626+
1627+   key = <integer> (required)
1628+
1629+   This is the key of the unix semaphore.
1630+
1631+   EXAMPLES
1632+
1633+
1634+   Enable tracing of the sem:
1635+
1636+   |  bash$ psim -t sem-device \
1637+
1638+
1639+   Configure a UNIX semaphore using key 0x12345678 mapped into psim
1640+   address space at 0xfff00000:
1641+
1642+   |  -o '/sem@0xfff00000/reg 0xfff00000 0x80000' \
1643+   |  -o '/sem@0xfff00000/key 0x12345678' \
1644+
1645+   sim/ppc/run -o '/#address-cells 1' \
1646+         -o '/sem@0xc0000000/reg 0xc0000000 0x80000' \
1647+         -o '/sem@0xc0000000/key 0x12345678' ../psim-hello/hello
1648+
1649+   REGISTERS
1650+
1651+   offset 0 - lock count
1652+   offset 4 - lock operation
1653+   offset 8 - unlock operation
1654+
1655+   All reads return the current or resulting count.
1656+
1657+   BUGS
1658+
1659+   None known.
1660+
1661+   */
1662+
1663+typedef struct _hw_sem_device {
1664+  unsigned_word  physical_address;
1665+  key_t          key;
1666+  int            id;
1667+  int            initial;
1668+  int            count;
1669+} hw_sem_device;
1670+
1671+static void
1672+hw_sem_init_data(device *me)
1673+{
1674+  hw_sem_device *sem = (hw_sem_device*)device_data(me);
1675+  const device_unit *d;
1676+  int status;
1677+#if !HAS_UNION_SEMUN
1678+        union semun {
1679+          int val;
1680+          struct semid_ds *buf;
1681+          unsigned short int *array;
1682+#if defined(__linux__)
1683+          struct seminfo *__buf;
1684+#endif
1685+        } ;
1686+#endif
1687+  union semun help;
1688+
1689+  /* initialize the properties of the sem */
1690+
1691+  if (device_find_property(me, "key") == NULL)
1692+    error("sem_init_data() required key property is missing\n");
1693+
1694+  if (device_find_property(me, "value") == NULL)
1695+    error("sem_init_data() required value property is missing\n");
1696+
1697+  sem->key = (key_t) device_find_integer_property(me, "key");
1698+  DTRACE(sem, ("semaphore key (%d)\n", sem->key) );
1699+
1700+  sem->initial = (int) device_find_integer_property(me, "value");
1701+  DTRACE(sem, ("semaphore initial value (%d)\n", sem->initial) );
1702+
1703+  d = device_unit_address(me);
1704+  sem->physical_address = d->cells[ d->nr_cells-1 ];
1705+  DTRACE(sem, ("semaphore physical_address=0x%x\n", sem->physical_address));
1706+
1707+  /* Now to initialize the semaphore */
1708+
1709+  if ( sem->initial != -1 ) {
1710+
1711+    sem->id = semget(sem->key, 1, IPC_CREAT | 0660);
1712+    if (sem->id == -1)
1713+      error("hw_sem_init_data() semget failed\n");
1714+
1715+    help.val = sem->initial;
1716+    status = semctl( sem->id, 0, SETVAL, help );
1717+    if (status == -1)
1718+      error("hw_sem_init_data() semctl -- set value failed\n");
1719+
1720+  } else {
1721+    sem->id = semget(sem->key, 1, 0660);
1722+    if (sem->id == -1)
1723+      error("hw_sem_init_data() semget failed\n");
1724+  }
1725+
1726+  sem->count = semctl( sem->id, 0, GETVAL, help );
1727+  if (sem->count == -1)
1728+    error("hw_sem_init_data() semctl -- get value failed\n");
1729+  DTRACE(sem, ("semaphore OS value (%d)\n", sem->count) );
1730+
1731+  if (sizeof(int) != 4)
1732+    error("hw_sem_init_data() typing problem\n");
1733+}
1734+
1735+static void
1736+hw_sem_attach_address_callback(device *me,
1737+                               attach_type attach,
1738+                               int space,
1739+                               unsigned_word addr,
1740+                               unsigned nr_bytes,
1741+                               access_type access,
1742+                               device *client) /*callback/default*/
1743+{
1744+  hw_sem_device *sem = (hw_sem_device*)device_data(me);
1745+
1746+  if (space != 0)
1747+    error("sem_attach_address_callback() invalid address space\n");
1748+
1749+  if (nr_bytes == 12)
1750+    error("sem_attach_address_callback() invalid size\n");
1751+
1752+  sem->physical_address = addr;
1753+  DTRACE(sem, ("semaphore physical_address=0x%x\n", addr));
1754+}
1755+
1756+static unsigned
1757+hw_sem_io_read_buffer(device *me,
1758+                        void *dest,
1759+                        int space,
1760+                        unsigned_word addr,
1761+                        unsigned nr_bytes,
1762+                        cpu *processor,
1763+                        unsigned_word cia)
1764+{
1765+  hw_sem_device *sem = (hw_sem_device*)device_data(me);
1766+  struct sembuf sb;
1767+  int status;
1768+  unsigned32 u32;
1769+#if !HAS_UNION_SEMUN
1770+        union semun {
1771+          int val;
1772+          struct semid_ds *buf;
1773+          unsigned short int *array;
1774+#if defined(__linux__)
1775+          struct seminfo *__buf;
1776+#endif
1777+        } ;
1778+#endif
1779+  union semun help;
1780+
1781+  /* do we need to worry about out of range addresses? */
1782+
1783+  DTRACE(sem, ("semaphore read addr=0x%x length=%d\n", addr, nr_bytes));
1784+
1785+  if (!(addr >= sem->physical_address && addr <= sem->physical_address + 11))
1786+    error("hw_sem_io_read_buffer() invalid address - out of range\n");
1787+
1788+  if ((addr % 4) != 0)
1789+    error("hw_sem_io_read_buffer() invalid address - alignment\n");
1790+
1791+  if (nr_bytes != 4)
1792+    error("hw_sem_io_read_buffer() invalid length\n");
1793+
1794+  switch ( (addr - sem->physical_address) / 4 ) {
1795+
1796+    case 0:  /* OBTAIN CURRENT VALUE */
1797+      break;
1798+
1799+    case 1:  /* LOCK */
1800+      sb.sem_num = 0;
1801+      sb.sem_op  = -1;
1802+      sb.sem_flg = 0;
1803+
1804+      status = semop(sem->id, &sb, 1);
1805+      if (status == -1) {
1806+        perror( "hw_sem.c: lock" );
1807+        error("hw_sem_io_read_buffer() sem lock\n");
1808+      }
1809+
1810+      DTRACE(sem, ("semaphore lock %d\n", sem->count));
1811+      break;
1812+
1813+    case 2: /* UNLOCK */
1814+      sb.sem_num = 0;
1815+      sb.sem_op  = 1;
1816+      sb.sem_flg = 0;
1817+
1818+      status = semop(sem->id, &sb, 1);
1819+      if (status == -1) {
1820+        perror( "hw_sem.c: unlock" );
1821+        error("hw_sem_io_read_buffer() sem unlock\n");
1822+      }
1823+      DTRACE(sem, ("semaphore unlock %d\n", sem->count));
1824+      break;
1825+
1826+    default:
1827+      error("hw_sem_io_read_buffer() invalid address - unknown error\n");
1828+      break;
1829+  }
1830+
1831+  /* assume target is big endian */
1832+  u32 = H2T_4(semctl( sem->id, 0, GETVAL, help ));
1833+
1834+  DTRACE(sem, ("semaphore OS value (%d)\n", u32) );
1835+  if (u32 == 0xffffffff) {
1836+    perror( "hw_sem.c: getval" );
1837+    error("hw_sem_io_read_buffer() semctl -- get value failed\n");
1838+  }
1839+
1840+  memcpy(dest, &u32, nr_bytes);
1841+  return nr_bytes;
1842+
1843+}
1844+
1845+static device_callbacks const hw_sem_callbacks = {
1846+  { generic_device_init_address, hw_sem_init_data },
1847+  { hw_sem_attach_address_callback, }, /* address */
1848+  { hw_sem_io_read_buffer, NULL }, /* IO */
1849+  { NULL, }, /* DMA */
1850+  { NULL, }, /* interrupt */
1851+  { NULL, }, /* unit */
1852+  NULL,
1853+};
1854+
1855+static void *
1856+hw_sem_create(const char *name,
1857+                const device_unit *unit_address,
1858+                const char *args)
1859+{
1860+  hw_sem_device *sem = ZALLOC(hw_sem_device);
1861+  return sem;
1862+}
1863+
1864+const device_descriptor hw_sem_device_descriptor[] = {
1865+  { "sem", hw_sem_create, &hw_sem_callbacks },
1866+  { NULL },
1867+};
1868+
1869+#endif /* _HW_SEM_C_ */
1870diff -Naur gdb-6.8.orig/sim/ppc/hw_shm.c gdb-6.8-rtems4.10-20090312/sim/ppc/hw_shm.c
1871--- gdb-6.8.orig/sim/ppc/hw_shm.c       1970-01-01 01:00:00.000000000 +0100
1872+++ gdb-6.8-rtems4.10-20090312/sim/ppc/hw_shm.c 2009-03-12 04:56:03.000000000 +0100
1873@@ -0,0 +1,236 @@
1874+/*  This file is part of the program psim.
1875+
1876+    Copyright (C) 1997,2008, Joel Sherrill <joel@OARcorp.com>
1877+
1878+    This program is free software; you can redistribute it and/or modify
1879+    it under the terms of the GNU General Public License as published by
1880+    the Free Software Foundation; either version 2 of the License, or
1881+    (at your option) any later version.
1882+
1883+    This program is distributed in the hope that it will be useful,
1884+    but WITHOUT ANY WARRANTY; without even the implied warranty of
1885+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1886+    GNU General Public License for more details.
1887+
1888+    You should have received a copy of the GNU General Public License
1889+    along with this program; if not, write to the Free Software
1890+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1891+
1892+    */
1893+
1894+
1895+#ifndef _HW_SHM_C_
1896+#define _HW_SHM_C_
1897+
1898+#include "device_table.h"
1899+
1900+#ifdef HAVE_STRING_H
1901+#include <string.h>
1902+#else
1903+#ifdef HAVE_STRINGS_H
1904+#include <strings.h>
1905+#endif
1906+#endif
1907+
1908+#include <sys/ipc.h>
1909+#include <sys/shm.h>
1910+
1911+
1912+/* DEVICE
1913+
1914+
1915+   shm - map unix shared memory into psim address space
1916+
1917+
1918+   DESCRIPTION
1919+
1920+
1921+   This device implements an area of memory which is mapped into UNIX
1922+   shared memory.
1923+
1924+
1925+   PROPERTIES
1926+
1927+
1928+   reg = <address> <size> (required)
1929+
1930+   Determine where the memory lives in the parents address space.
1931+   The SHM area is assumed to be of the same length.
1932+
1933+   key = <integer> (required)
1934+
1935+   This is the key of the unix shared memory area.
1936+
1937+   EXAMPLES
1938+
1939+
1940+   Enable tracing of the shm:
1941+
1942+   |  bash$ psim -t shm-device \
1943+
1944+
1945+   Configure a 512 kilobytes of UNIX shared memory with the key 0x12345678
1946+   mapped into psim address space at 0x0c000000.
1947+
1948+   |  -o '/shm@0x0c000000/reg 0x0c000000 0x80000' \
1949+   |  -o '/shm@0x0c000000/key 0x12345678' \
1950+
1951+   sim/ppc/run -o '/#address-cells 1' \
1952+         -o '/shm@0x0c000000/reg 0x0c000000 0x80000' \
1953+         -o '/shm@0x0c000000/key 0x12345678' ../psim-hello/hello
1954+
1955+   BUGS
1956+
1957+   None known.
1958+
1959+   */
1960+
1961+typedef struct _hw_shm_device {
1962+  unsigned_word  physical_address;
1963+  char          *shm_address;
1964+  unsigned       sizeof_memory;
1965+  key_t          key;
1966+  int            id;
1967+} hw_shm_device;
1968+
1969+static void
1970+hw_shm_init_data(device *me)
1971+{
1972+  hw_shm_device *shm = (hw_shm_device*)device_data(me);
1973+  const device_unit *d;
1974+  reg_property_spec reg;
1975+  int i;
1976+
1977+  /* Obtain the Key Value */
1978+  if (device_find_property(me, "key") == NULL)
1979+    error("shm_init_data() required key property is missing\n");
1980+
1981+  shm->key = (key_t) device_find_integer_property(me, "key");
1982+  DTRACE(shm, ("shm key (0x%08x)\n", shm->key) );
1983
1984+  /* Figure out where this memory is in address space and how long it is */
1985+  if ( !device_find_reg_array_property(me, "reg", 0, &reg) )
1986+    error("hw_shm_init_data() no address registered\n");
1987+
1988+  /* Determine the address and length being as paranoid as possible */
1989+  shm->physical_address = 0xffffffff;
1990+  shm->sizeof_memory = 0xffffffff;
1991+
1992+  for ( i=0 ; i<reg.address.nr_cells; i++ ) {
1993+    if (reg.address.cells[0] == 0 && reg.size.cells[0] == 0)
1994+      continue;
1995+
1996+    if ( shm->physical_address != 0xffffffff )
1997+      device_error(me, "Only single celled address ranges supported\n");
1998+
1999+    shm->physical_address = reg.address.cells[i];
2000+    DTRACE(shm, ("shm physical_address=0x%x\n", shm->physical_address));
2001+
2002+    shm->sizeof_memory = reg.size.cells[i];
2003+    DTRACE(shm, ("shm length=0x%x\n", shm->sizeof_memory));
2004+  }
2005+
2006+  if ( shm->physical_address == 0xffffffff )
2007+    device_error(me, "Address not specified\n" );
2008+
2009+  if ( shm->sizeof_memory == 0xffffffff )
2010+    device_error(me, "Length not specified\n" );
2011+
2012+  /* Now actually attach to or create the shared memory area */
2013+  shm->id = shmget(shm->key, shm->sizeof_memory, IPC_CREAT | 0660);
2014+  if (shm->id == -1)
2015+    error("hw_shm_init_data() shmget failed\n");
2016+
2017+  shm->shm_address = shmat(shm->id, (char *)0, SHM_RND);
2018+  if (shm->shm_address == (void *)-1)
2019+    error("hw_shm_init_data() shmat failed\n");
2020+}
2021+
2022+static void
2023+hw_shm_attach_address_callback(device *me,
2024+                               attach_type attach,
2025+                               int space,
2026+                               unsigned_word addr,
2027+                               unsigned nr_bytes,
2028+                               access_type access,
2029+                               device *client) /*callback/default*/
2030+{
2031+  hw_shm_device *shm = (hw_shm_device*)device_data(me);
2032+
2033+  if (space != 0)
2034+    error("shm_attach_address_callback() invalid address space\n");
2035+
2036+  if (nr_bytes == 0)
2037+    error("shm_attach_address_callback() invalid size\n");
2038+}
2039+
2040+
2041+static unsigned
2042+hw_shm_io_read_buffer(device *me,
2043+                        void *dest,
2044+                        int space,
2045+                        unsigned_word addr,
2046+                        unsigned nr_bytes,
2047+                        cpu *processor,
2048+                        unsigned_word cia)
2049+{
2050+  hw_shm_device *shm = (hw_shm_device*)device_data(me);
2051+
2052+  /* do we need to worry about out of range addresses? */
2053+
2054+  DTRACE(shm, ("read %p %x %x %x\n", \
2055+     shm->shm_address, shm->physical_address, addr, nr_bytes) );
2056+
2057+  memcpy(dest, &shm->shm_address[addr - shm->physical_address], nr_bytes);
2058+  return nr_bytes;
2059+}
2060+
2061+
2062+static unsigned
2063+hw_shm_io_write_buffer(device *me,
2064+                         const void *source,
2065+                         int space,
2066+                         unsigned_word addr,
2067+                         unsigned nr_bytes,
2068+                         cpu *processor,
2069+                         unsigned_word cia)
2070+{
2071+  hw_shm_device *shm = (hw_shm_device*)device_data(me);
2072+
2073+  /* do we need to worry about out of range addresses? */
2074+
2075+  DTRACE(shm, ("write %p %x %x %x\n", \
2076+     shm->shm_address, shm->physical_address, addr, nr_bytes) );
2077+
2078+  memcpy(&shm->shm_address[addr - shm->physical_address], source, nr_bytes);
2079+  return nr_bytes;
2080+}
2081+
2082+static device_callbacks const hw_shm_callbacks = {
2083+  { generic_device_init_address, hw_shm_init_data },
2084+  { hw_shm_attach_address_callback, }, /* address */
2085+  { hw_shm_io_read_buffer,
2086+    hw_shm_io_write_buffer }, /* IO */
2087+  { NULL, }, /* DMA */
2088+  { NULL, }, /* interrupt */
2089+  { NULL, }, /* unit */
2090+  NULL,
2091+};
2092+
2093+static void *
2094+hw_shm_create(const char *name,
2095+                const device_unit *unit_address,
2096+                const char *args)
2097+{
2098+  hw_shm_device *shm = ZALLOC(hw_shm_device);
2099+  return shm;
2100+}
2101+
2102+
2103+
2104+const device_descriptor hw_shm_device_descriptor[] = {
2105+  { "shm", hw_shm_create, &hw_shm_callbacks },
2106+  { NULL },
2107+};
2108+
2109+#endif /* _HW_SHM_C_ */
2110diff -Naur gdb-6.8.orig/sim/ppc/Makefile.in gdb-6.8-rtems4.10-20090312/sim/ppc/Makefile.in
2111--- gdb-6.8.orig/sim/ppc/Makefile.in    2006-05-31 17:14:45.000000000 +0200
2112+++ gdb-6.8-rtems4.10-20090312/sim/ppc/Makefile.in      2009-03-12 04:56:03.000000000 +0100
2113@@ -834,6 +834,8 @@
2114 hw_pal.o: hw_pal.c $(DEVICE_TABLE_H) $(CPU_H)
2115 hw_phb.o: hw_phb.c $(DEVICE_TABLE_H) $(HW_PHB_H) $(COREFILE_H)
2116 hw_register.o: hw_register.c $(DEVICE_TABLE_H) $(PSIM_H)
2117+hw_sem.o: hw_sem.c $(DEVICE_TABLE_H) $(PSIM_H)
2118+hw_shm.o: hw_shm.c $(DEVICE_TABLE_H) $(PSIM_H)
2119 hw_trace.o: hw_trace.c $(DEVICE_TABLE_H)
2120 hw_vm.o: hw_vm.c $(DEVICE_TABLE_H) $(CPU_H)
2121 # ignore this line, it stops make from getting confused
2122diff -Naur gdb-6.8.orig/sim/ppc/ppc-instructions gdb-6.8-rtems4.10-20090312/sim/ppc/ppc-instructions
2123--- gdb-6.8.orig/sim/ppc/ppc-instructions       2006-11-29 16:20:55.000000000 +0100
2124+++ gdb-6.8-rtems4.10-20090312/sim/ppc/ppc-instructions 2009-03-12 04:56:03.000000000 +0100
2125@@ -3402,6 +3402,14 @@
2126            case spr_dec:
2127              *rT = cpu_get_decrementer(processor);
2128              break;
2129+               case spr_tbrl:
2130+                 if (is_64bit_implementation) *rT = TB;
2131+                 else                         *rT = EXTRACTED64(TB, 32, 63);
2132+               break;
2133+               case spr_tbru:
2134+                 if (is_64bit_implementation) *rT = EXTRACTED64(TB, 0, 31);
2135+                 else                         *rT = EXTRACTED64(TB, 0, 31);
2136+               break;
2137            case spr_tbu:
2138            case spr_tbl:
2139              /* NOTE - these SPR's are not readable. Use mftb[ul] */
2140diff -Naur gdb-6.8.orig/sim/ppc/ppc-spr-table gdb-6.8-rtems4.10-20090312/sim/ppc/ppc-spr-table
2141--- gdb-6.8.orig/sim/ppc/ppc-spr-table  2003-06-22 18:48:12.000000000 +0200
2142+++ gdb-6.8-rtems4.10-20090312/sim/ppc/ppc-spr-table    2009-03-12 04:56:03.000000000 +0100
2143@@ -32,6 +32,8 @@
2144 SRR0:26:0:0
2145 SRR1:27:0:0
2146 VRSAVE:256:0:0
2147+TBRL:268:0:0
2148+TBRU:269:0:0
2149 SPRG0:272:0:0
2150 SPRG1:273:0:0
2151 SPRG2:274:0:0
Note: See TracBrowser for help on using the repository browser.