mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: linux-kernel@vger.kernel.org
Cc: Jason Wessel <jason.wessel@windriver.com>,
	kgdb-bugreport@lists.sourceforge.net
Subject: [PATCH 04/13] scripts/gdb: Add get_target_endianness helper
Date: Wed,  3 Oct 2012 13:21:35 +0200	[thread overview]
Message-ID: <4f794cfb44b8c19fe97333677d89018b023be341.1349263293.git.jan.kiszka@web.de> (raw)
In-Reply-To: <cover.1349263293.git.jan.kiszka@web.de>
In-Reply-To: <cover.1349263293.git.jan.kiszka@web.de>

From: Jan Kiszka <jan.kiszka@siemens.com>

Parse the target endianness from the output of "show endian" and cache
the result to return it via the new helper get_target_endiannes. We will
need it for reading integers from buffers that contain target memory.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 scripts/gdb/utils.py |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/scripts/gdb/utils.py b/scripts/gdb/utils.py
index f770c5c..40356d9 100644
--- a/scripts/gdb/utils.py
+++ b/scripts/gdb/utils.py
@@ -53,3 +53,20 @@ class ContainerOf(gdb.Function):
 				    elementname.string())
 
 ContainerOf()
+
+
+BIG_ENDIAN = 0
+LITTLE_ENDIAN = 1
+target_endianness = None
+
+def get_target_endianness():
+	global target_endianness
+	if target_endianness == None:
+		endian = gdb.execute("show endian", False, True)
+		if endian.find("little endian") >= 0:
+			target_endianness = LITTLE_ENDIAN
+		elif endian.find("big endian") >= 0:
+			target_endianness = BIG_ENDIAN
+		else:
+			raise gdb.GdgError("unknown endianness '%s'" % endian)
+	return target_endianness
-- 
1.7.3.4


  parent reply	other threads:[~2012-10-03 11:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-03 11:21 [PATCH 00/13] Add gdb python scripts as kernel debugging helpers Jan Kiszka
2012-10-03 11:21 ` [PATCH 01/13] scripts/gdb: Add infrastructure Jan Kiszka
2012-10-03 11:21 ` [PATCH 02/13] scripts/gdb: Add container_of helper and convenience function Jan Kiszka
2012-10-03 11:21 ` [PATCH 03/13] scripts/gdb: Add lx-symbols command Jan Kiszka
2012-10-03 11:21 ` Jan Kiszka [this message]
2012-10-03 11:21 ` [PATCH 05/13] scripts/gdb: Add read_u16/32/64 helpers Jan Kiszka
2012-10-03 11:21 ` [PATCH 06/13] scripts/gdb: Add lx-dmesg command Jan Kiszka
2012-10-03 12:16   ` Andi Kleen
2012-10-03 13:04     ` Jan Kiszka
2012-10-03 11:21 ` [PATCH 07/13] scripts/gdb: Add task iteration helper Jan Kiszka
2012-10-03 11:21 ` [PATCH 08/13] scripts/gdb: Add helper and convenience function to look up tasks Jan Kiszka
2012-10-03 11:21 ` [PATCH 09/13] scripts/gdb: Add is_target_arch helper Jan Kiszka
2012-10-03 11:21 ` [PATCH 10/13] scripts/gdb: Add internal helper and convenience function to retrieve thread_info Jan Kiszka
2012-10-03 11:21 ` [PATCH 11/13] scripts/gdb: Add get_gdbserver_type helper Jan Kiszka
2012-10-03 11:21 ` [PATCH 12/13] scripts/gdb: Add internal helper and convenience function for per-cpu lookup Jan Kiszka
2012-10-03 11:21 ` [PATCH 13/13] scripts/gdb: Add lx_current convenience function Jan Kiszka
2012-11-05 16:08 [PATCH 00/13] Add gdb python scripts as kernel debugging helpers Jan Kiszka
2012-11-05 16:08 ` [PATCH 04/13] scripts/gdb: Add get_target_endianness helper Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f794cfb44b8c19fe97333677d89018b023be341.1349263293.git.jan.kiszka@web.de \
    --to=jan.kiszka@web.de \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®