diff options
| author | Johannes Altmanninger <aclopte@gmail.com> | 2025-05-10 21:13:09 +0200 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2025-05-11 09:57:01 +1000 |
| commit | 7c3efe3b92816697383c5792d7876e7ed6e331ae (patch) | |
| tree | 019a020da99685b0ff9c40d06c2dfa7c47501a4b | |
| parent | dedbc2179cdb8f287b042462de040d125ae796b2 (diff) | |
Update GDB pretty printer following SSO layout change
Commit 2754e27cf (Increase SSO from 22 to 23 chars., 2024-06-07) changed
they layout of SSO-strings. Specifically, is_long() no longer takes a bit
away from the size field.
Update the GDB pretty printer accordingly, making it work with small strings
again.
| -rw-r--r-- | gdb/kakoune.py | 15 | ||||
| -rw-r--r-- | src/string.hh | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/gdb/kakoune.py b/gdb/kakoune.py index 726fc05a..6988e562 100644 --- a/gdb/kakoune.py +++ b/gdb/kakoune.py @@ -85,13 +85,16 @@ class String: self.val = val def to_string(self): - data = self.val["m_data"] - if (data["u"]["s"]["size"] & 1) != 1: - ptr = data["u"]["l"]["ptr"] - len = data["u"]["l"]["size"] + data_u = self.val["m_data"]["u"] + long = data_u["l"] + short = data_u["s"] + if (long["mode"] & long["active_mask"]) != 0: + ptr = long["ptr"] + len = long["size"] else: - ptr = data["u"]["s"]["string"] - len = data["u"]["s"]["size"] >> 1 + ptr = short["string"] + short_capacity = short + len = short["capacity"] - short["remaining_size"] return "\"%s\"" % (ptr.string("utf-8", "ignore", len)) diff --git a/src/string.hh b/src/string.hh index 677f01f5..fd1e5b74 100644 --- a/src/string.hh +++ b/src/string.hh @@ -184,7 +184,7 @@ public: Data& operator=(const Data& other); Data& operator=(Data&& other) noexcept; - bool is_long() const { return (u.l.mode& Long::active_mask) > 0; } + bool is_long() const { return (u.l.mode & Long::active_mask) != 0; } size_t size() const { return is_long() ? u.l.size : (Short::capacity - u.s.remaining_size); } size_t capacity() const { return is_long() ? u.l.capacity : Short::capacity; } |
