This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


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

RE: [RFA] Add la_getstr member to language_defn


  Hi Thiago,

  I just wrote a pascal version of your c_get_string,
which basically calls c_get_string but also handles
Pascal string types specifically.

  The problem is that I found no reference to 
this la_get_string in the code yet, so that I am
unable to really check if my patch is correct.

  Is this in some submitted patch for python
or isn't it ready for submission yet?
Could you please send me a pointer to that patch?


Pierre Muller
Pascal language support maintainer for GDB


This is the function I wrote:


static void
pascal_get_string (struct value *value, gdb_byte **buffer, int *length,
              const char **charset)
{
  int err, width;
  unsigned int fetchlimit;
  struct type *type = check_typedef (value_type (value));
  struct type *element_type;
  int length_pos, length_size, string_pos;

  if (is_pascal_string_type (type, &length_pos, &length_size,
                             &string_pos, &width, NULL))
    {
      CORE_ADDR addr = value_as_address (value);
      ULONGEST string_length;
      *buffer = xmalloc (length_size);
      if (target_read_memory (addr + length_pos, *buffer, length_size)
          == length_size)
        {
          string_length = extract_unsigned_integer (*buffer, length_size);
          xfree (*buffer);
          *buffer = xmalloc (length_size * width);
          fetchlimit = string_length;
          err = read_string (addr + string_pos, string_length,
                             width, fetchlimit, buffer, length);
          *charset = target_charset ();
        }
      else
        err = 1;
      if (err)
        {
          xfree (*buffer);
          error (_("Error reading pascal string from inferior: %s"),
                 safe_strerror (err));
        }
      return;
    }
  else
    c_get_string (value, buffer, length, charset);
}


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