GNU Binutils with patches for OS216
Revisión | 8bf5d944716b1e13987e0e8cba1bcb5d7beea3b0 (tree) |
---|---|
Tiempo | 2017-09-20 23:15:02 |
Autor | Walfred Tedeschi <walfred.tedeschi@inte...> |
Commiter | Walfred Tedeschi |
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.
@@ -1088,6 +1088,7 @@ SFILES = \ | ||
1088 | 1088 | dtrace-probe.c \ |
1089 | 1089 | dummy-frame.c \ |
1090 | 1090 | dwarf2-frame.c \ |
1091 | + dwarf2utils.c \ | |
1091 | 1092 | dwarf2-frame-tailcall.c \ |
1092 | 1093 | dwarf2expr.c \ |
1093 | 1094 | dwarf2loc.c \ |
@@ -1707,6 +1708,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ | ||
1707 | 1708 | dummy-frame.o \ |
1708 | 1709 | dwarf2-frame.o \ |
1709 | 1710 | dwarf2-frame-tailcall.o \ |
1711 | + dwarf2utils.o \ | |
1710 | 1712 | dwarf2expr.o \ |
1711 | 1713 | dwarf2loc.o \ |
1712 | 1714 | dwarf2read.o \ |
@@ -43,6 +43,7 @@ | ||
43 | 43 | #include <algorithm> |
44 | 44 | #include "target-descriptions.h" |
45 | 45 | #include "arch/amd64.h" |
46 | +#include "dwarf2utils.h" | |
46 | 47 | #include "ax.h" |
47 | 48 | #include "ax-gdb.h" |
48 | 49 |
@@ -75,6 +75,7 @@ | ||
75 | 75 | #include "common/underlying.h" |
76 | 76 | #include "common/byte-vector.h" |
77 | 77 | #include "filename-seen-cache.h" |
78 | +#include "dwarf2utils.h" | |
78 | 79 | #include <fcntl.h> |
79 | 80 | #include <sys/types.h> |
80 | 81 | #include <algorithm> |
@@ -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 | +} |
@@ -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 |
@@ -2944,60 +2944,6 @@ make_bpstat_clear_actions_cleanup (void) | ||
2944 | 2944 | return make_cleanup (do_bpstat_clear_actions_cleanup, NULL); |
2945 | 2945 | } |
2946 | 2946 | |
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 | -} | |
3001 | 2947 | |
3002 | 2948 | /* Helper for make_cleanup_free_char_ptr_vec. */ |
3003 | 2949 |
@@ -442,9 +442,6 @@ void dummy_obstack_deallocate (void *object, void *data); | ||
442 | 442 | extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout); |
443 | 443 | #endif |
444 | 444 | |
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 | - | |
448 | 445 | extern int myread (int, char *, int); |
449 | 446 | |
450 | 447 | /* Ensure that V is aligned to an N byte boundary (B's assumed to be a |