public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: tromey@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  archer-tromey-multi-breakpoint-2: added $_strcmp and $_memcmp
Date: Wed, 09 Feb 2011 15:11:00 -0000	[thread overview]
Message-ID: <20110209151125.5279.qmail@sourceware.org> (raw)

The branch, archer-tromey-multi-breakpoint-2 has been updated
       via  4aabb4b780d0cd66dce3621f4c93e146e150d618 (commit)
      from  b1516d990e344bd827028ad11032eb89cf530e5d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 4aabb4b780d0cd66dce3621f4c93e146e150d618
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Feb 9 08:11:17 2011 -0700

    added $_strcmp and $_memcmp

-----------------------------------------------------------------------

Summary of changes:
 gdb/data-directory/Makefile.in        |    3 +-
 gdb/python/lib/gdb/__init__.py        |    1 +
 gdb/python/lib/gdb/function/strcmp.py |   67 +++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 1 deletions(-)
 create mode 100644 gdb/python/lib/gdb/function/strcmp.py

First 500 lines of diff:
diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
index 64c5bfe..596ca62 100644
--- a/gdb/data-directory/Makefile.in
+++ b/gdb/data-directory/Makefile.in
@@ -60,7 +60,8 @@ PYTHON_FILES = \
 	gdb/command/__init__.py \
 	gdb/command/multi.py \
 	gdb/command/pretty_printers.py \
-	gdb/command/prompt.py
+	gdb/command/prompt.py \
+	gdb/function/strcmp.py
 
 FLAGS_TO_PASS = \
 	"prefix=$(prefix)" \
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index d433110..0b15521 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -16,5 +16,6 @@
 import gdb.command.pretty_printers
 import gdb.command.multi
 import gdb.command.prompt
+import gdb.function.strcmp
 
 gdb.command.pretty_printers.register_pretty_printer_commands()
diff --git a/gdb/python/lib/gdb/function/strcmp.py b/gdb/python/lib/gdb/function/strcmp.py
new file mode 100644
index 0000000..dc7dd2d
--- /dev/null
+++ b/gdb/python/lib/gdb/function/strcmp.py
@@ -0,0 +1,67 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import gdb
+
+class Strcmp(gdb.Function):
+    """A string-comparison function like C's strcmp.
+Usage: $_strcmp (STR1, STR2, [LEN])
+With two arguments, compare strings until a terminating NUL character.
+Return a negative value if STR1 is less than STR2, a positive
+value if STR1 is greater than STR2, or zero if STR1 and STR2 are equal.
+LEN, if specified, is the maximum number of characters to compare."""
+
+    def __init__(self):
+        super(Strcmp, self).__init__('_strcmp')
+
+    def invoke(self, s1, s2, len = None):
+        i = 0
+        while len is None or i < len:
+            c1 = s1[i]
+            c2 = s2[i]
+            if c1 < c2:
+                return -1
+            elif c1 > c2:
+                return 1
+            elif c1 == 0:
+                return 0
+            i = i + 1
+        return 0
+
+class Memcmp(gdb.Function):
+    """A memory-comparison function like C's memcmp.
+Usage: $_memcmp (MEM1, MEM2, LEN)
+Bytewise compare two regions of memory.  Return a negative value if
+MEM1 is less than MEM2, a positive value if MEM1 is greater than MEM2,
+or zero if MEM1 and MEM2 are equal.  LEN is the maximum number of
+bytes to compare."""
+
+    def __init__(self):
+        super(Memcmp, self).__init__('_memcmp')
+
+    def invoke(self, s1, s2, len):
+        i = 0
+        while i < len:
+            c1 = s1[i]
+            c2 = s2[i]
+            if c1 < c2:
+                return -1
+            elif c1 > c2:
+                return 1
+            i = i + 1
+        return 0
+
+Strcmp()
+Memcmp()


hooks/post-receive
--
Repository for Project Archer.


                 reply	other threads:[~2011-02-09 15:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20110209151125.5279.qmail@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=archer-commits@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).