This is the mail archive of the gdb-prs@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]

[Bug python/20786] New: lazy strings of user-specified length zero do not work


https://sourceware.org/bugzilla/show_bug.cgi?id=20786

            Bug ID: 20786
           Summary: lazy strings of user-specified length zero do not work
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: dje at google dot com
  Target Milestone: ---

Given

const char *ptr = "abc";

this

(gdb) py print gdb.parse_and_eval("ptr").lazy_string(length=0).value()

should print "", I think, but that's not what gdb currently does.

One problem is representing an array of length 0 in C in gdb.
At least some parts of gdb cannot handle it.

Ada supports zero length arrays via high_bound < low_bound.
One thought is to generalize the support.
Code like this in create_array_type_with_stride will need to be dealt with:

  /* TYPE_TARGET_STUB will take care of zero length arrays.  */
  if (TYPE_LENGTH (result_type) == 0)
    TYPE_TARGET_STUB (result_type) = 1;

And this in c_val_print_array:

  if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
    ...;
  else
    /* Array of unspecified length: treat like pointer to first elt.  */

[one can argue this should be filed under something under than python since
some underlying general gdb support needs to be fixed first. whatever.
bugzilla didn't find an equivalent bug on this, though there could be one of
course.]

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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