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

4.104.11
Last change on this file since 4022445 was 4022445, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 12, 2009 at 8:59:26 AM

Add psim/configure.

  • Property mode set to 100644
File size: 65.9 KB
  • bfd/config.bfd

    diff -Naur gdb-6.8.orig/bfd/config.bfd gdb-6.8-rtems4.10-20090312/bfd/config.bfd
    old new  
    712712    targ_defvec=bfd_elf32_iq2000_vec
    713713    ;;
    714714
    715   m32c-*-elf)
     715  m32c-*-elf | m32c-*-rtems*)
    716716    targ_defvec=bfd_elf32_m32c_vec
    717717    ;;
    718718
     
    728728    targ_defvec=bfd_elf32_m32rle_vec
    729729    targ_selvecs="bfd_elf32_m32r_vec bfd_elf32_m32rle_vec"
    730730    ;;
     731  m32r-*-rtems*)
     732    targ_defvec=bfd_elf32_m32r_vec
     733    ;;
    731734  m32r-*-*)
    732735    targ_defvec=bfd_elf32_m32r_vec
    733736    ;;
  • gdb/breakpoint.c

    diff -Naur gdb-6.8.orig/gdb/breakpoint.c gdb-6.8-rtems4.10-20090312/gdb/breakpoint.c
    old new  
    5555#include "memattr.h"
    5656#include "ada-lang.h"
    5757#include "top.h"
     58#include "wrapper.h"
    5859
    5960#include "gdb-events.h"
    6061#include "mi/mi-common.h"
     
    826827          || bpt->type == bp_access_watchpoint);
    827828}
    828829
    829 /* Assuming that B is a hardware breakpoint:
     830/* Find the current value of a watchpoint on EXP.  Return the value in
     831   *VALP and *RESULTP and the chain of intermediate and final values
     832   in *VAL_CHAIN.  RESULTP and VAL_CHAIN may be NULL if the caller does
     833   not need them.
     834
     835   If an error occurs while evaluating the expression, *RESULTP will
     836   be set to NULL.  *RESULTP may be a lazy value, if the result could
     837   not be read from memory.  It is used to determine whether a value
     838   is user-specified (we should watch the whole value) or intermediate
     839   (we should watch only the bit used to locate the final value).
     840
     841   If the final value, or any intermediate value, could not be read
     842   from memory, *VALP will be set to NULL.  *VAL_CHAIN will still be
     843   set to any referenced values.  *VALP will never be a lazy value.
     844   This is the value which we store in struct breakpoint.
     845
     846   If VAL_CHAIN is non-NULL, *VAL_CHAIN will be released from the
     847   value chain.  The caller must free the values individually.  If
     848   VAL_CHAIN is NULL, all generated values will be left on the value
     849   chain.  */
     850
     851static void
     852fetch_watchpoint_value (struct expression *exp, struct value **valp,
     853                        struct value **resultp, struct value **val_chain)
     854{
     855  struct value *mark, *new_mark, *result;
     856
     857  *valp = NULL;
     858  if (resultp)
     859    *resultp = NULL;
     860  if (val_chain)
     861    *val_chain = NULL;
     862
     863  /* Evaluate the expression.  */
     864  mark = value_mark ();
     865  result = NULL;
     866  gdb_evaluate_expression (exp, &result);
     867  new_mark = value_mark ();
     868  if (mark == new_mark)
     869    return;
     870  if (resultp)
     871    *resultp = result;
     872
     873  /* Make sure it's not lazy, so that after the target stops again we
     874     have a non-lazy previous value to compare with.  */
     875  if (result != NULL
     876      && (!value_lazy (result) || gdb_value_fetch_lazy (result)))
     877    *valp = result;
     878
     879  if (val_chain)
     880    {
     881      /* Return the chain of intermediate values.  We use this to
     882         decide which addresses to watch.  */
     883      *val_chain = new_mark;
     884      value_release_to_mark (mark);
     885    }
     886}
     887
     888/* Assuming that B is a hardware watchpoint:
    830889   - Reparse watchpoint expression, is REPARSE is non-zero
    831890   - Evaluate expression and store the result in B->val
    832891   - Update the list of values that must be watched in B->loc.
     
    837896update_watchpoint (struct breakpoint *b, int reparse)
    838897{
    839898  int within_current_scope;
    840   struct value *mark = value_mark ();
    841899  struct frame_id saved_frame_id;
    842900  struct bp_location *loc;
    843901  bpstat bs;
     
    889947         to the user when the old value and the new value may actually
    890948         be completely different objects.  */
    891949      value_free (b->val);
    892       b->val = NULL;     
     950      b->val = NULL;
     951      b->val_valid = 0;
    893952    }
    894  
    895953
    896954  /* If we failed to parse the expression, for example because
    897955     it refers to a global variable in a not-yet-loaded shared library,
     
    900958     is different from out-of-scope watchpoint.  */
    901959  if (within_current_scope && b->exp)
    902960    {
    903       struct value *v, *next;
     961      struct value *val_chain, *v, *result, *next;
     962
     963      fetch_watchpoint_value (b->exp, &v, &result, &val_chain);
    904964
    905       /* Evaluate the expression and make sure it's not lazy, so that
    906          after target stops again, we have a non-lazy previous value
    907          to compare with. Also, making the value non-lazy will fetch
    908          intermediate values as needed, which we use to decide which
    909          addresses to watch.
    910 
    911          The value returned by evaluate_expression is stored in b->val.
    912          In addition, we look at all values which were created
    913          during evaluation, and set watchoints at addresses as needed.
    914          Those values are explicitly deleted here.  */
    915       v = evaluate_expression (b->exp);
    916965      /* Avoid setting b->val if it's already set.  The meaning of
    917966         b->val is 'the last value' user saw, and we should update
    918967         it only if we reported that last value to user.  As it
    919968         happens, the code that reports it updates b->val directly.  */
    920       if (b->val == NULL)
    921         b->val = v;
    922       value_contents (v);
    923       value_release_to_mark (mark);
     969      if (!b->val_valid)
     970        {
     971          b->val = v;
     972          b->val_valid = 1;
     973        }
    924974
    925975      /* Look at each value on the value chain.  */
    926       for (; v; v = next)
     976      for (v = val_chain; v; v = next)
    927977        {
    928978          /* If it's a memory location, and GDB actually needed
    929979             its contents to evaluate the expression, then we
    930              must watch it.  */
     980             must watch it.  If the first value returned is
     981             still lazy, that means an error occurred reading it;
     982             watch it anyway in case it becomes readable.  */
    931983          if (VALUE_LVAL (v) == lval_memory
    932               && ! value_lazy (v))
     984              && (v == val_chain || ! value_lazy (v)))
    933985            {
    934986              struct type *vtype = check_typedef (value_type (v));
    935987
    936988              /* We only watch structs and arrays if user asked
    937989                 for it explicitly, never if they just happen to
    938990                 appear in the middle of some value chain.  */
    939               if (v == b->val
     991              if (v == result
    940992                  || (TYPE_CODE (vtype) != TYPE_CODE_STRUCT
    941993                      && TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
    942994                {
     
    16811733            if (b->val)
    16821734              value_free (b->val);
    16831735            b->val = NULL;
     1736            b->val_valid = 0;
    16841737          }
    16851738        break;
    16861739      default:
     
    21032156  do_cleanups (old_chain);
    21042157}
    21052158
     2159/* Print out the (old or new) value associated with a watchpoint.  */
     2160
     2161static void
     2162watchpoint_value_print (struct value *val, struct ui_file *stream)
     2163{
     2164  if (val == NULL)
     2165    fprintf_unfiltered (stream, _("<unreadable>"));
     2166  else
     2167    value_print (val, stream, 0, Val_pretty_default);
     2168}
     2169
    21062170/* This is the normal print function for a bpstat.  In the future,
    21072171   much of this logic could (should?) be moved to bpstat_stop_status,
    21082172   by having it set different print_it values.
     
    22212285
    22222286    case bp_watchpoint:
    22232287    case bp_hardware_watchpoint:
    2224       if (bs->old_val != NULL)
    2225         {
    2226           annotate_watchpoint (b->number);
    2227           if (ui_out_is_mi_like_p (uiout))
    2228             ui_out_field_string
    2229               (uiout, "reason",
    2230                async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
    2231           mention (b);
    2232           ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
    2233           ui_out_text (uiout, "\nOld value = ");
    2234           value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
    2235           ui_out_field_stream (uiout, "old", stb);
    2236           ui_out_text (uiout, "\nNew value = ");
    2237           value_print (b->val, stb->stream, 0, Val_pretty_default);
    2238           ui_out_field_stream (uiout, "new", stb);
    2239           do_cleanups (ui_out_chain);
    2240           ui_out_text (uiout, "\n");
    2241           value_free (bs->old_val);
    2242           bs->old_val = NULL;
    2243         }
     2288      annotate_watchpoint (b->number);
     2289      if (ui_out_is_mi_like_p (uiout))
     2290        ui_out_field_string
     2291          (uiout, "reason",
     2292           async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
     2293      mention (b);
     2294      ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
     2295      ui_out_text (uiout, "\nOld value = ");
     2296      watchpoint_value_print (bs->old_val, stb->stream);
     2297      ui_out_field_stream (uiout, "old", stb);
     2298      ui_out_text (uiout, "\nNew value = ");
     2299      watchpoint_value_print (b->val, stb->stream);
     2300      ui_out_field_stream (uiout, "new", stb);
     2301      do_cleanups (ui_out_chain);
     2302      ui_out_text (uiout, "\n");
    22442303      /* More than one watchpoint may have been triggered.  */
    22452304      return PRINT_UNKNOWN;
    22462305      break;
     
    22532312      mention (b);
    22542313      ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
    22552314      ui_out_text (uiout, "\nValue = ");
    2256       value_print (b->val, stb->stream, 0, Val_pretty_default);
     2315      watchpoint_value_print (b->val, stb->stream);
    22572316      ui_out_field_stream (uiout, "value", stb);
    22582317      do_cleanups (ui_out_chain);
    22592318      ui_out_text (uiout, "\n");
     
    22612320      break;
    22622321
    22632322    case bp_access_watchpoint:
    2264       if (bs->old_val != NULL)     
     2323      if (bs->old_val != NULL)
    22652324        {
    22662325          annotate_watchpoint (b->number);
    22672326          if (ui_out_is_mi_like_p (uiout))
     
    22712330          mention (b);
    22722331          ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
    22732332          ui_out_text (uiout, "\nOld value = ");
    2274           value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
     2333          watchpoint_value_print (bs->old_val, stb->stream);
    22752334          ui_out_field_stream (uiout, "old", stb);
    2276           value_free (bs->old_val);
    2277           bs->old_val = NULL;
    22782335          ui_out_text (uiout, "\nNew value = ");
    22792336        }
    22802337      else
     
    22872344          ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
    22882345          ui_out_text (uiout, "\nValue = ");
    22892346        }
    2290       value_print (b->val, stb->stream, 0,Val_pretty_default);
     2347      watchpoint_value_print (b->val, stb->stream);
    22912348      ui_out_field_stream (uiout, "new", stb);
    22922349      do_cleanups (ui_out_chain);
    22932350      ui_out_text (uiout, "\n");
     
    25742631         we might be in the middle of evaluating a function call.  */
    25752632
    25762633      struct value *mark = value_mark ();
    2577       struct value *new_val = evaluate_expression (b->exp);
    2578       if (!value_equal (b->val, new_val))
     2634      struct value *new_val;
     2635
     2636      fetch_watchpoint_value (b->exp, &new_val, NULL, NULL);
     2637      if ((b->val != NULL) != (new_val != NULL)
     2638          || (b->val != NULL && !value_equal (b->val, new_val)))
    25792639        {
    2580           release_value (new_val);
    2581           value_free_to_mark (mark);
     2640          if (new_val != NULL)
     2641            {
     2642              release_value (new_val);
     2643              value_free_to_mark (mark);
     2644            }
    25822645          bs->old_val = b->val;
    25832646          b->val = new_val;
     2647          b->val_valid = 1;
    25842648          /* We will stop here */
    25852649          return WP_VALUE_CHANGED;
    25862650        }
     
    57225786  exp_end = arg;
    57235787  exp_valid_block = innermost_block;
    57245788  mark = value_mark ();
    5725   val = evaluate_expression (exp);
    5726   release_value (val);
    5727   if (value_lazy (val))
    5728     value_fetch_lazy (val);
     5789  fetch_watchpoint_value (exp, &val, NULL, NULL);
     5790  if (val != NULL)
     5791    release_value (val);
    57295792
    57305793  tok = arg;
    57315794  while (*tok == ' ' || *tok == '\t')
     
    58145877  b->exp_valid_block = exp_valid_block;
    58155878  b->exp_string = savestring (exp_start, exp_end - exp_start);
    58165879  b->val = val;
     5880  b->val_valid = 1;
    58175881  b->loc->cond = cond;
    58185882  if (cond_start)
    58195883    b->cond_string = savestring (cond_start, cond_end - cond_start);
     
    76977761      if (bpt->val)
    76987762        value_free (bpt->val);
    76997763      mark = value_mark ();
    7700       bpt->val = evaluate_expression (bpt->exp);
    7701       release_value (bpt->val);
    7702       if (value_lazy (bpt->val))
    7703         value_fetch_lazy (bpt->val);
    7704      
     7764      fetch_watchpoint_value (bpt->exp, &bpt->val, NULL, NULL);
     7765      if (bpt->val)
     7766        release_value (bpt->val);
     7767      bpt->val_valid = 1;
     7768
    77057769      if (bpt->type == bp_hardware_watchpoint ||
    77067770          bpt->type == bp_read_watchpoint ||
    77077771          bpt->type == bp_access_watchpoint)
  • gdb/breakpoint.h

    diff -Naur gdb-6.8.orig/gdb/breakpoint.h gdb-6.8-rtems4.10-20090312/gdb/breakpoint.h
    old new  
    391391    /* The largest block within which it is valid, or NULL if it is
    392392       valid anywhere (e.g. consists just of global symbols).  */
    393393    struct block *exp_valid_block;
    394     /* Value of the watchpoint the last time we checked it.  */
     394    /* Value of the watchpoint the last time we checked it, or NULL
     395       when we do not know the value yet or the value was not
     396       readable.  VAL is never lazy.  */
    395397    struct value *val;
     398    /* Nonzero if VAL is valid.  If VAL_VALID is set but VAL is NULL,
     399       then an error occurred reading the value.  */
     400    int val_valid;
    396401
    397402    /* Holds the address of the related watchpoint_scope breakpoint
    398403       when using watchpoints on local variables (might the concept
  • gdb/NEWS

    diff -Naur gdb-6.8.orig/gdb/NEWS gdb-6.8-rtems4.10-20090312/gdb/NEWS
    old new  
    11                What has changed in GDB?
    22             (Organized release by release)
    33
     4* Watchpoints can now be set on unreadable memory locations, e.g. addresses
     5which will be allocated using malloc later in program execution.
     6
    47*** Changes in GDB 6.8
    58
    69* New native configurations
  • gdb/testsuite/gdb.base/watchpoint.c

    diff -Naur gdb-6.8.orig/gdb/testsuite/gdb.base/watchpoint.c gdb-6.8-rtems4.10-20090312/gdb/testsuite/gdb.base/watchpoint.c
    old new  
    3939
    4040int doread = 0;
    4141
     42char *global_ptr;
     43
    4244void marker1 ()
    4345{
    4446}
     
    110112  return 73;
    111113}
    112114
     115void
     116func4 ()
     117{
     118  buf[0] = 3;
     119  global_ptr = buf;
     120  buf[0] = 7;
     121}
     122
    113123int main ()
    114124{
    115125#ifdef usestubs
     
    185195
    186196  func3 ();
    187197
     198  func4 ();
     199
    188200  return 0;
    189201}
  • gdb/testsuite/gdb.base/watchpoint.exp

    diff -Naur gdb-6.8.orig/gdb/testsuite/gdb.base/watchpoint.exp gdb-6.8-rtems4.10-20090312/gdb/testsuite/gdb.base/watchpoint.exp
    old new  
    645645    }
    646646}
    647647   
     648proc test_inaccessible_watchpoint {} {
     649    global gdb_prompt
     650
     651    # This is a test for watchpoints on currently inaccessible (but later
     652    # valid) memory.
     653
     654    if [runto func4] then {
     655        gdb_test "watch *global_ptr" ".*atchpoint \[0-9\]+: \\*global_ptr"
     656        gdb_test "next" ".*global_ptr = buf.*"
     657        gdb_test_multiple "next" "next over ptr init" {
     658            -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = .*\r\nNew value = 3 .*\r\n.*$gdb_prompt $" {
     659                # We can not test for <unknown> here because NULL may be readable.
     660                # This test does rely on *NULL != 3.
     661                pass "next over ptr init"
     662            }
     663        }
     664        gdb_test_multiple "next" "next over buffer set" {
     665            -re ".*atchpoint \[0-9\]+: \\*global_ptr\r\n\r\nOld value = 3 .*\r\nNew value = 7 .*\r\n.*$gdb_prompt $" {
     666                pass "next over buffer set"
     667            }
     668        }
     669    }
     670}
     671   
    648672# Start with a fresh gdb.
    649673
    650674gdb_exit
     
    797821      }
    798822    }
    799823
     824    test_inaccessible_watchpoint
     825
    800826    # See above.
    801827    if [istarget "mips-idt-*"] then {
    802828        gdb_exit
  • sim/common/aclocal.m4

    diff -Naur gdb-6.8.orig/sim/common/aclocal.m4 gdb-6.8-rtems4.10-20090312/sim/common/aclocal.m4
    old new  
    1818#
    1919# SIM_AC_OUTPUT
    2020
    21 AC_DEFUN(SIM_AC_COMMON,
     21AC_DEFUN([SIM_AC_COMMON],
    2222[
    2323# autoconf.info says this should be called right after AC_INIT.
    2424AC_CONFIG_HEADER(ifelse([$1],,config.h,[$1]):config.in)
     
    245245dnl supported.
    246246dnl ??? Until there is demonstrable value in doing something more complicated,
    247247dnl let's not.
    248 AC_DEFUN(SIM_AC_OPTION_ENVIRONMENT,
     248AC_DEFUN([SIM_AC_OPTION_ENVIRONMENT],
    249249[
    250250AC_ARG_ENABLE(sim-environment,
    251251[  --enable-sim-environment=environment Specify mixed, user, virtual or operating environment.],
     
    269269dnl Without this option all possible alignment restrictions are accommodated.
    270270dnl arg[1] is hardwired target alignment
    271271dnl arg[2] is default target alignment
    272 AC_DEFUN(SIM_AC_OPTION_ALIGNMENT,
     272AC_DEFUN([SIM_AC_OPTION_ALIGNMENT],
    273273wire_alignment="[$1]"
    274274default_alignment="[$2]"
    275275[
     
    318318
    319319
    320320dnl Conditionally compile in assertion statements.
    321 AC_DEFUN(SIM_AC_OPTION_ASSERT,
     321AC_DEFUN([SIM_AC_OPTION_ASSERT],
    322322[
    323323AC_ARG_ENABLE(sim-assert,
    324324[  --enable-sim-assert                  Specify whether to perform random assertions.],
     
    342342dnl arg[3] is the number of bits in an address
    343343dnl arg[4] is the number of bits in an OpenFirmware cell.
    344344dnl FIXME: this information should be obtained from bfd/archure
    345 AC_DEFUN(SIM_AC_OPTION_BITSIZE,
     345AC_DEFUN([SIM_AC_OPTION_BITSIZE],
    346346wire_word_bitsize="[$1]"
    347347wire_word_msb="[$2]"
    348348wire_address_bitsize="[$3]"
     
    408408dnl that support both big and little endian targets.
    409409dnl arg[1] is hardwired target endianness.
    410410dnl arg[2] is default target endianness.
    411 AC_DEFUN(SIM_AC_OPTION_ENDIAN,
     411AC_DEFUN([SIM_AC_OPTION_ENDIAN],
    412412[
    413413wire_endian="[$1]"
    414414default_endian="[$2]"
     
    458458dnl --enable-sim-hostendian is for users of the simulator when
    459459dnl they find that AC_C_BIGENDIAN does not function correctly
    460460dnl (for instance in a canadian cross)
    461 AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
     461AC_DEFUN([SIM_AC_OPTION_HOSTENDIAN],
    462462[
    463463AC_ARG_ENABLE(sim-hostendian,
    464464[  --enable-sim-hostendian=end          Specify host byte endian orientation.],
     
    490490dnl And optionally the bitsize of the floating point register.
    491491dnl arg[1] specifies the presence (or absence) of floating point hardware
    492492dnl arg[2] specifies the number of bits in a floating point register
    493 AC_DEFUN(SIM_AC_OPTION_FLOAT,
     493AC_DEFUN([SIM_AC_OPTION_FLOAT],
    494494[
    495495default_sim_float="[$1]"
    496496default_sim_float_bitsize="[$2]"
     
    519519
    520520
    521521dnl The argument is the default cache size if none is specified.
    522 AC_DEFUN(SIM_AC_OPTION_SCACHE,
     522AC_DEFUN([SIM_AC_OPTION_SCACHE],
    523523[
    524524default_sim_scache="ifelse([$1],,0,[$1])"
    525525AC_ARG_ENABLE(sim-scache,
     
    539539
    540540
    541541dnl The argument is the default model if none is specified.
    542 AC_DEFUN(SIM_AC_OPTION_DEFAULT_MODEL,
     542AC_DEFUN([SIM_AC_OPTION_DEFAULT_MODEL],
    543543[
    544544default_sim_default_model="ifelse([$1],,0,[$1])"
    545545AC_ARG_ENABLE(sim-default-model,
     
    559559dnl arg[1] Enable sim-hw by default? ("yes" or "no")
    560560dnl arg[2] is a space separated list of devices that override the defaults
    561561dnl arg[3] is a space separated list of extra target specific devices.
    562 AC_DEFUN(SIM_AC_OPTION_HARDWARE,
     562AC_DEFUN([SIM_AC_OPTION_HARDWARE],
    563563[
    564564if test x"[$1]" = x"yes"; then
    565565  sim_hw_p=yes
     
    621621dnl performance by inlining functions.
    622622dnl Guarantee that unconfigured simulators do not do any inlining
    623623sim_inline="-DDEFAULT_INLINE=0"
    624 AC_DEFUN(SIM_AC_OPTION_INLINE,
     624AC_DEFUN([SIM_AC_OPTION_INLINE],
    625625[
    626626default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
    627627AC_ARG_ENABLE(sim-inline,
     
    666666AC_SUBST(sim_inline)
    667667
    668668
    669 AC_DEFUN(SIM_AC_OPTION_PACKAGES,
     669AC_DEFUN([SIM_AC_OPTION_PACKAGES],
    670670[
    671671AC_ARG_ENABLE(sim-packages,
    672672[  --enable-sim-packages=list           Specify the packages to be included in the build.],
     
    692692AC_SUBST(sim_packages)
    693693
    694694
    695 AC_DEFUN(SIM_AC_OPTION_REGPARM,
     695AC_DEFUN([SIM_AC_OPTION_REGPARM],
    696696[
    697697AC_ARG_ENABLE(sim-regparm,
    698698[  --enable-sim-regparm=nr-parm         Pass parameters in registers instead of on the stack - x86/GCC specific.],
     
    709709AC_SUBST(sim_regparm)
    710710
    711711
    712 AC_DEFUN(SIM_AC_OPTION_RESERVED_BITS,
     712AC_DEFUN([SIM_AC_OPTION_RESERVED_BITS],
    713713[
    714714default_sim_reserved_bits="ifelse([$1],,1,[$1])"
    715715AC_ARG_ENABLE(sim-reserved-bits,
     
    726726AC_SUBST(sim_reserved_bits)
    727727
    728728
    729 AC_DEFUN(SIM_AC_OPTION_SMP,
     729AC_DEFUN([SIM_AC_OPTION_SMP],
    730730[
    731731default_sim_smp="ifelse([$1],,5,[$1])"
    732732AC_ARG_ENABLE(sim-smp,
     
    746746AC_SUBST(sim_smp)
    747747
    748748
    749 AC_DEFUN(SIM_AC_OPTION_STDCALL,
     749AC_DEFUN([SIM_AC_OPTION_STDCALL],
    750750[
    751751AC_ARG_ENABLE(sim-stdcall,
    752752[  --enable-sim-stdcall=type            Use an alternative function call/return mechanism - x86/GCC specific.],
     
    763763AC_SUBST(sim_stdcall)
    764764
    765765
    766 AC_DEFUN(SIM_AC_OPTION_XOR_ENDIAN,
     766AC_DEFUN([SIM_AC_OPTION_XOR_ENDIAN],
    767767[
    768768default_sim_xor_endian="ifelse([$1],,8,[$1])"
    769769AC_ARG_ENABLE(sim-xor-endian,
     
    782782
    783783dnl --enable-build-warnings is for developers of the simulator.
    784784dnl it enables extra GCC specific warnings.
    785 AC_DEFUN(SIM_AC_OPTION_WARNINGS,
     785AC_DEFUN([SIM_AC_OPTION_WARNINGS],
    786786[
    787787# NOTE: Don't add -Wall or -Wunused, they both include
    788788# -Wunused-parameter which reports bogus warnings.
     
    866866dnl one afterwards.  The two pieces of the common fragment are inserted into
    867867dnl the target's fragment at the appropriate points.
    868868
    869 AC_DEFUN(SIM_AC_OUTPUT,
     869AC_DEFUN([SIM_AC_OUTPUT],
    870870[
    871871AC_LINK_FILES($sim_link_files, $sim_link_links)
    872872dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
     
    895895sinclude(../../config/gettext-sister.m4)
    896896
    897897dnl --enable-cgen-maint support
    898 AC_DEFUN(SIM_AC_OPTION_CGEN_MAINT,
     898AC_DEFUN([SIM_AC_OPTION_CGEN_MAINT],
    899899[
    900900cgen_maint=no
    901901dnl Default is to use one in build tree.
  • sim/common/gentmap.c

    diff -Naur gdb-6.8.orig/sim/common/gentmap.c gdb-6.8-rtems4.10-20090312/sim/common/gentmap.c
    old new  
    22
    33#include <stdio.h>
    44#include <stdlib.h>
     5#include <string.h>
    56
    67struct tdefs {
    78  char *symbol;
  • sim/common/sim-signal.c

    diff -Naur gdb-6.8.orig/sim/common/sim-signal.c gdb-6.8-rtems4.10-20090312/sim/common/sim-signal.c
    old new  
    2626   to not think the process has died (so it can be debugged at the point of
    2727   failure).  */
    2828
    29 #ifdef _MSC_VER
     29#ifdef _WIN32
    3030#ifndef SIGTRAP
    3131#define SIGTRAP 5
    3232#endif
  • sim/erc32/configure

    diff -Naur gdb-6.8.orig/sim/erc32/configure gdb-6.8-rtems4.10-20090312/sim/erc32/configure
    old new  
    309309# include <unistd.h>
    310310#endif"
    311311
    312 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'
     312ac_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'
    313313ac_subst_files=''
    314314
    315315# Initialize some variables set by options.
     
    858858  --enable-sim-trace=opts               Enable tracing flags
    859859  --enable-sim-profile=opts             Enable profiling flags
    860860
     861Optional Packages:
     862  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
     863  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
     864  --with-system-readline  use installed readline library
     865
    861866Some influential environment variables:
    862867  CC          C compiler command
    863868  CFLAGS      C compiler flags
     
    44934498done
    44944499
    44954500
    4496 # In the Cygwin environment, we need some additional flags.
    4497 echo "$as_me:$LINENO: checking for cygwin" >&5
    4498 echo $ECHO_N "checking for cygwin... $ECHO_C" >&6
    4499 if test "${sim_cv_os_cygwin+set}" = set; then
    4500   echo $ECHO_N "(cached) $ECHO_C" >&6
    4501 else
    4502   cat >conftest.$ac_ext <<_ACEOF
    4503 /* confdefs.h.  */
    4504 _ACEOF
    4505 cat confdefs.h >>conftest.$ac_ext
    4506 cat >>conftest.$ac_ext <<_ACEOF
    4507 /* end confdefs.h.  */
    45084501
    4509 #ifdef __CYGWIN__
    4510 lose
    4511 #endif
    4512 _ACEOF
    4513 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
    4514   $EGREP "lose" >/dev/null 2>&1; then
    4515   sim_cv_os_cygwin=yes
    4516 else
    4517   sim_cv_os_cygwin=no
    4518 fi
    4519 rm -f conftest*
     4502# Check whether --with-system-readline or --without-system-readline was given.
     4503if test "${with_system_readline+set}" = set; then
     4504  withval="$with_system_readline"
    45204505
    4521 fi
    4522 echo "$as_me:$LINENO: result: $sim_cv_os_cygwin" >&5
    4523 echo "${ECHO_T}$sim_cv_os_cygwin" >&6
     4506fi;
    45244507
    4525 if test x$sim_cv_os_cygwin = xyes; then
    4526   TERMCAP='`if test -r ../../libtermcap/libtermcap.a; then echo ../../libtermcap/libtermcap.a; else echo -ltermcap; fi` -luser32'
    4527 else
    4528   echo "$as_me:$LINENO: checking for main in -ltermcap" >&5
    4529 echo $ECHO_N "checking for main in -ltermcap... $ECHO_C" >&6
    4530 if test "${ac_cv_lib_termcap_main+set}" = set; then
    4531   echo $ECHO_N "(cached) $ECHO_C" >&6
    4532 else
    4533   ac_check_lib_save_LIBS=$LIBS
    4534 LIBS="-ltermcap  $LIBS"
    4535 cat >conftest.$ac_ext <<_ACEOF
     4508if test "$with_system_readline" = yes; then
     4509  echo "$as_me:$LINENO: checking for readline" >&5
     4510echo $ECHO_N "checking for readline... $ECHO_C" >&6
     4511  save_LIBS="$LIBS"
     4512  LIBS="-lreadline $save_LIBS"
     4513  cat >conftest.$ac_ext <<_ACEOF
    45364514/* confdefs.h.  */
    45374515_ACEOF
    45384516cat confdefs.h >>conftest.$ac_ext
    45394517cat >>conftest.$ac_ext <<_ACEOF
    45404518/* end confdefs.h.  */
    45414519
    4542 
     4520/* Override any gcc2 internal prototype to avoid an error.  */
     4521#ifdef __cplusplus
     4522extern "C"
     4523#endif
     4524/* We use char because int might match the return type of a gcc2
     4525   builtin and then its argument prototype would still apply.  */
     4526char add_history ();
    45434527int
    45444528main ()
    45454529{
    4546 main ();
     4530add_history ();
    45474531  ;
    45484532  return 0;
    45494533}
     
    45704554  ac_status=$?
    45714555  echo "$as_me:$LINENO: \$? = $ac_status" >&5
    45724556  (exit $ac_status); }; }; then
    4573   ac_cv_lib_termcap_main=yes
     4557  READLINE=-lreadline
    45744558else
    45754559  echo "$as_me: failed program was:" >&5
    45764560sed 's/^/| /' conftest.$ac_ext >&5
    45774561
    4578 ac_cv_lib_termcap_main=no
    4579 fi
    4580 rm -f conftest.err conftest.$ac_objext \
    4581       conftest$ac_exeext conftest.$ac_ext
    4582 LIBS=$ac_check_lib_save_LIBS
    4583 fi
    4584 echo "$as_me:$LINENO: result: $ac_cv_lib_termcap_main" >&5
    4585 echo "${ECHO_T}$ac_cv_lib_termcap_main" >&6
    4586 if test $ac_cv_lib_termcap_main = yes; then
    4587   TERMCAP=-ltermcap
    4588 else
    4589   TERMCAP=""
    4590 fi
    4591 
    4592 fi
    4593 
    4594 
    4595 # We prefer the in-tree readline.  Top-level dependencies make sure
    4596 # src/readline (if it's there) is configured before src/sim.
    4597 if test -r ../../readline/Makefile; then
    4598   READLINE=../../readline/libreadline.a
    4599 else
    4600   echo "$as_me:$LINENO: checking for readline in -lreadline" >&5
    4601 echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6
    4602 if test "${ac_cv_lib_readline_readline+set}" = set; then
    4603   echo $ECHO_N "(cached) $ECHO_C" >&6
    4604 else
    4605   ac_check_lib_save_LIBS=$LIBS
    4606 LIBS="-lreadline $TERMCAP $LIBS"
    4607 cat >conftest.$ac_ext <<_ACEOF
     4562 LIBS="-lreadline -lncurses $save_LIBS"
     4563      cat >conftest.$ac_ext <<_ACEOF
    46084564/* confdefs.h.  */
    46094565_ACEOF
    46104566cat confdefs.h >>conftest.$ac_ext
     
    46174573#endif
    46184574/* We use char because int might match the return type of a gcc2
    46194575   builtin and then its argument prototype would still apply.  */
    4620 char readline ();
     4576char add_history ();
    46214577int
    46224578main ()
    46234579{
    4624 readline ();
     4580add_history ();
    46254581  ;
    46264582  return 0;
    46274583}
     
    46484604  ac_status=$?
    46494605  echo "$as_me:$LINENO: \$? = $ac_status" >&5
    46504606  (exit $ac_status); }; }; then
    4651   ac_cv_lib_readline_readline=yes
     4607  READLINE="-lreadline -lncurses"
    46524608else
    46534609  echo "$as_me: failed program was:" >&5
    46544610sed 's/^/| /' conftest.$ac_ext >&5
    46554611
    4656 ac_cv_lib_readline_readline=no
     4612{ { echo "$as_me:$LINENO: error: unable to detect readline" >&5
     4613echo "$as_me: error: unable to detect readline" >&2;}
     4614   { (exit 1); exit 1; }; }
    46574615fi
    46584616rm -f conftest.err conftest.$ac_objext \
    46594617      conftest$ac_exeext conftest.$ac_ext
    4660 LIBS=$ac_check_lib_save_LIBS
     4618
    46614619fi
    4662 echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5
    4663 echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6
    4664 if test $ac_cv_lib_readline_readline = yes; then
    4665   READLINE=-lreadline
    4666 else
    4667   { { echo "$as_me:$LINENO: error: the required \"readline\" library is missing" >&5
    4668 echo "$as_me: error: the required \"readline\" library is missing" >&2;}
    4669    { (exit 1); exit 1; }; }
     4620rm -f conftest.err conftest.$ac_objext \
     4621      conftest$ac_exeext conftest.$ac_ext
     4622  LIBS="$save_LIBS"
     4623  echo "$as_me:$LINENO: result: $READLINE" >&5
     4624echo "${ECHO_T}$READLINE" >&6
     4625  READLINE_DEPS=
     4626  READLINE_CFLAGS=
     4627else
     4628  READLINE='$(READLINE_DIR)/libreadline.a'
     4629  READLINE_DEPS='$(READLINE)'
     4630  READLINE_CFLAGS='-I$(READLINE_SRC)/..'
    46704631fi
    46714632
    4672 fi
     4633
     4634
    46734635
    46744636
    46754637ac_sources="$sim_link_files"
     
    53895351s,@sim_stdio@,$sim_stdio,;t t
    53905352s,@sim_trace@,$sim_trace,;t t
    53915353s,@sim_profile@,$sim_profile,;t t
    5392 s,@TERMCAP@,$TERMCAP,;t t
    53935354s,@READLINE@,$READLINE,;t t
     5355s,@READLINE_DEPS@,$READLINE_DEPS,;t t
     5356s,@READLINE_CFLAGS@,$READLINE_CFLAGS,;t t
    53945357s,@cgen_breaks@,$cgen_breaks,;t t
    53955358s,@LIBOBJS@,$LIBOBJS,;t t
    53965359s,@LTLIBOBJS@,$LTLIBOBJS,;t t
  • sim/erc32/configure.ac

    diff -Naur gdb-6.8.orig/sim/erc32/configure.ac gdb-6.8-rtems4.10-20090312/sim/erc32/configure.ac
    old new  
    1111
    1212AC_CHECK_HEADERS(stdlib.h)
    1313
    14 # In the Cygwin environment, we need some additional flags.
    15 AC_CACHE_CHECK([for cygwin], sim_cv_os_cygwin,
    16 [AC_EGREP_CPP(lose, [
    17 #ifdef __CYGWIN__
    18 lose
    19 #endif],[sim_cv_os_cygwin=yes],[sim_cv_os_cygwin=no])])
     14AC_ARG_WITH([system-readline],
     15  [AS_HELP_STRING([--with-system-readline],
     16                  [use installed readline library])])
    2017
    21 if test x$sim_cv_os_cygwin = xyes; then
    22   TERMCAP='`if test -r ../../libtermcap/libtermcap.a; then echo ../../libtermcap/libtermcap.a; else echo -ltermcap; fi` -luser32'
     18if test "$with_system_readline" = yes; then
     19  AC_MSG_CHECKING([for readline])
     20  save_LIBS="$LIBS"
     21  LIBS="-lreadline $save_LIBS"
     22  AC_LINK_IFELSE([AC_LANG_CALL([],
     23    [add_history])], [READLINE=-lreadline],
     24    [ LIBS="-lreadline -lncurses $save_LIBS"
     25      AC_LINK_IFELSE([AC_LANG_CALL([],
     26        [add_history])], [READLINE="-lreadline -lncurses"],
     27        [AC_MSG_ERROR([unable to detect readline])])
     28    ])
     29  LIBS="$save_LIBS"
     30  AC_MSG_RESULT($READLINE)
     31  READLINE_DEPS=
     32  READLINE_CFLAGS=
    2333else
    24   AC_CHECK_LIB(termcap, main, TERMCAP=-ltermcap, TERMCAP="")
    25 fi
    26 AC_SUBST(TERMCAP)
    27 
    28 # We prefer the in-tree readline.  Top-level dependencies make sure
    29 # src/readline (if it's there) is configured before src/sim.
    30 if test -r ../../readline/Makefile; then
    31   READLINE=../../readline/libreadline.a
    32 else
    33   AC_CHECK_LIB(readline, readline, READLINE=-lreadline,
    34                AC_ERROR([the required "readline" library is missing]), $TERMCAP)
     34  READLINE='$(READLINE_DIR)/libreadline.a'
     35  READLINE_DEPS='$(READLINE)'
     36  READLINE_CFLAGS='-I$(READLINE_SRC)/..'
    3537fi
    3638AC_SUBST(READLINE)
     39AC_SUBST(READLINE_DEPS)
     40AC_SUBST(READLINE_CFLAGS)
     41
    3742SIM_AC_OUTPUT
  • sim/erc32/erc32.c

    diff -Naur gdb-6.8.orig/sim/erc32/erc32.c gdb-6.8-rtems4.10-20090312/sim/erc32/erc32.c
    old new  
    2424
    2525#include <sys/types.h>
    2626#include <stdio.h>
     27#include <string.h>
    2728#include <termios.h>
    2829#include <sys/fcntl.h>
    2930#include <sys/file.h>
     
    413414    if (rom8) mec_memcfg &= ~0x20000;
    414415    else mec_memcfg |= 0x20000;
    415416
    416     mem_ramsz = (256 * 1024) << ((mec_memcfg >> 10) & 7);
     417    mem_ramsz = (512 * 1024) << ((mec_memcfg >> 10) & 7);
    417418    mem_romsz = (128 * 1024) << ((mec_memcfg >> 18) & 7);
    418419
    419420    if (sparclite_board) {
     
    16591660        errmec = 0;
    16601661        return(1);
    16611662    }
    1662 #endif;
     1663#endif
    16631664
    16641665    if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
    16651666        fetch_bytes (asi, &ramb[addr & mem_rammask], data, sz);
     
    17361737        errmec = 0;
    17371738        return(1);
    17381739    }
    1739 #endif;
     1740#endif
    17401741
    17411742    if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
    17421743        if (mem_accprot) {
  • sim/erc32/exec.c

    diff -Naur gdb-6.8.orig/sim/erc32/exec.c gdb-6.8-rtems4.10-20090312/sim/erc32/exec.c
    old new  
    17131713            sregs->fdp[rs2 | 1] = sregs->fs[rs2 & ~1];
    17141714            sregs->fdp[rs2 & ~1] = sregs->fs[rs2 | 1];
    17151715    default:
    1716       ;
     1716      break;
    17171717    }
    17181718#endif
    17191719
     
    18861886        sregs->fs[rd & ~1] = sregs->fdp[rd | 1];
    18871887        sregs->fs[rd | 1] = sregs->fdp[rd & ~1];
    18881888    default:
    1889       ;
     1889      break;
    18901890    }
    18911891#endif
    18921892    if (sregs->fpstate == FP_EXC_PE) {
  • sim/erc32/Makefile.in

    diff -Naur gdb-6.8.orig/sim/erc32/Makefile.in gdb-6.8-rtems4.10-20090312/sim/erc32/Makefile.in
    old new  
    1818
    1919## COMMON_PRE_CONFIG_FRAG
    2020
    21 TERMCAP_LIB = @TERMCAP@
     21# TERMCAP_LIB = -lncurses
    2222READLINE_LIB = @READLINE@
    2323
    2424SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o
    2525SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) -lm
    26 SIM_EXTRA_ALL = sis
     26SIM_EXTRA_ALL = sis$(EXEEXT)
    2727SIM_EXTRA_INSTALL = install-sis
    2828SIM_EXTRA_CLEAN = clean-sis
    2929
     
    3737# `sis' doesn't need interf.o.
    3838SIS_OFILES = exec.o erc32.o func.o help.o float.o
    3939
    40 sis: sis.o $(SIS_OFILES) $(COMMON_OBJS) $(LIBDEPS)
    41         $(CC) $(ALL_CFLAGS) -o sis \
     40sis$(EXEEXT): sis.o $(SIS_OFILES) $(COMMON_OBJS) $(LIBDEPS)
     41        $(CC) $(ALL_CFLAGS) -o sis$(EXEEXT) \
    4242          sis.o $(SIS_OFILES) $(COMMON_OBJS) $(EXTRA_LIBS)
    4343
    4444# FIXME: This computes the build host's endianness, doesn't it?
     
    5151
    5252# Copy the files into directories where they will be run.
    5353install-sis: installdirs
    54         n=`echo sis | sed '$(program_transform_name)'`; \
    55         $(INSTALL_PROGRAM) sis$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
     54        n=`echo sis$(EXEEXT) | sed '$(program_transform_name)'`; \
     55        $(INSTALL_PROGRAM) sis$(EXEEXT) $(DESTDIR)$(bindir)/$$n
    5656
    5757clean-sis:
    58         rm -f sis end end.h
     58        rm -f sis$(EXEEXT) end end.h
    5959
    6060configure:
    6161        @echo "Rebuilding configure..."
  • sim/h8300/compile.c

    diff -Naur gdb-6.8.orig/sim/h8300/compile.c gdb-6.8-rtems4.10-20090312/sim/h8300/compile.c
    old new  
    3838# define SIGTRAP 5
    3939#endif
    4040
     41#ifdef _WIN32
     42#ifndef SIGBUS
     43#define SIGBUS 10
     44#endif
     45#endif
     46
    4147int debug;
    4248
    4349host_callback *sim_callback;
     
    599605  /* Find the exact opcode/arg combo.  */
    600606  for (q = h8_opcodes; q->name; q++)
    601607    {
    602       op_type *nib = q->data.nib;
     608      const op_type *nib = q->data.nib;
    603609      unsigned int len = 0;
    604610
    605611      if ((q->available == AV_H8SX && !h8300sxmode) ||
     
    924930#endif
    925931                  /* Fill in the args.  */
    926932                  {
    927                     op_type *args = q->args.nib;
     933                    const op_type *args = q->args.nib;
    928934                    int hadone = 0;
    929935                    int nargs;
    930936
  • sim/m32c/gdb-if.c

    diff -Naur gdb-6.8.orig/sim/m32c/gdb-if.c gdb-6.8-rtems4.10-20090312/sim/m32c/gdb-if.c
    old new  
    534534#endif
    535535
    536536    case 5:
     537#ifdef SIGTRAP
    537538      return SIGTRAP;
    538 
     539#else
     540      return SIGSEGV;
     541#endif
     542   
    539543    case 10:
    540544#ifdef SIGBUS
    541545      return SIGBUS;
  • sim/m32c/Makefile.in

    diff -Naur gdb-6.8.orig/sim/m32c/Makefile.in gdb-6.8-rtems4.10-20090312/sim/m32c/Makefile.in
    old new  
    5555        ./opc2c -l m32c.out $(srcdir)/m32c.opc > m32c.c
    5656
    5757opc2c : opc2c.o safe-fgets.o
    58         $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
     58        $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $^ -o $@
    5959
    6060sample.x : $(srcdir)/sample.S $(srcdir)/sample.ld
    6161        ../../gcc/xgcc $(CPUFLAGS) -B../../gcc/ -c $(srcdir)/sample.S -o sample.o
     
    8383mem.o : mem.h cpu.h syscalls.h
    8484misc.o : cpu.h misc.h
    8585opc2c.o : safe-fgets.h
     86        $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ -c $(srcdir)/opc2c.c
    8687reg.o : cpu.h
    8788safe-fgets.o : safe-fgets.h
     89        $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ -c $(srcdir)/safe-fgets.c
    8890srcdest.c : cpu.h mem.h
    8991syscalls.c : cpu.h mem.h syscalls.h
    9092
  • sim/ppc/configure

    diff -Naur gdb-6.8.orig/sim/ppc/configure gdb-6.8-rtems4.10-20090312/sim/ppc/configure
    old new  
    27092709
    27102710fi;
    27112711
     2712echo "$as_me:$LINENO: checking if union semun defined" >&5
     2713echo $ECHO_N "checking if union semun defined... $ECHO_C" >&6
     2714if test "${ac_cv_HAS_UNION_SEMUN+set}" = set; then
     2715  echo $ECHO_N "(cached) $ECHO_C" >&6
     2716else
     2717  cat >conftest.$ac_ext <<_ACEOF
     2718/* confdefs.h.  */
     2719_ACEOF
     2720cat confdefs.h >>conftest.$ac_ext
     2721cat >>conftest.$ac_ext <<_ACEOF
     2722/* end confdefs.h.  */
     2723
     2724#include <sys/types.h>
     2725#include <sys/ipc.h>
     2726#include <sys/sem.h>
     2727int
     2728main ()
     2729{
     2730union semun arg ;
     2731  ;
     2732  return 0;
     2733}
     2734_ACEOF
     2735rm -f conftest.$ac_objext
     2736if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
     2737  (eval $ac_compile) 2>conftest.er1
     2738  ac_status=$?
     2739  grep -v '^ *+' conftest.er1 >conftest.err
     2740  rm -f conftest.er1
     2741  cat conftest.err >&5
     2742  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2743  (exit $ac_status); } &&
     2744         { ac_try='test -z "$ac_c_werror_flag"
     2745                         || test ! -s conftest.err'
     2746  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     2747  (eval $ac_try) 2>&5
     2748  ac_status=$?
     2749  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2750  (exit $ac_status); }; } &&
     2751         { ac_try='test -s conftest.$ac_objext'
     2752  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     2753  (eval $ac_try) 2>&5
     2754  ac_status=$?
     2755  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2756  (exit $ac_status); }; }; then
     2757  ac_cv_has_union_semun="yes"
     2758else
     2759  echo "$as_me: failed program was:" >&5
     2760sed 's/^/| /' conftest.$ac_ext >&5
     2761
     2762ac_cv_has_union_semun="no"
     2763fi
     2764rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
     2765echo "$as_me:$LINENO: result: $ac_cv_has_union_semun" >&5
     2766echo "${ECHO_T}$ac_cv_has_union_semun" >&6
     2767
     2768fi
     2769echo "$as_me:$LINENO: result: $ac_cv_HAS_UNION_SEMUN" >&5
     2770echo "${ECHO_T}$ac_cv_HAS_UNION_SEMUN" >&6
     2771
     2772
     2773if test "$ac_cv_has_union_semun" = "yes"; then
     2774  echo "$as_me:$LINENO: checking whether System V semaphores are supported" >&5
     2775echo $ECHO_N "checking whether System V semaphores are supported... $ECHO_C" >&6
     2776if test "${ac_cv_sysv_sem+set}" = set; then
     2777  echo $ECHO_N "(cached) $ECHO_C" >&6
     2778else
     2779
     2780  if test "$cross_compiling" = yes; then
     2781  :
     2782else
     2783  cat >conftest.$ac_ext <<_ACEOF
     2784/* confdefs.h.  */
     2785_ACEOF
     2786cat confdefs.h >>conftest.$ac_ext
     2787cat >>conftest.$ac_ext <<_ACEOF
     2788/* end confdefs.h.  */
     2789
     2790  #include <sys/types.h>
     2791  #include <sys/ipc.h>
     2792  #include <sys/sem.h>
     2793  int main () {
     2794    union semun arg ;
     2795
     2796    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
     2797    if (id == -1)
     2798      exit(1);
     2799    arg.val = 0; /* avoid implicit type cast to union */
     2800    if (semctl(id, 0, IPC_RMID, arg) == -1)
     2801      exit(1);
     2802    exit(0);
     2803  }
     2804
     2805_ACEOF
     2806rm -f conftest$ac_exeext
     2807if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
     2808  (eval $ac_link) 2>&5
     2809  ac_status=$?
     2810  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2811  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
     2812  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     2813  (eval $ac_try) 2>&5
     2814  ac_status=$?
     2815  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2816  (exit $ac_status); }; }; then
     2817  ac_cv_sysv_sem="yes"
     2818else
     2819  echo "$as_me: program exited with status $ac_status" >&5
     2820echo "$as_me: failed program was:" >&5
     2821sed 's/^/| /' conftest.$ac_ext >&5
     2822
     2823( exit $ac_status )
     2824ac_cv_sysv_sem="no"
     2825fi
     2826rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
     2827fi
     2828
     2829fi
     2830echo "$as_me:$LINENO: result: $ac_cv_sysv_sem" >&5
     2831echo "${ECHO_T}$ac_cv_sysv_sem" >&6
     2832else  # semun is not defined
     2833  echo "$as_me:$LINENO: checking whether System V semaphores are supported" >&5
     2834echo $ECHO_N "checking whether System V semaphores are supported... $ECHO_C" >&6
     2835if test "${ac_cv_sysv_sem+set}" = set; then
     2836  echo $ECHO_N "(cached) $ECHO_C" >&6
     2837else
     2838
     2839  if test "$cross_compiling" = yes; then
     2840  :
     2841else
     2842  cat >conftest.$ac_ext <<_ACEOF
     2843/* confdefs.h.  */
     2844_ACEOF
     2845cat confdefs.h >>conftest.$ac_ext
     2846cat >>conftest.$ac_ext <<_ACEOF
     2847/* end confdefs.h.  */
     2848
     2849  #include <sys/types.h>
     2850  #include <sys/ipc.h>
     2851  #include <sys/sem.h>
     2852  union semun {
     2853    int val;
     2854    struct semid_ds *buf;
     2855    ushort *array;
     2856  };
     2857  int main () {
     2858    union semun arg ;
     2859
     2860    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
     2861    if (id == -1)
     2862      exit(1);
     2863    arg.val = 0; /* avoid implicit type cast to union */
     2864    if (semctl(id, 0, IPC_RMID, arg) == -1)
     2865      exit(1);
     2866    exit(0);
     2867  }
     2868
     2869_ACEOF
     2870rm -f conftest$ac_exeext
     2871if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
     2872  (eval $ac_link) 2>&5
     2873  ac_status=$?
     2874  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2875  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
     2876  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     2877  (eval $ac_try) 2>&5
     2878  ac_status=$?
     2879  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2880  (exit $ac_status); }; }; then
     2881  ac_cv_sysv_sem="yes"
     2882else
     2883  echo "$as_me: program exited with status $ac_status" >&5
     2884echo "$as_me: failed program was:" >&5
     2885sed 's/^/| /' conftest.$ac_ext >&5
     2886
     2887( exit $ac_status )
     2888ac_cv_sysv_sem="no"
     2889fi
     2890rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
     2891fi
     2892
     2893fi
     2894echo "$as_me:$LINENO: result: $ac_cv_sysv_sem" >&5
     2895echo "${ECHO_T}$ac_cv_sysv_sem" >&6
     2896fi
     2897
     2898echo "$as_me:$LINENO: checking whether System V shared memory is supported" >&5
     2899echo $ECHO_N "checking whether System V shared memory is supported... $ECHO_C" >&6
     2900if test "${ac_cv_sysv_shm+set}" = set; then
     2901  echo $ECHO_N "(cached) $ECHO_C" >&6
     2902else
     2903
     2904if test "$cross_compiling" = yes; then
     2905  :
     2906else
     2907  cat >conftest.$ac_ext <<_ACEOF
     2908/* confdefs.h.  */
     2909_ACEOF
     2910cat confdefs.h >>conftest.$ac_ext
     2911cat >>conftest.$ac_ext <<_ACEOF
     2912/* end confdefs.h.  */
     2913
     2914#include <sys/types.h>
     2915#include <sys/ipc.h>
     2916#include <sys/shm.h>
     2917int main () {
     2918  int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400);
     2919  if (id == -1)
     2920    exit(1);
     2921  if (shmctl(id, IPC_RMID, 0) == -1)
     2922    exit(1);
     2923  exit(0);
     2924}
     2925
     2926_ACEOF
     2927rm -f conftest$ac_exeext
     2928if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
     2929  (eval $ac_link) 2>&5
     2930  ac_status=$?
     2931  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2932  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
     2933  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     2934  (eval $ac_try) 2>&5
     2935  ac_status=$?
     2936  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     2937  (exit $ac_status); }; }; then
     2938  ac_cv_sysv_shm="yes"
     2939else
     2940  echo "$as_me: program exited with status $ac_status" >&5
     2941echo "$as_me: failed program was:" >&5
     2942sed 's/^/| /' conftest.$ac_ext >&5
     2943
     2944( exit $ac_status )
     2945ac_cv_sysv_shm="no"
     2946fi
     2947rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
     2948fi
     2949
     2950fi
     2951echo "$as_me:$LINENO: result: $ac_cv_sysv_shm" >&5
     2952echo "${ECHO_T}$ac_cv_sysv_shm" >&6
     2953
     2954if test x"$ac_cv_sysv_shm" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
     2955  sim_sysv_ipc_hw=",sem,shm";
     2956else
     2957  sim_sysv_ipc_hw="";
     2958fi
     2959
     2960if test x"$ac_cv_has_union_semun" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
     2961  sim_hwflags="-DHAS_UNION_SEMUN";
     2962fi
     2963
     2964
    27122965# Check whether --enable-sim-hardware or --disable-sim-hardware was given.
    27132966if test "${enable_sim_hardware+set}" = set; then
    27142967  enableval="$enable_sim_hardware"
    2715   hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
     2968  hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
    27162969case "${enableval}" in
    27172970  yes)  ;;
    27182971  no)   { { echo "$as_me:$LINENO: error: \"List of hardware must be specified for --enable-sim-hardware\"" >&5
     
    27282981  echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
    27292982fi
    27302983else
    2731   hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
     2984  hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
    27322985sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
    27332986sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
    27342987if test x"$silent" != x"yes"; then
    27352988  echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
    27362989fi
    27372990fi;
    2738 
    27392991# Check whether --enable-sim-hostbitsize or --disable-sim-hostbitsize was given.
    27402992if test "${enable_sim_hostbitsize+set}" = set; then
    27412993  enableval="$enable_sim_hostbitsize"
     
    27523004  sim_hostbitsize=""
    27533005fi;
    27543006
    2755 
    27563007# Check whether --enable-sim-hostendian or --disable-sim-hostendian was given.
    27573008if test "${enable_sim_hostendian+set}" = set; then
    27583009  enableval="$enable_sim_hostendian"
  • sim/ppc/configure.ac

    diff -Naur gdb-6.8.orig/sim/ppc/configure.ac gdb-6.8-rtems4.10-20090312/sim/ppc/configure.ac
    old new  
    209209esac
    210210])dnl
    211211
     212AC_CACHE_CHECK([if union semun defined],
     213  ac_cv_HAS_UNION_SEMUN,
     214  [AC_TRY_COMPILE([
     215#include <sys/types.h>
     216#include <sys/ipc.h>
     217#include <sys/sem.h>],
     218[union semun arg ;],
     219[ac_cv_has_union_semun="yes"],
     220[ac_cv_has_union_semun="no"])
     221AC_MSG_RESULT($ac_cv_has_union_semun)
     222])
     223
     224
     225if test "$ac_cv_has_union_semun" = "yes"; then
     226  AC_CACHE_CHECK(whether System V semaphores are supported,
     227  ac_cv_sysv_sem,
     228  [
     229  AC_TRY_RUN(
     230  [
     231  #include <sys/types.h>
     232  #include <sys/ipc.h>
     233  #include <sys/sem.h>
     234  int main () {
     235    union semun arg ;
     236
     237    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
     238    if (id == -1)
     239      exit(1);
     240    arg.val = 0; /* avoid implicit type cast to union */
     241    if (semctl(id, 0, IPC_RMID, arg) == -1)
     242      exit(1);
     243    exit(0);
     244  }
     245  ],
     246  ac_cv_sysv_sem="yes", ac_cv_sysv_sem="no", :)
     247  ])
     248else  # semun is not defined
     249  AC_CACHE_CHECK(whether System V semaphores are supported,
     250  ac_cv_sysv_sem,
     251  [
     252  AC_TRY_RUN(
     253  [
     254  #include <sys/types.h>
     255  #include <sys/ipc.h>
     256  #include <sys/sem.h>
     257  union semun {
     258    int val;
     259    struct semid_ds *buf;
     260    ushort *array;
     261  };
     262  int main () {
     263    union semun arg ;
     264
     265    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
     266    if (id == -1)
     267      exit(1);
     268    arg.val = 0; /* avoid implicit type cast to union */
     269    if (semctl(id, 0, IPC_RMID, arg) == -1)
     270      exit(1);
     271    exit(0);
     272  }
     273  ],
     274  ac_cv_sysv_sem="yes", ac_cv_sysv_sem="no", :)
     275  ])
     276fi
     277
     278AC_CACHE_CHECK(whether System V shared memory is supported,
     279ac_cv_sysv_shm,
     280[
     281AC_TRY_RUN([
     282#include <sys/types.h>
     283#include <sys/ipc.h>
     284#include <sys/shm.h>
     285int main () {
     286  int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400);
     287  if (id == -1)
     288    exit(1);
     289  if (shmctl(id, IPC_RMID, 0) == -1)
     290    exit(1);
     291  exit(0);
     292}
     293],
     294ac_cv_sysv_shm="yes", ac_cv_sysv_shm="no", :)
     295])
     296
     297if test x"$ac_cv_sysv_shm" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
     298  sim_sysv_ipc_hw=",sem,shm";
     299else
     300  sim_sysv_ipc_hw="";
     301fi
     302
     303if test x"$ac_cv_has_union_semun" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
     304  sim_hwflags="-DHAS_UNION_SEMUN";
     305fi
     306
    212307
    213308AC_ARG_ENABLE(sim-hardware,
    214309[  --enable-sim-hardware=list           Specify the hardware to be included in the build.],
    215 [hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
     310[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
    216311case "${enableval}" in
    217312  yes)  ;;
    218313  no)   AC_MSG_ERROR("List of hardware must be specified for --enable-sim-hardware"); hardware="";;
     
    224319sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
    225320if test x"$silent" != x"yes" && test x"$hardware" != x""; then
    226321  echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
    227 fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide"
     322fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
    228323sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
    229324sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
    230325if test x"$silent" != x"yes"; then
    231326  echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
    232327fi])dnl
    233328
    234 
    235329AC_ARG_ENABLE(sim-hostbitsize,
    236330[  --enable-sim-hostbitsize=32|64       Specify host bitsize (32 or 64).],
    237331[case "${enableval}" in
  • sim/ppc/debug.c

    diff -Naur gdb-6.8.orig/sim/ppc/debug.c gdb-6.8-rtems4.10-20090312/sim/ppc/debug.c
    old new  
    7070  { trace_pass_device, "pass-device" },
    7171  { trace_phb_device, "phb-device" },
    7272  { trace_register_device, "register-device", "Device initializing registers" },
     73  { trace_sem_device, "sem-device" },
     74  { trace_shm_device, "shm-device" },
    7375  { trace_stack_device, "stack-device" },
    7476  { trace_vm_device, "vm-device" },
    7577  /* packages */
  • sim/ppc/debug.h

    diff -Naur gdb-6.8.orig/sim/ppc/debug.h gdb-6.8-rtems4.10-20090312/sim/ppc/debug.h
    old new  
    5151  trace_pal_device,
    5252  trace_pass_device,
    5353  trace_phb_device,
     54  trace_sem_device,
     55  trace_shm_device,
    5456  trace_stack_device,
    5557  trace_register_device,
    5658  trace_vm_device,
  • sim/ppc/hw_sem.c

    diff -Naur gdb-6.8.orig/sim/ppc/hw_sem.c gdb-6.8-rtems4.10-20090312/sim/ppc/hw_sem.c
    old new  
     1/*  This file is part of the program psim.
     2
     3    Copyright (C) 1997,2008, Joel Sherrill <joel@OARcorp.com>
     4
     5    This program is free software; you can redistribute it and/or modify
     6    it under the terms of the GNU General Public License as published by
     7    the Free Software Foundation; either version 2 of the License, or
     8    (at your option) any later version.
     9
     10    This program is distributed in the hope that it will be useful,
     11    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13    GNU General Public License for more details.
     14 
     15    You should have received a copy of the GNU General Public License
     16    along with this program; if not, write to the Free Software
     17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     18 
     19    */
     20
     21
     22#ifndef _HW_SEM_C_
     23#define _HW_SEM_C_
     24
     25#include "device_table.h"
     26
     27#ifdef HAVE_STRING_H
     28#include <string.h>
     29#else
     30#ifdef HAVE_STRINGS_H
     31#include <strings.h>
     32#endif
     33#endif
     34
     35#include <sys/ipc.h>
     36#include <sys/sem.h>
     37
     38#include <errno.h>
     39
     40/* DEVICE
     41
     42
     43   sem - provide access to a unix semaphore
     44
     45
     46   DESCRIPTION
     47
     48
     49   This device implements an interface to a unix semaphore.
     50
     51
     52   PROPERTIES
     53
     54
     55   reg = <address> <size> (required)
     56
     57   Determine where the memory lives in the parents address space.
     58
     59   key = <integer> (required)
     60
     61   This is the key of the unix semaphore.
     62
     63   EXAMPLES
     64
     65
     66   Enable tracing of the sem:
     67
     68   |  bash$ psim -t sem-device \
     69
     70
     71   Configure a UNIX semaphore using key 0x12345678 mapped into psim
     72   address space at 0xfff00000:
     73
     74   |  -o '/sem@0xfff00000/reg 0xfff00000 0x80000' \
     75   |  -o '/sem@0xfff00000/key 0x12345678' \
     76
     77   sim/ppc/run -o '/#address-cells 1' \
     78         -o '/sem@0xc0000000/reg 0xc0000000 0x80000' \
     79         -o '/sem@0xc0000000/key 0x12345678' ../psim-hello/hello
     80
     81   REGISTERS
     82
     83   offset 0 - lock count
     84   offset 4 - lock operation
     85   offset 8 - unlock operation
     86
     87   All reads return the current or resulting count.
     88
     89   BUGS
     90
     91   None known.
     92
     93   */
     94
     95typedef struct _hw_sem_device {
     96  unsigned_word  physical_address;
     97  key_t          key;
     98  int            id;
     99  int            initial;
     100  int            count;
     101} hw_sem_device;
     102
     103static void
     104hw_sem_init_data(device *me)
     105{
     106  hw_sem_device *sem = (hw_sem_device*)device_data(me);
     107  const device_unit *d;
     108  int status;
     109#if !HAS_UNION_SEMUN
     110        union semun {
     111          int val;
     112          struct semid_ds *buf;
     113          unsigned short int *array;
     114#if defined(__linux__)
     115          struct seminfo *__buf;
     116#endif
     117        } ;
     118#endif
     119  union semun help;
     120
     121  /* initialize the properties of the sem */
     122
     123  if (device_find_property(me, "key") == NULL)
     124    error("sem_init_data() required key property is missing\n");
     125
     126  if (device_find_property(me, "value") == NULL)
     127    error("sem_init_data() required value property is missing\n");
     128
     129  sem->key = (key_t) device_find_integer_property(me, "key");
     130  DTRACE(sem, ("semaphore key (%d)\n", sem->key) );
     131
     132  sem->initial = (int) device_find_integer_property(me, "value");
     133  DTRACE(sem, ("semaphore initial value (%d)\n", sem->initial) );
     134
     135  d = device_unit_address(me);
     136  sem->physical_address = d->cells[ d->nr_cells-1 ];
     137  DTRACE(sem, ("semaphore physical_address=0x%x\n", sem->physical_address));
     138
     139  /* Now to initialize the semaphore */
     140
     141  if ( sem->initial != -1 ) {
     142
     143    sem->id = semget(sem->key, 1, IPC_CREAT | 0660);
     144    if (sem->id == -1)
     145      error("hw_sem_init_data() semget failed\n");
     146
     147    help.val = sem->initial;
     148    status = semctl( sem->id, 0, SETVAL, help );
     149    if (status == -1)
     150      error("hw_sem_init_data() semctl -- set value failed\n");
     151
     152  } else {
     153    sem->id = semget(sem->key, 1, 0660);
     154    if (sem->id == -1)
     155      error("hw_sem_init_data() semget failed\n");
     156  }
     157
     158  sem->count = semctl( sem->id, 0, GETVAL, help );
     159  if (sem->count == -1)
     160    error("hw_sem_init_data() semctl -- get value failed\n");
     161  DTRACE(sem, ("semaphore OS value (%d)\n", sem->count) );
     162
     163  if (sizeof(int) != 4)
     164    error("hw_sem_init_data() typing problem\n");
     165}
     166
     167static void
     168hw_sem_attach_address_callback(device *me,
     169                                attach_type attach,
     170                                int space,
     171                                unsigned_word addr,
     172                                unsigned nr_bytes,
     173                                access_type access,
     174                                device *client) /*callback/default*/
     175{
     176  hw_sem_device *sem = (hw_sem_device*)device_data(me);
     177
     178  if (space != 0)
     179    error("sem_attach_address_callback() invalid address space\n");
     180
     181  if (nr_bytes == 12)
     182    error("sem_attach_address_callback() invalid size\n");
     183
     184  sem->physical_address = addr;
     185  DTRACE(sem, ("semaphore physical_address=0x%x\n", addr));
     186}
     187
     188static unsigned
     189hw_sem_io_read_buffer(device *me,
     190                         void *dest,
     191                         int space,
     192                         unsigned_word addr,
     193                         unsigned nr_bytes,
     194                         cpu *processor,
     195                         unsigned_word cia)
     196{
     197  hw_sem_device *sem = (hw_sem_device*)device_data(me);
     198  struct sembuf sb;
     199  int status;
     200  unsigned32 u32;
     201#if !HAS_UNION_SEMUN
     202        union semun {
     203          int val;
     204          struct semid_ds *buf;
     205          unsigned short int *array;
     206#if defined(__linux__)
     207          struct seminfo *__buf;
     208#endif
     209        } ;
     210#endif
     211  union semun help;
     212
     213  /* do we need to worry about out of range addresses? */
     214
     215  DTRACE(sem, ("semaphore read addr=0x%x length=%d\n", addr, nr_bytes));
     216
     217  if (!(addr >= sem->physical_address && addr <= sem->physical_address + 11))
     218    error("hw_sem_io_read_buffer() invalid address - out of range\n");
     219
     220  if ((addr % 4) != 0)
     221    error("hw_sem_io_read_buffer() invalid address - alignment\n");
     222
     223  if (nr_bytes != 4)
     224    error("hw_sem_io_read_buffer() invalid length\n");
     225
     226  switch ( (addr - sem->physical_address) / 4 ) {
     227
     228    case 0:  /* OBTAIN CURRENT VALUE */
     229      break;
     230
     231    case 1:  /* LOCK */
     232      sb.sem_num = 0;
     233      sb.sem_op  = -1;
     234      sb.sem_flg = 0;
     235
     236      status = semop(sem->id, &sb, 1);
     237      if (status == -1) {
     238        perror( "hw_sem.c: lock" );
     239        error("hw_sem_io_read_buffer() sem lock\n");
     240      }
     241
     242      DTRACE(sem, ("semaphore lock %d\n", sem->count));
     243      break;
     244
     245    case 2: /* UNLOCK */
     246      sb.sem_num = 0;
     247      sb.sem_op  = 1;
     248      sb.sem_flg = 0;
     249
     250      status = semop(sem->id, &sb, 1);
     251      if (status == -1) {
     252        perror( "hw_sem.c: unlock" );
     253        error("hw_sem_io_read_buffer() sem unlock\n");
     254      }
     255      DTRACE(sem, ("semaphore unlock %d\n", sem->count));
     256      break;
     257
     258    default:
     259      error("hw_sem_io_read_buffer() invalid address - unknown error\n");
     260      break;
     261  }
     262
     263  /* assume target is big endian */
     264  u32 = H2T_4(semctl( sem->id, 0, GETVAL, help ));
     265
     266  DTRACE(sem, ("semaphore OS value (%d)\n", u32) );
     267  if (u32 == 0xffffffff) {
     268    perror( "hw_sem.c: getval" );
     269    error("hw_sem_io_read_buffer() semctl -- get value failed\n");
     270  }
     271
     272  memcpy(dest, &u32, nr_bytes);
     273  return nr_bytes;
     274
     275}
     276
     277static device_callbacks const hw_sem_callbacks = {
     278  { generic_device_init_address, hw_sem_init_data },
     279  { hw_sem_attach_address_callback, }, /* address */
     280  { hw_sem_io_read_buffer, NULL }, /* IO */
     281  { NULL, }, /* DMA */
     282  { NULL, }, /* interrupt */
     283  { NULL, }, /* unit */
     284  NULL,
     285};
     286
     287static void *
     288hw_sem_create(const char *name,
     289                 const device_unit *unit_address,
     290                 const char *args)
     291{
     292  hw_sem_device *sem = ZALLOC(hw_sem_device);
     293  return sem;
     294}
     295
     296const device_descriptor hw_sem_device_descriptor[] = {
     297  { "sem", hw_sem_create, &hw_sem_callbacks },
     298  { NULL },
     299};
     300
     301#endif /* _HW_SEM_C_ */
  • sim/ppc/hw_shm.c

    diff -Naur gdb-6.8.orig/sim/ppc/hw_shm.c gdb-6.8-rtems4.10-20090312/sim/ppc/hw_shm.c
    old new  
     1/*  This file is part of the program psim.
     2
     3    Copyright (C) 1997,2008, Joel Sherrill <joel@OARcorp.com>
     4
     5    This program is free software; you can redistribute it and/or modify
     6    it under the terms of the GNU General Public License as published by
     7    the Free Software Foundation; either version 2 of the License, or
     8    (at your option) any later version.
     9
     10    This program is distributed in the hope that it will be useful,
     11    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13    GNU General Public License for more details.
     14 
     15    You should have received a copy of the GNU General Public License
     16    along with this program; if not, write to the Free Software
     17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     18 
     19    */
     20
     21
     22#ifndef _HW_SHM_C_
     23#define _HW_SHM_C_
     24
     25#include "device_table.h"
     26
     27#ifdef HAVE_STRING_H
     28#include <string.h>
     29#else
     30#ifdef HAVE_STRINGS_H
     31#include <strings.h>
     32#endif
     33#endif
     34
     35#include <sys/ipc.h>
     36#include <sys/shm.h>
     37
     38
     39/* DEVICE
     40
     41
     42   shm - map unix shared memory into psim address space
     43
     44
     45   DESCRIPTION
     46
     47
     48   This device implements an area of memory which is mapped into UNIX
     49   shared memory.
     50
     51
     52   PROPERTIES
     53
     54
     55   reg = <address> <size> (required)
     56
     57   Determine where the memory lives in the parents address space.
     58   The SHM area is assumed to be of the same length.
     59
     60   key = <integer> (required)
     61
     62   This is the key of the unix shared memory area.
     63
     64   EXAMPLES
     65
     66
     67   Enable tracing of the shm:
     68
     69   |  bash$ psim -t shm-device \
     70
     71
     72   Configure a 512 kilobytes of UNIX shared memory with the key 0x12345678
     73   mapped into psim address space at 0x0c000000.
     74
     75   |  -o '/shm@0x0c000000/reg 0x0c000000 0x80000' \
     76   |  -o '/shm@0x0c000000/key 0x12345678' \
     77
     78   sim/ppc/run -o '/#address-cells 1' \
     79         -o '/shm@0x0c000000/reg 0x0c000000 0x80000' \
     80         -o '/shm@0x0c000000/key 0x12345678' ../psim-hello/hello
     81
     82   BUGS
     83
     84   None known.
     85
     86   */
     87
     88typedef struct _hw_shm_device {
     89  unsigned_word  physical_address;
     90  char          *shm_address;
     91  unsigned       sizeof_memory;
     92  key_t          key;
     93  int            id;
     94} hw_shm_device;
     95
     96static void
     97hw_shm_init_data(device *me)
     98{
     99  hw_shm_device *shm = (hw_shm_device*)device_data(me);
     100  const device_unit *d;
     101  reg_property_spec reg;
     102  int i;
     103
     104  /* Obtain the Key Value */
     105  if (device_find_property(me, "key") == NULL)
     106    error("shm_init_data() required key property is missing\n");
     107
     108  shm->key = (key_t) device_find_integer_property(me, "key");
     109  DTRACE(shm, ("shm key (0x%08x)\n", shm->key) );
     110 
     111  /* Figure out where this memory is in address space and how long it is */
     112  if ( !device_find_reg_array_property(me, "reg", 0, &reg) )
     113    error("hw_shm_init_data() no address registered\n");
     114
     115  /* Determine the address and length being as paranoid as possible */
     116  shm->physical_address = 0xffffffff;
     117  shm->sizeof_memory = 0xffffffff;
     118
     119  for ( i=0 ; i<reg.address.nr_cells; i++ ) {
     120    if (reg.address.cells[0] == 0 && reg.size.cells[0] == 0)
     121      continue;
     122
     123    if ( shm->physical_address != 0xffffffff )
     124      device_error(me, "Only single celled address ranges supported\n");
     125
     126    shm->physical_address = reg.address.cells[i];
     127    DTRACE(shm, ("shm physical_address=0x%x\n", shm->physical_address));
     128
     129    shm->sizeof_memory = reg.size.cells[i];
     130    DTRACE(shm, ("shm length=0x%x\n", shm->sizeof_memory));
     131  }
     132
     133  if ( shm->physical_address == 0xffffffff )
     134    device_error(me, "Address not specified\n" );
     135
     136  if ( shm->sizeof_memory == 0xffffffff )
     137    device_error(me, "Length not specified\n" );
     138
     139  /* Now actually attach to or create the shared memory area */
     140  shm->id = shmget(shm->key, shm->sizeof_memory, IPC_CREAT | 0660);
     141  if (shm->id == -1)
     142    error("hw_shm_init_data() shmget failed\n");
     143
     144  shm->shm_address = shmat(shm->id, (char *)0, SHM_RND);
     145  if (shm->shm_address == (void *)-1)
     146    error("hw_shm_init_data() shmat failed\n");
     147}
     148
     149static void
     150hw_shm_attach_address_callback(device *me,
     151                                attach_type attach,
     152                                int space,
     153                                unsigned_word addr,
     154                                unsigned nr_bytes,
     155                                access_type access,
     156                                device *client) /*callback/default*/
     157{
     158  hw_shm_device *shm = (hw_shm_device*)device_data(me);
     159
     160  if (space != 0)
     161    error("shm_attach_address_callback() invalid address space\n");
     162
     163  if (nr_bytes == 0)
     164    error("shm_attach_address_callback() invalid size\n");
     165}
     166
     167
     168static unsigned
     169hw_shm_io_read_buffer(device *me,
     170                         void *dest,
     171                         int space,
     172                         unsigned_word addr,
     173                         unsigned nr_bytes,
     174                         cpu *processor,
     175                         unsigned_word cia)
     176{
     177  hw_shm_device *shm = (hw_shm_device*)device_data(me);
     178
     179  /* do we need to worry about out of range addresses? */
     180
     181  DTRACE(shm, ("read %p %x %x %x\n", \
     182     shm->shm_address, shm->physical_address, addr, nr_bytes) );
     183
     184  memcpy(dest, &shm->shm_address[addr - shm->physical_address], nr_bytes);
     185  return nr_bytes;
     186}
     187
     188
     189static unsigned
     190hw_shm_io_write_buffer(device *me,
     191                          const void *source,
     192                          int space,
     193                          unsigned_word addr,
     194                          unsigned nr_bytes,
     195                          cpu *processor,
     196                          unsigned_word cia)
     197{
     198  hw_shm_device *shm = (hw_shm_device*)device_data(me);
     199
     200  /* do we need to worry about out of range addresses? */
     201
     202  DTRACE(shm, ("write %p %x %x %x\n", \
     203     shm->shm_address, shm->physical_address, addr, nr_bytes) );
     204
     205  memcpy(&shm->shm_address[addr - shm->physical_address], source, nr_bytes);
     206  return nr_bytes;
     207}
     208
     209static device_callbacks const hw_shm_callbacks = {
     210  { generic_device_init_address, hw_shm_init_data },
     211  { hw_shm_attach_address_callback, }, /* address */
     212  { hw_shm_io_read_buffer,
     213    hw_shm_io_write_buffer }, /* IO */
     214  { NULL, }, /* DMA */
     215  { NULL, }, /* interrupt */
     216  { NULL, }, /* unit */
     217  NULL,
     218};
     219
     220static void *
     221hw_shm_create(const char *name,
     222                 const device_unit *unit_address,
     223                 const char *args)
     224{
     225  hw_shm_device *shm = ZALLOC(hw_shm_device);
     226  return shm;
     227}
     228
     229
     230
     231const device_descriptor hw_shm_device_descriptor[] = {
     232  { "shm", hw_shm_create, &hw_shm_callbacks },
     233  { NULL },
     234};
     235
     236#endif /* _HW_SHM_C_ */
  • sim/ppc/Makefile.in

    diff -Naur gdb-6.8.orig/sim/ppc/Makefile.in gdb-6.8-rtems4.10-20090312/sim/ppc/Makefile.in
    old new  
    834834hw_pal.o: hw_pal.c $(DEVICE_TABLE_H) $(CPU_H)
    835835hw_phb.o: hw_phb.c $(DEVICE_TABLE_H) $(HW_PHB_H) $(COREFILE_H)
    836836hw_register.o: hw_register.c $(DEVICE_TABLE_H) $(PSIM_H)
     837hw_sem.o: hw_sem.c $(DEVICE_TABLE_H) $(PSIM_H)
     838hw_shm.o: hw_shm.c $(DEVICE_TABLE_H) $(PSIM_H)
    837839hw_trace.o: hw_trace.c $(DEVICE_TABLE_H)
    838840hw_vm.o: hw_vm.c $(DEVICE_TABLE_H) $(CPU_H)
    839841# ignore this line, it stops make from getting confused
  • sim/ppc/ppc-instructions

    diff -Naur gdb-6.8.orig/sim/ppc/ppc-instructions gdb-6.8-rtems4.10-20090312/sim/ppc/ppc-instructions
    old new  
    34023402            case spr_dec:
    34033403              *rT = cpu_get_decrementer(processor);
    34043404              break;
     3405                case spr_tbrl:
     3406                  if (is_64bit_implementation) *rT = TB;
     3407                  else                         *rT = EXTRACTED64(TB, 32, 63);
     3408                break;
     3409                case spr_tbru:
     3410                  if (is_64bit_implementation) *rT = EXTRACTED64(TB, 0, 31);
     3411                  else                         *rT = EXTRACTED64(TB, 0, 31);
     3412                break;
    34053413            case spr_tbu:
    34063414            case spr_tbl:
    34073415              /* NOTE - these SPR's are not readable. Use mftb[ul] */
  • sim/ppc/ppc-spr-table

    diff -Naur gdb-6.8.orig/sim/ppc/ppc-spr-table gdb-6.8-rtems4.10-20090312/sim/ppc/ppc-spr-table
    old new  
    3232SRR0:26:0:0
    3333SRR1:27:0:0
    3434VRSAVE:256:0:0
     35TBRL:268:0:0
     36TBRU:269:0:0
    3537SPRG0:272:0:0
    3638SPRG1:273:0:0
    3739SPRG2:274:0:0
Note: See TracBrowser for help on using the repository browser.