summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2003-11-07 16:30:26 +0000
committerMark Kettenis <kettenis@gnu.org>2003-11-07 16:30:26 +0000
commit4ddf1cd05c6b6d587020c8f1f0479fb894c95a11 (patch)
tree1710aba5ecba59964ffba279620ee3051b9d99d7
parent3baa47c42b7c8524a9ff80c5f9cbd3f88db1f86d (diff)
downloadgdb-4ddf1cd05c6b6d587020c8f1f0479fb894c95a11.tar.gz
* fbsd-proc.c (read_mapping): Use sscanf and fgets instead of
fscanf.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/fbsd-proc.c23
2 files changed, 16 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 259ac8a9141..7f69024e5c0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2003-11-07 Mark Kettenis <kettenis@gnu.org>
+ * fbsd-proc.c (read_mapping): Use sscanf and fgets instead of
+ fscanf.
+
+2003-11-07 Mark Kettenis <kettenis@gnu.org>
+
* fbsd-proc.c: Fix formatting.
2003-11-06 Kevin Buettner <kevinb@redhat.com>
diff --git a/gdb/fbsd-proc.c b/gdb/fbsd-proc.c
index 07272b19863..16813a9a1c8 100644
--- a/gdb/fbsd-proc.c
+++ b/gdb/fbsd-proc.c
@@ -52,20 +52,19 @@ static int
read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end,
char *protection)
{
+ /* FreeBSD 5.1-RELEASE uses a 256-byte buffer. */
+ char buf[256];
int resident, privateresident;
unsigned long obj;
- int ref_count, shadow_count;
- unsigned flags;
- char cow[5], access[4];
- char type[8];
- int ret;
-
- /* The layout is described in /usr/src/miscfs/procfs/procfs_map.c. */
- ret = fscanf (mapfile, "%lx %lx %d %d %lx %s %d %d %x %s %s %s\n",
- start, end,
- &resident, &privateresident, &obj,
- protection,
- &ref_count, &shadow_count, &flags, cow, access, type);
+ int ret = EOF;
+
+ /* As of FreeBSD 5.0-RELEASE, the layout is described in
+ /usr/src/sys/fs/procfs/procfs_map.c. Somewhere in 5.1-CURRENT a
+ new column was added to the procfs map. Therefore we can't use
+ fscanf since we need to support older releases too. */
+ if (fgets (buf, sizeof buf, mapfile) != NULL)
+ ret = sscanf (buf, "%lx %lx %d %d %lx %s", start, end,
+ &resident, &privateresident, &obj, protection);
return (ret != 0 && ret != EOF);
}