public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/31743] New: <repeats N times> is confusing inside a python pretty printer
@ 2024-05-16  9:16 jwakely.gcc at gmail dot com
  2024-05-16  9:21 ` [Bug python/31743] " jwakely.gcc at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jwakely.gcc at gmail dot com @ 2024-05-16  9:16 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 31743
           Summary: <repeats N times> is confusing inside a python pretty
                    printer
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: jwakely.gcc at gmail dot com
  Target Milestone: ---

#include <vector>
int
main()
{
  std::vector<const char*> v;
  v.emplace_back("=================================== 
=============================\n");
  v.emplace_back("abcdefghijklmnopqrstuvwxyz\n");
  return 0;
}

$ gdb -q -ex start -ex "n 3" -ex "p v" -ex cont -ex q a.out
Reading symbols from a.out...
Temporary breakpoint 1 at 0x40119f: file s.cc, line 6.
Starting program: /tmp/a.out 
[Thread debugging using libthread_db enabled]                                   
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main () at s.cc:6
6         std::vector<const char*> v;
9         return 0;
$1 = std::vector of length 2, capacity 2 = {0x402010 '=' <repeats 35 times>, " 
", '=' <repeats 29 times>, "\n", 0x402054 "abcdefghijklmnopqrstuvwxyz\n"}
Continuing.
[Inferior 1 (process 634451) exited normally]

This output is very confusing, as we have commas inserted before/after the
<repeats...> text which get confused with the commas between the vector
elements.

It's worse for a vector<string> or vector<string_view> because we don't even
get the const char* addresses like 0x402010 as delimiters between elements:

#include <vector>
#include <string_view>
int
main()
{
  std::vector<std::string_view> v;
  v.emplace_back("=================================== 
=============================\n");
  v.emplace_back("abcdefghijklmnopqrstuvwxyz\n");
  return 0;
}

$ gdb -q -ex start -ex "n 3" -ex "p v" -ex cont -ex q a.out
Reading symbols from a.out...
Temporary breakpoint 1 at 0x40119f: file s.cc, line 6.
Starting program: /tmp/a.out 
[Thread debugging using libthread_db enabled]                                   
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main () at s.cc:6
6         std::vector<std::string_view> v;
9         return 0;
$1 = std::vector of length 2, capacity 2 = {'=' <repeats 35 times>, "  ", '='
<repeats 29 times>, "\n", "abcdefghijklmnopqrstuvwxyz\n"}
Continuing.
[Inferior 1 (process 634576) exited normally]


It takes quite a lot of effort to see that this is all part of the same v[0]
object:

'=' <repeats 35 times>, "  ", '=' <repeats 29 times>, "\n"

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-16 14:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-16  9:16 [Bug python/31743] New: <repeats N times> is confusing inside a python pretty printer jwakely.gcc at gmail dot com
2024-05-16  9:21 ` [Bug python/31743] " jwakely.gcc at gmail dot com
2024-05-16  9:21 ` jwakely.gcc at gmail dot com
2024-05-16  9:33 ` jwakely.gcc at gmail dot com
2024-05-16  9:34 ` [Bug python/31743] Strings containing <repeats N times> are " jwakely.gcc at gmail dot com
2024-05-16  9:37 ` drepper.fsp at gmail dot com
2024-05-16 14:25 ` ssbssa at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).