From 4d51ef6fa6938887cad1748011a509792a59fcd5 Mon Sep 17 00:00:00 2001 From: hanjinpeng Date: Wed, 6 Dec 2023 17:38:05 +0800 Subject: [PATCH] fix gdb debug hashamp bucket counts and entry sizes issue --- ...rs-for-bucket-counts-and-entry-sizes.patch | 46 +++++++++++++++++++ systemd.spec | 6 ++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 backport-gdb-update-accessors-for-bucket-counts-and-entry-sizes.patch diff --git a/backport-gdb-update-accessors-for-bucket-counts-and-entry-sizes.patch b/backport-gdb-update-accessors-for-bucket-counts-and-entry-sizes.patch new file mode 100644 index 0000000..538d6db --- /dev/null +++ b/backport-gdb-update-accessors-for-bucket-counts-and-entry-sizes.patch @@ -0,0 +1,46 @@ +From 3aff6c79170717478ba89bb1a3b8bb2063adc735 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Wed, 27 May 2020 11:37:58 +0200 +Subject: [PATCH] gdb: update accessors for bucket counts and entry sizes + +Afaict, this code never worked, since even when this code was added in +2ea8c08306c7e33f8217a878cf990fc491c9432c, neither all_entry_sizes nor +all_direct_buckets were defined. +--- + tools/gdb-sd_dump_hashmaps.py | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/tools/gdb-sd_dump_hashmaps.py b/tools/gdb-sd_dump_hashmaps.py +index 4e8593f..6933d2d 100644 +--- a/tools/gdb-sd_dump_hashmaps.py ++++ b/tools/gdb-sd_dump_hashmaps.py +@@ -13,8 +13,7 @@ class sd_dump_hashmaps(gdb.Command): + + def invoke(self, arg, from_tty): + d = gdb.parse_and_eval("hashmap_debug_list") +- all_entry_sizes = gdb.parse_and_eval("all_entry_sizes") +- all_direct_buckets = gdb.parse_and_eval("all_direct_buckets") ++ hashmap_type_info = gdb.parse_and_eval("hashmap_type_info") + uchar_t = gdb.lookup_type("unsigned char") + ulong_t = gdb.lookup_type("unsigned long") + debug_offset = gdb.parse_and_eval("(unsigned long)&((HashmapBase*)0)->debug") +@@ -30,14 +29,14 @@ class sd_dump_hashmaps(gdb.Command): + else: + storage_ptr = h["direct"]["storage"].cast(uchar_t.pointer()) + n_entries = h["n_direct_entries"] +- n_buckets = all_direct_buckets[int(h["type"])]; ++ n_buckets = hashmap_type_info[h["type"]]["n_direct_buckets"] + + t = ["plain", "ordered", "set"][int(h["type"])] + + print("{}, {}, {}, {}, {}, {}, {} ({}:{})".format(t, h["hash_ops"], bool(h["has_indirect"]), n_entries, d["max_entries"], n_buckets, d["func"], d["file"], d["line"])) + + if arg != "" and n_entries > 0: +- dib_raw_addr = storage_ptr + (all_entry_sizes[h["type"]] * n_buckets) ++ dib_raw_addr = storage_ptr + hashmap_type_info[h["type"]]["entry_size"] * n_buckets + + histogram = {} + for i in xrange(0, n_buckets): +-- +2.27.0 + diff --git a/systemd.spec b/systemd.spec index a3e4dbb..2208163 100644 --- a/systemd.spec +++ b/systemd.spec @@ -16,7 +16,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 243 -Release: 63 +Release: 64 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -213,6 +213,7 @@ Patch0165: backport-pid1-fix-segv-triggered-by-status-query.patch Patch0166: backport-main-log-which-process-send-SIGNAL-to-PID1.patch Patch0167: backport-main-drop-get_process_cmdline-from-crash-handler.patch Patch0168: backport-conf-parser-fix-line-number-in-error-message.patch +Patch0169: backport-gdb-update-accessors-for-bucket-counts-and-entry-sizes.patch #openEuler Patch9002: 1509-fix-journal-file-descriptors-leak-problems.patch @@ -1620,6 +1621,9 @@ fi %exclude /usr/share/man/man3/* %changelog +* Wed Dec 6 2023 hanjinpeng - 243-64 +- fix gdb debug hashmap bucket counts and entry sizes issue + * Tue Dec 5 2023 huyubiao - 243-63 - sync community patches: fix line number in conf_parser error message -- Gitee