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 2016/11/25 00:53:30 UTC

incubator-mynewt-core git commit: Some gdb scripts.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 1ad17c8c9 -> d36a40391


Some gdb scripts.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d36a4039
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d36a4039
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d36a4039

Branch: refs/heads/develop
Commit: d36a403913f18baa51b50103b8ae5f7d418460db
Parents: 1ad17c8
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 24 16:55:14 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 24 16:55:31 2016 -0800

----------------------------------------------------------------------
 compiler/gdbmacros/ble.gdb   |  52 ++++++++++++
 compiler/gdbmacros/mbuf.gdb  | 166 ++++++++++++++++++++++++++++++++++++++
 compiler/gdbmacros/queue.gdb |  71 ++++++++++++++++
 3 files changed, 289 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d36a4039/compiler/gdbmacros/ble.gdb
----------------------------------------------------------------------
diff --git a/compiler/gdbmacros/ble.gdb b/compiler/gdbmacros/ble.gdb
new file mode 100644
index 0000000..434c7ba
--- /dev/null
+++ b/compiler/gdbmacros/ble.gdb
@@ -0,0 +1,52 @@
+# 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_ble_opcode_parse
+    set $opcode = (uint16_t)($arg0)
+    set $ogf = ($opcode & 0xff00) >> 10
+    set $ocf = $opcode & 0x00ff
+
+    printf "ogf=0x%02x ocf=0x%02x\n", $ogf, $ocf
+end
+
+document mn_ble_opcode_parse
+usage: mn_ble_opcode_parse <uint16_t hci-opcode>
+
+Parses a 16-bit HCI opcode, displaying its OGF and OCF components.  The opcode
+must be in little endian format.
+end
+
+define mn_gattc_procs_print
+    if $argc == 0
+        set $proc_list = &ble_gattc_procs
+    else
+        set $proc_list = ($arg0)
+    end
+
+    set $cur = $proc_list->stqh_first
+    while $cur != 0
+        printf "proc (%p): op=%d\n", $cur, $cur->op
+        set $cur = $cur->next.stqe_next
+    end
+end
+
+document mn_gattc_procs_print
+usage: mn_gattc_procs_print [struct ble_gattc_proc_list *proc-list]
+
+Prints the currently-active GATT client procedures.  The proc-list parameter is
+optional; by default, the standard list is read.
+end

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d36a4039/compiler/gdbmacros/mbuf.gdb
----------------------------------------------------------------------
diff --git a/compiler/gdbmacros/mbuf.gdb b/compiler/gdbmacros/mbuf.gdb
new file mode 100644
index 0000000..662cb52
--- /dev/null
+++ b/compiler/gdbmacros/mbuf.gdb
@@ -0,0 +1,166 @@
+# 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_mqueue_print
+    set $cur = ($arg0)->mq_head.stqh_first
+
+    while $cur != 0
+        printf "[entry %p]\n", $cur
+        p/x *$cur
+
+        set $cur = $cur->omp_next.stqe_next
+    end
+end
+
+document mn_mqueue_print
+usage: mn_mqueue_print <struct os_mqueue *>
+
+Prints the contents of the specified mqueue.
+end
+
+define mn_mbuf_pkthdr_print
+    # Calculate address of packet header.
+    set $data_addr = (uint8_t *)&($arg0)->om_data
+    set $hdr_addr = $data_addr + sizeof(struct os_mbuf)
+
+    # Convert the address to a pointer of the correct type.
+    set $pkthdr = (struct os_mbuf_pkthdr *)$hdr_addr
+
+    # Print header.
+    p *$pkthdr
+end
+
+document mn_mbuf_pkthdr_print
+usage: mn_mbuf_pkthdr_print <struct os_mbuf *>
+
+Prints the packet header associated with the specified mbuf.  If the specified
+mbuf does not contain a packet header, the output is indeterminate.
+end
+
+define mn_mbuf_print
+    set $om = (struct os_mbuf *)($arg0)
+
+    printf "Mbuf header: "
+    p *$om
+
+    if ($om)->om_pkthdr_len > 0
+        printf "Packet header: "
+        mn_mbuf_pkthdr_print $om
+    end
+end
+
+document mn_mbuf_print
+usage mn_mbuf_print <struct os_mbuf *>
+
+Prints the following information about the specified mbuf:
+    * mbuf header
+    * mbuf packet header (if present).
+end
+
+define mn_mbuf_dump
+    set $om = (struct os_mbuf *)($arg0)
+    mn_mbuf_print $om
+
+    printf "Mbuf data: "
+    set $len = ($om)->om_len
+    p/x *$om->om_data@$len
+end
+
+document mn_mbuf_dump
+usage mn_mbuf_dump <struct os_mbuf *>
+
+Prints the following information about the specified mbuf:
+    * mbuf header
+    * mbuf packet header (if present).
+    * mbuf data contents
+end
+
+define mn_mbuf_chain_print
+    set $totlen = 0
+    set $om = ($arg0)
+    while $om != 0
+        printf "Mbuf addr: %p\n", $om
+        mn_mbuf_print $om
+        set $totlen += $om->om_len
+        set $om = $om->om_next.sle_next
+    end
+
+    printf "total length: %d\n", $totlen
+end
+
+document mn_mbuf_chain_print
+usage mn_mbuf_chain_print <struct os_mbuf *>
+
+Applies the mn_mbuf_print function to each buffer in the specified mbuf chain.
+That is, this function prints the following information about each mbuf:
+    * mbuf header
+    * mbuf packet header (if present).
+end
+
+define mn_mbuf_chain_dump
+    set $totlen = 0
+    set $om = ($arg0)
+    while $om != 0
+        printf "Mbuf addr: %p\n", $om
+        mn_mbuf_dump $om
+        set $totlen += $om->om_len
+        set $om = $om->om_next.sle_next
+    end
+
+    printf "total length: %d\n", $totlen
+end
+
+document mn_mbuf_chain_dump
+usage mn_mbuf_chain_dump <struct os_mbuf *>
+
+Applies the mn_mbuf_dump function to each buffer in the specified mbuf chain.
+That is, this function prints the following information about each mbuf:
+    * mbuf header
+    * mbuf packet header (if present).
+    * mbuf data contents
+end
+
+define mn_mbuf_pool_print
+    set $pool = ($arg0)
+    set $om = (struct os_mbuf *)$pool->omp_pool.mp_membuf_addr
+    set $elem_size = $pool->omp_databuf_len + sizeof (struct os_mbuf)
+    set $end = (uint8_t *)$om + $pool->omp_mbuf_count * $elem_size
+
+    while $om < $end
+        printf "Mbuf addr: %p\n", $om
+        mn_mbuf_print $om
+        set $om = (struct os_mbuf *)((uint8_t *)$om + $elem_size)
+    end
+end
+
+document mn_mbuf_pool_print
+usage: mn_mbuf_pool_print <struct os_mbuf_pool *>
+
+Applies the mn_mbuf_print function to each element in the specified pool.  Both
+allocated and unallocated mbufs are printed.
+end
+
+document mn_mbuf_pool_print
+usage: mn_msys1_print
+
+Prints all mbufs in the first msys pool.  Both allocated and unallocated mbufs
+are printed.
+end
+
+define mn_msys1_print
+    mn_mbuf_pool_print &os_msys_init_1_mbuf_pool 
+end

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d36a4039/compiler/gdbmacros/queue.gdb
----------------------------------------------------------------------
diff --git a/compiler/gdbmacros/queue.gdb b/compiler/gdbmacros/queue.gdb
new file mode 100644
index 0000000..601d7d7
--- /dev/null
+++ b/compiler/gdbmacros/queue.gdb
@@ -0,0 +1,71 @@
+# 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.
+
+set $MN_MAX_ENTRIES_DFLT = 100
+
+define mn_gen_queue_print
+    set $cur = ($arg0)
+    set $next_off = ($arg1)
+
+    if $argc < 3
+        set $max_entries = $MN_MAX_ENTRIES_DFLT
+    else
+        set $max_entries = ($arg2)
+    end
+    if $max_entries <= 0
+        set $max_entries = -1
+    end
+
+    set $count = 0
+    while $cur != 0 && $count != $max_entries
+        printf "[entry %p]\n", $cur
+        set $cur = *((uint32_t *)((uint8_t *)$cur) + ($arg1))
+
+        set $count++
+    end
+end
+
+document mn_gen_queue_print
+usage mn_gen_queue_print <void *first-entry> <int next-offset> <int max-entries>
+
+Prints the address of each entry in the specified queue.
+    first-elem: an entry belonging to a queue; contains a 'next' pointer.
+    next-offset: the offset of the next-pointer field within first-elem.
+    max-elems: the maximum number of entries to print; 0 means no limit;
+               dflt=100.
+end
+
+define mn_slist_print
+    set $head = ($arg0)->slh_first
+    if $argc < 2
+        set $max_entries = $MN_MAX_ENTRIES_DFLT
+    else
+        set $max_entries = ($arg2)
+    end
+
+    mn_gen_queue_print $head ($arg1) $max_entries
+end
+
+document mn_slist_print
+usage mn_slist_print <SLIST_HEAD *slist> <int next-offset> <int max-entries>
+
+Prints the address of each entry in the specified slist.
+    slist: an slist struct created with the SLIST_HEAD macro.
+    next-offset: the offset of the next-pointer field within each entry.
+    max-elems: the maximum number of entries to print; 0 means no limit;
+               dflt=100.
+end