• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisión8bf5d944716b1e13987e0e8cba1bcb5d7beea3b0 (tree)
Tiempo2017-09-20 23:15:02
AutorWalfred Tedeschi <walfred.tedeschi@inte...>
CommiterWalfred Tedeschi

Log Message

dwarf2read: move producers help functions to a dwarf specific file

This patch add new files to add dwarf reader utilities into it.
It is also a preparation path to add functions to detect the icc
version that produced a given compilation unit.

2017-09-18 Walfred Tedeschi <walfred.tedeschi@intel.com>

* Makefile.in (SFILES): Add dwarf2utils.c.
(COMMON_OBS): Add dwarf2utils.o
* amd64-tdep.c (dwarf2utils.h): Add new header.
* dwarf2read.c (dwarf2utils.h): Add new header.
* dwarf2utils.c: New file.
* dwarf2utils.h: New file.
* utils.c (producer_is_gcc, producer_is_gcc_ge_4): Move to
dwarf2utils.c.
* utils.h (producer_is_gcc, producer_is_gcc_ge_4): Move to
dwarf2utils.h.

Cambiar Resumen

Diferencia incremental

--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1088,6 +1088,7 @@ SFILES = \
10881088 dtrace-probe.c \
10891089 dummy-frame.c \
10901090 dwarf2-frame.c \
1091+ dwarf2utils.c \
10911092 dwarf2-frame-tailcall.c \
10921093 dwarf2expr.c \
10931094 dwarf2loc.c \
@@ -1707,6 +1708,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
17071708 dummy-frame.o \
17081709 dwarf2-frame.o \
17091710 dwarf2-frame-tailcall.o \
1711+ dwarf2utils.o \
17101712 dwarf2expr.o \
17111713 dwarf2loc.o \
17121714 dwarf2read.o \
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -43,6 +43,7 @@
4343 #include <algorithm>
4444 #include "target-descriptions.h"
4545 #include "arch/amd64.h"
46+#include "dwarf2utils.h"
4647 #include "ax.h"
4748 #include "ax-gdb.h"
4849
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -75,6 +75,7 @@
7575 #include "common/underlying.h"
7676 #include "common/byte-vector.h"
7777 #include "filename-seen-cache.h"
78+#include "dwarf2utils.h"
7879 #include <fcntl.h>
7980 #include <sys/types.h>
8081 #include <algorithm>
--- /dev/null
+++ b/gdb/dwarf2utils.c
@@ -0,0 +1,86 @@
1+/* DWARF 2 debugging format utils for GDB.
2+
3+ This file is part of GDB.
4+
5+ This program is free software; you can redistribute it and/or modify
6+ it under the terms of the GNU General Public License as published by
7+ the Free Software Foundation; either version 3 of the License, or
8+ (at your option) any later version.
9+
10+ This program is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ GNU General Public License for more details.
14+
15+ You should have received a copy of the GNU General Public License
16+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
17+
18+/* Check for GCC >= 4.x according to the symtab->producer string. Return minor
19+ version (x) of 4.x in such case. If it is not GCC or it is GCC older than
20+ 4.x return -1. If it is GCC 5.x or higher return INT_MAX. */
21+
22+#include "config.h"
23+#include "dwarf2utils.h"
24+#include "stdio.h"
25+#include "string.h"
26+#include "defs.h"
27+#include "dyn-string.h"
28+#include <ctype.h>
29+
30+#include "common/common-types.h"
31+#include "common/common-exceptions.h"
32+#include "common/common-utils.h"
33+
34+
35+#include "utils.h"
36+
37+int
38+producer_is_gcc_ge_4 (const char *producer)
39+{
40+ int major, minor;
41+
42+ if (! producer_is_gcc (producer, &major, &minor))
43+ return -1;
44+ if (major < 4)
45+ return -1;
46+ if (major > 4)
47+ return INT_MAX;
48+ return minor;
49+}
50+
51+/* Returns nonzero if the given PRODUCER string is GCC and sets the MAJOR
52+ and MINOR versions when not NULL. Returns zero if the given PRODUCER
53+ is NULL or it isn't GCC. */
54+
55+int
56+producer_is_gcc (const char *producer, int *major, int *minor)
57+{
58+ const char *cs;
59+
60+ if (producer != NULL && startswith (producer, "GNU "))
61+ {
62+ int maj, min;
63+
64+ if (major == NULL)
65+ major = &maj;
66+ if (minor == NULL)
67+ minor = &min;
68+
69+ /* Skip any identifier after "GNU " - such as "C11" "C++" or "Java".
70+ A full producer string might look like:
71+ "GNU C 4.7.2"
72+ "GNU Fortran 4.8.2 20140120 (Red Hat 4.8.2-16) -mtune=generic ..."
73+ "GNU C++14 5.0.0 20150123 (experimental)"
74+ */
75+ cs = &producer[strlen ("GNU ")];
76+ while (*cs && !isspace (*cs))
77+ cs++;
78+ if (*cs && isspace (*cs))
79+ cs++;
80+ if (sscanf (cs, "%d.%d", major, minor) == 2)
81+ return 1;
82+ }
83+
84+ /* Not recognized as GCC. */
85+ return 0;
86+}
--- /dev/null
+++ b/gdb/dwarf2utils.h
@@ -0,0 +1,28 @@
1+/* DWARF 2 debugging format utils for GDB.
2+
3+ Copyright (C) 2017 Free Software Foundation, Inc.
4+
5+ This file is part of GDB.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ You should have received a copy of the GNU General Public License
18+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
19+#ifndef DWARF2UTILS_H
20+#define DWARF2UTILS_H
21+
22+/* See documentation in the utils.c file. */
23+extern int producer_is_gcc_ge_4 (const char *producer);
24+
25+/* See documentation in the utils.c file. */
26+extern int producer_is_gcc (const char *producer, int *major, int *minor);
27+
28+#endif
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2944,60 +2944,6 @@ make_bpstat_clear_actions_cleanup (void)
29442944 return make_cleanup (do_bpstat_clear_actions_cleanup, NULL);
29452945 }
29462946
2947-/* Check for GCC >= 4.x according to the symtab->producer string. Return minor
2948- version (x) of 4.x in such case. If it is not GCC or it is GCC older than
2949- 4.x return -1. If it is GCC 5.x or higher return INT_MAX. */
2950-
2951-int
2952-producer_is_gcc_ge_4 (const char *producer)
2953-{
2954- int major, minor;
2955-
2956- if (! producer_is_gcc (producer, &major, &minor))
2957- return -1;
2958- if (major < 4)
2959- return -1;
2960- if (major > 4)
2961- return INT_MAX;
2962- return minor;
2963-}
2964-
2965-/* Returns nonzero if the given PRODUCER string is GCC and sets the MAJOR
2966- and MINOR versions when not NULL. Returns zero if the given PRODUCER
2967- is NULL or it isn't GCC. */
2968-
2969-int
2970-producer_is_gcc (const char *producer, int *major, int *minor)
2971-{
2972- const char *cs;
2973-
2974- if (producer != NULL && startswith (producer, "GNU "))
2975- {
2976- int maj, min;
2977-
2978- if (major == NULL)
2979- major = &maj;
2980- if (minor == NULL)
2981- minor = &min;
2982-
2983- /* Skip any identifier after "GNU " - such as "C11" or "C++".
2984- A full producer string might look like:
2985- "GNU C 4.7.2"
2986- "GNU Fortran 4.8.2 20140120 (Red Hat 4.8.2-16) -mtune=generic ..."
2987- "GNU C++14 5.0.0 20150123 (experimental)"
2988- */
2989- cs = &producer[strlen ("GNU ")];
2990- while (*cs && !isspace (*cs))
2991- cs++;
2992- if (*cs && isspace (*cs))
2993- cs++;
2994- if (sscanf (cs, "%d.%d", major, minor) == 2)
2995- return 1;
2996- }
2997-
2998- /* Not recognized as GCC. */
2999- return 0;
3000-}
30012947
30022948 /* Helper for make_cleanup_free_char_ptr_vec. */
30032949
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -442,9 +442,6 @@ void dummy_obstack_deallocate (void *object, void *data);
442442 extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
443443 #endif
444444
445-extern int producer_is_gcc_ge_4 (const char *producer);
446-extern int producer_is_gcc (const char *producer, int *major, int *minor);
447-
448445 extern int myread (int, char *, int);
449446
450447 /* Ensure that V is aligned to an N byte boundary (B's assumed to be a