You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2019/10/11 00:58:22 UTC
[mynewt-core] 04/04: stat.gdb: gdb scripts for stats debugging
This is an automated email from the ASF dual-hosted git repository.
ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 7b824caf6510e465158b91c1c191f295b77c58bf
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Thu Oct 10 15:34:08 2019 -0700
stat.gdb: gdb scripts for stats debugging
---
compiler/gdbmacros/stat.gdb | 69 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/compiler/gdbmacros/stat.gdb b/compiler/gdbmacros/stat.gdb
new file mode 100644
index 0000000..047b3b8
--- /dev/null
+++ b/compiler/gdbmacros/stat.gdb
@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+define mn_stat_print
+ set $shdr = $arg0
+ printf "<%s>\n", $shdr->s_name
+
+ set $idx = 0
+ while $idx < $shdr->s_cnt
+ set $name_entry = &$shdr->s_map[$idx]
+ set $val_addr = (uint8_t *)$shdr + $name_entry->snm_off
+
+ # No "else if" chains in gdb; simplify to avoid nesting.
+ if $shdr->s_size == 1
+ set $val = *(uint8_t *)$val_addr
+ end
+ if $shdr->s_size == 2
+ set $val = *(uint16_t *)$val_addr
+ end
+ if $shdr->s_size == 4
+ set $val = *(uint32_t *)$val_addr
+ end
+
+ printf "%s: %llu\n", $name_entry->snm_name, (unsigned long long)$val
+
+ set $idx++
+ end
+end
+
+document mn_stat_print
+usage: mn_stat_print <struct stats_hdr *>
+
+Prints the stats group with the specified header.
+
+Note: Requires MYNEWT_VAL(STATS_NAMES) to be enabled.
+end
+
+define mn_stat_print_all
+ set $cur = g_stats_registry.stqh_first
+ while $cur != 0
+ mn_stat_print $cur
+ set $cur = $cur->s_next.stqe_next
+
+ if $cur != 0
+ printf "\n"
+ end
+ end
+end
+
+
+document mn_stat_print_all
+usage: mn_stat_print_all
+
+Prints all registered stats groups.
+end