2009-03-14 17:50:36 +01:00
|
|
|
/*
|
2019-01-15 18:28:24 +01:00
|
|
|
SPDX-License-Identifier: GPL-2.0-only
|
2007-01-19 00:13:56 +01:00
|
|
|
|
2019-01-15 18:28:24 +01:00
|
|
|
Copyright (C) 2007-2016 Arnaldo Carvalho de Melo <acme@kernel.org>
|
2007-01-19 00:13:56 +01:00
|
|
|
*/
|
|
|
|
|
2007-05-26 15:29:02 +02:00
|
|
|
#include <argp.h>
|
2007-01-19 00:13:56 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>
|
2022-04-15 20:25:58 +02:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2007-01-19 00:13:56 +01:00
|
|
|
#include "dwarves.h"
|
2007-12-16 17:47:59 +01:00
|
|
|
#include "dutil.h"
|
2007-01-19 00:13:56 +01:00
|
|
|
|
2007-05-26 15:29:02 +02:00
|
|
|
static struct conf_fprintf conf = {
|
2022-04-13 17:35:06 +02:00
|
|
|
.emit_stats = 0,
|
2007-05-24 22:19:21 +02:00
|
|
|
};
|
|
|
|
|
2022-04-15 20:25:58 +02:00
|
|
|
typedef struct
|
2022-04-13 17:35:06 +02:00
|
|
|
{
|
2022-04-15 20:25:58 +02:00
|
|
|
struct list_head node;
|
|
|
|
int linenum;
|
2022-04-13 17:35:06 +02:00
|
|
|
struct tag *tag;
|
2022-04-15 20:25:58 +02:00
|
|
|
struct cu *cu;
|
|
|
|
} header_line_t;
|
2022-04-13 17:35:06 +02:00
|
|
|
|
2022-04-15 20:25:58 +02:00
|
|
|
typedef struct
|
2022-04-13 17:35:06 +02:00
|
|
|
{
|
2022-04-15 20:25:58 +02:00
|
|
|
struct list_head node;
|
2022-04-13 17:35:06 +02:00
|
|
|
const char *filename;
|
2022-04-15 20:25:58 +02:00
|
|
|
struct list_head lines;
|
|
|
|
} header_info_t;
|
2022-04-13 17:35:06 +02:00
|
|
|
|
2022-04-15 20:25:58 +02:00
|
|
|
LIST_HEAD(headers);
|
2022-04-13 17:35:06 +02:00
|
|
|
|
|
|
|
char *strncpy2(char *dest, const char *src, size_t n)
|
|
|
|
{
|
|
|
|
char *ret = strncpy(dest, src, n);
|
|
|
|
dest[n] = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-04-15 20:25:58 +02:00
|
|
|
static bool strcaseendswith(const char *s1, const char *s2)
|
|
|
|
{
|
|
|
|
int len1 = strlen(s1);
|
|
|
|
int len2 = strlen(s2);
|
|
|
|
|
|
|
|
if( len1 < len2 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return !strcasecmp(s1 + len1 - len2, s2);
|
|
|
|
}
|
|
|
|
|
2022-04-15 22:35:54 +02:00
|
|
|
static int strcasestartswith( const char *s1, const char *s2 )
|
|
|
|
{
|
|
|
|
int len2 = strlen(s2);
|
|
|
|
|
|
|
|
if( !strncasecmp(s1, s2, len2))
|
|
|
|
return len2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-04-15 20:25:58 +02:00
|
|
|
static bool filename_looks_like_header(const char *filename)
|
|
|
|
{
|
|
|
|
return strcaseendswith(filename, ".h");
|
|
|
|
}
|
|
|
|
|
|
|
|
static header_info_t *find_or_create_header(const char *filename)
|
|
|
|
{
|
|
|
|
header_info_t *header;
|
|
|
|
|
2022-04-15 22:35:54 +02:00
|
|
|
if( strcasestartswith( filename, "../" ))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if( strcasestartswith( filename, "/usr/" ))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if( strcasestartswith( filename, "/fs/root/build/host/glibc-2.29/" ))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
filename += strcasestartswith( filename, "/fs/root/build/x86_64/lccrt/" );
|
|
|
|
filename += strcasestartswith( filename, "fs/root/build/x86_64/lccrt/" );
|
|
|
|
filename += strcasestartswith( filename, "./" );
|
|
|
|
filename += strcasestartswith( filename, ".obj/" );
|
|
|
|
|
|
|
|
|
2022-04-15 20:25:58 +02:00
|
|
|
list_for_each_entry(header, &headers, node)
|
|
|
|
{
|
|
|
|
if( !strcmp( header->filename, filename ))
|
|
|
|
{
|
|
|
|
return header;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
header = malloc( sizeof( header_info_t ));
|
|
|
|
header->filename = strdup(filename);
|
|
|
|
INIT_LIST_HEAD(&header->lines);
|
|
|
|
|
|
|
|
list_add_tail(&header->node, &headers);
|
|
|
|
|
|
|
|
return header;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool find_or_insert_line(header_info_t *header, int linenum, struct tag *tag, struct cu *cu)
|
|
|
|
{
|
|
|
|
header_line_t *line, *new;
|
|
|
|
|
|
|
|
list_for_each_entry_reverse(line, &header->lines, node)
|
|
|
|
{
|
2022-04-15 22:35:54 +02:00
|
|
|
if( line->linenum == linenum ) // && tag__orig_id(line->tag, line->cu) == tag__orig_id(tag, cu))
|
|
|
|
{
|
|
|
|
line->tag = tag;
|
|
|
|
line->cu = cu;
|
2022-04-15 20:25:58 +02:00
|
|
|
return false;
|
2022-04-15 22:35:54 +02:00
|
|
|
}
|
2022-04-15 20:25:58 +02:00
|
|
|
|
|
|
|
if( line->linenum <= linenum )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
new = malloc( sizeof( header_line_t ));
|
|
|
|
new->linenum = linenum;
|
|
|
|
new->tag = tag;
|
|
|
|
new->cu = cu;
|
|
|
|
list_add(&new->node, &line->node);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-04-15 22:35:54 +02:00
|
|
|
static void add_header_tag(const char *file, struct tag *tag, struct cu *cu, FILE *fp)
|
|
|
|
{
|
|
|
|
//static const char *prev = NULL;
|
|
|
|
|
|
|
|
header_info_t *header;
|
|
|
|
header = find_or_create_header(file);
|
|
|
|
|
|
|
|
if( header )
|
|
|
|
{
|
|
|
|
find_or_insert_line(header, tag__decl_line(tag, cu), tag, cu);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if( prev != header->filename )
|
|
|
|
{
|
|
|
|
fprintf( fp, "#include \"%s\"\n", header->filename);
|
|
|
|
}
|
|
|
|
prev = header->filename;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void emit_tag(struct tag *tag, struct cu *cu, FILE *fp)
|
|
|
|
{
|
|
|
|
if (tag__is_struct(tag))
|
|
|
|
class__find_holes(tag__class(tag));
|
|
|
|
|
|
|
|
if (tag__is_pointer(tag))
|
|
|
|
fprintf(fp, " /* pointer to %lld %s */\n", (unsigned long long)tag->type, dwarf_tag_name(tag->tag));
|
|
|
|
else
|
|
|
|
tag__fprintf(tag, cu, &conf, fp);
|
|
|
|
|
|
|
|
fprintf(fp, " /* size: %zd */\n\n", tag__size(tag, cu));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_types(struct cu *cu, struct tag *tag, bool header, FILE *fp)
|
|
|
|
{
|
|
|
|
const char *file;
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
switch(tag->tag)
|
|
|
|
{
|
|
|
|
case DW_TAG_base_type:
|
|
|
|
case DW_TAG_const_type:
|
|
|
|
case DW_TAG_array_type:
|
|
|
|
case DW_TAG_pointer_type:
|
|
|
|
case DW_TAG_reference_type:
|
|
|
|
case DW_TAG_subroutine_type:
|
|
|
|
case DW_TAG_unspecified_type:
|
|
|
|
case DW_TAG_rvalue_reference_type:
|
|
|
|
case DW_TAG_restrict_type:
|
|
|
|
case DW_TAG_volatile_type:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
name = type__name(tag__type(tag));
|
|
|
|
// probably included
|
|
|
|
if( name == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( name[0] == '\0' )
|
|
|
|
return;
|
|
|
|
|
|
|
|
file = header ? 0 : tag__decl_file(tag, cu);
|
|
|
|
if( file && filename_looks_like_header( file ))
|
|
|
|
{
|
|
|
|
add_header_tag(file, tag, cu, fp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// probably a forward declaration, skip for now
|
|
|
|
if( tag__size(tag, cu) == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
emit_tag(tag, cu, fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_variables(struct cu *cu, struct tag *tag, bool header, FILE *fp)
|
|
|
|
{
|
|
|
|
const char *file = header ? 0 : tag__decl_file(tag, cu);
|
|
|
|
if( file && filename_looks_like_header( file ))
|
|
|
|
{
|
|
|
|
add_header_tag(file, tag, cu, fp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct variable *variable = tag__variable(tag);
|
|
|
|
|
|
|
|
if( variable->scope == VSCOPE_LOCAL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
tag__fprintf(tag, cu, NULL, fp);
|
|
|
|
fprintf(fp, " /* size: %zd scope: %s */\n", tag__size(tag, cu), variable__scope_str(variable));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_functions(struct cu *cu, struct function *function, bool header, FILE *fp)
|
|
|
|
{
|
|
|
|
const char *file;
|
|
|
|
struct tag *tag = function__tag(function);
|
|
|
|
|
|
|
|
file = header ? 0 : tag__decl_file(tag, cu);
|
|
|
|
if( file && filename_looks_like_header( file ))
|
|
|
|
{
|
|
|
|
add_header_tag(file, tag, cu, fp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tag__fprintf(tag, cu, &conf, fp);
|
|
|
|
fputs("\n", fp);
|
|
|
|
lexblock__fprintf(&function->lexblock, cu, function, 0,
|
|
|
|
&conf, fp);
|
|
|
|
fputs("\n\n", fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NO_WRITE_FILES 0
|
|
|
|
|
2022-04-13 17:35:06 +02:00
|
|
|
static void mkdir_p(const char *path)
|
|
|
|
{
|
2022-04-15 22:35:54 +02:00
|
|
|
#if NO_WRITE_FILES
|
|
|
|
return;
|
|
|
|
#else
|
2022-04-15 20:25:58 +02:00
|
|
|
char orig_dir[2048];
|
|
|
|
getcwd(orig_dir, sizeof( orig_dir ));
|
|
|
|
|
2022-04-13 17:35:06 +02:00
|
|
|
for(const char *path2 = path; (path2 = strchr(path, '/')); path = path2 + 1)
|
|
|
|
{
|
|
|
|
char dir[128];
|
|
|
|
|
|
|
|
strncpy2(dir, path, path2 - path);
|
2022-04-15 20:25:58 +02:00
|
|
|
|
|
|
|
mkdir(dir, 0777);
|
|
|
|
|
|
|
|
chdir(dir);
|
2022-04-13 17:35:06 +02:00
|
|
|
}
|
2022-04-15 20:25:58 +02:00
|
|
|
|
|
|
|
chdir(orig_dir);
|
2022-04-15 22:35:54 +02:00
|
|
|
#endif
|
2022-04-13 17:35:06 +02:00
|
|
|
}
|
|
|
|
|
2022-04-15 22:35:54 +02:00
|
|
|
static void headers_print( void )
|
2007-01-19 00:13:56 +01:00
|
|
|
{
|
2022-04-15 22:35:54 +02:00
|
|
|
header_info_t *header;
|
2022-04-15 20:25:58 +02:00
|
|
|
|
2022-04-15 22:35:54 +02:00
|
|
|
list_for_each_entry(header, &headers, node)
|
|
|
|
{
|
|
|
|
printf( "HEADER: %s\n", header->filename );
|
|
|
|
|
|
|
|
mkdir_p( header->filename );
|
|
|
|
|
|
|
|
FILE *fp = fopen( header->filename, "w+" );
|
|
|
|
|
|
|
|
header_line_t *line;
|
|
|
|
list_for_each_entry(line, &header->lines, node)
|
|
|
|
{
|
|
|
|
if( tag__is_type(line->tag))
|
|
|
|
{
|
|
|
|
print_types(line->cu, line->tag, true, fp);
|
|
|
|
}
|
|
|
|
else if( tag__is_variable(line->tag))
|
|
|
|
{
|
|
|
|
print_variables(line->cu, line->tag, true, fp );
|
|
|
|
}
|
|
|
|
else if( tag__is_function(line->tag))
|
|
|
|
{
|
|
|
|
print_functions(line->cu, tag__function(line->tag), true, fp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
}
|
2007-01-19 00:13:56 +01:00
|
|
|
}
|
|
|
|
|
2012-08-17 23:47:15 +02:00
|
|
|
static int cu__emit_tags(struct cu *cu)
|
2007-01-19 00:13:56 +01:00
|
|
|
{
|
2009-03-31 20:58:29 +02:00
|
|
|
uint32_t i;
|
|
|
|
struct tag *tag;
|
2022-04-15 22:35:54 +02:00
|
|
|
struct function *function;
|
2022-04-15 20:25:58 +02:00
|
|
|
FILE *fp;
|
2022-04-13 17:35:06 +02:00
|
|
|
|
|
|
|
if(!strncmp(cu->name, "../", 3))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mkdir_p(cu->name);
|
2022-04-15 20:25:58 +02:00
|
|
|
|
2022-04-15 22:35:54 +02:00
|
|
|
printf( "SOURCE: %s\n", cu->name );
|
|
|
|
#if NO_WRITE_FILES
|
|
|
|
fp = stdout;
|
|
|
|
#else
|
2022-04-15 20:25:58 +02:00
|
|
|
fp = fopen(cu->name, "w+");
|
2022-04-15 22:35:54 +02:00
|
|
|
#endif
|
2022-04-13 17:35:06 +02:00
|
|
|
|
2022-04-15 22:35:54 +02:00
|
|
|
fputs("/****************** Types: ******************/\n", fp);
|
|
|
|
cu__for_each_type(cu, i, tag) {
|
|
|
|
print_types(cu, tag, false, fp);
|
2022-04-15 20:25:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fputs("\n/****************** Variables: ******************/\n", fp);
|
|
|
|
cu__for_each_variable(cu, i, tag) {
|
2022-04-15 22:35:54 +02:00
|
|
|
print_variables(cu, tag, false, fp);
|
2022-04-13 17:35:06 +02:00
|
|
|
}
|
2009-03-31 20:58:29 +02:00
|
|
|
|
2022-04-15 20:25:58 +02:00
|
|
|
fputs("\n/****************** Functions: ******************/\n", fp);
|
2009-03-31 20:58:29 +02:00
|
|
|
conf.no_semicolon = true;
|
2012-08-17 23:47:15 +02:00
|
|
|
cu__for_each_function(cu, i, function) {
|
2022-04-15 22:35:54 +02:00
|
|
|
print_functions(cu, function, false, fp);
|
dwarves: Remove some more DWARF details from the core
Had to be a big sweeping change, but the regression tests shows just
improvements :-)
Now we stop using an id in struct tag, only storing the type, that now
uses 16 bits only, as CTF does.
Each format loader has to go on adding the types to the core, that
figures out if it is a tag that can be on the tag->type field
(tag__is_tag_type).
Formats that already have the types separated and in sequence, such as
CTF, just ask the core to insert in the types_table directly with its
original ID.
For DWARF, we ask the core to put it on the table, in sequence, and return the
index, that is then stashed with the DWARF specific info (original id, type,
decl_line, etc) and hashed by the original id. Later we recode everything,
looking up via the original type, getting the small_id to put on the tag->type.
The underlying debugging info not needed by the core is stashed in tag->priv,
and the DWARF loader now just allocates sizeof(struct dwarf_tag) at the end of
the core tag and points it there, and makes that info available thru
cu->orig_info. In the future we can ask, when loading a cu, that this info be
trown away, so that we reduce the memory footprint for big multi-cu files such
as the Linux kernel.
There is also a routine to ask for inserting a NULL, as we still have
bugs in the CTF decoding and thus some entries are being lost, to avoid
using an undefined pointer when traversing the types_table the ctf
loader puts a NULL there via cu__table_nullify_type_entry() and then
cu__for_each_type skips those.
There is some more cleanups for leftovers that I avoided cleaning to
reduce this changeset.
And also while doing this I saw that enums can appear without any
enumerators and that an array with DW_TAG_GNU_vector is actually a
different tag, encoded this way till we get to DWARF4 ;-)
So now we don't have to lookup on a hash table looking for DWARF
offsets, we can do the more sensible thing of just indexing the
types_tags array.
Now to do some cleanups and try to get the per cu encoder done. Then
order all the cus per number of type entries, pick the one with more,
then go on merging/recoding the types of the others and putting the
parent linkage in place.
Just to show the extent of the changes:
$ codiff /tmp/libdwarves.so.1.0.0 build/libdwarves.so.1.0.0
/home/acme/git/pahole/dwarves.c:
struct cu | -4048
struct tag | -32
struct ptr_to_member_type | -32
struct namespace | -32
struct type | -32
struct class | -32
struct base_type | -32
struct array_type | -32
struct class_member | -32
struct lexblock | -32
struct ftype | -32
struct function | -64
struct parameter | -32
struct variable | -32
struct inline_expansion | -32
struct label | -32
struct enumerator | -32
17 structs changed
tag__follow_typedef | +3
tag__fprintf_decl_info | +25
array_type__fprintf | +6
type__name | -126
type__find_first_biggest_size_base_type_member | -3
typedef__fprintf | +16
imported_declaration__fprintf | +6
imported_module__fprintf | +3
cu__new | +26
cu__delete | +26
hashtags__hash | -65
hash_64 | -124
hlist_add_head | -78
hashtags__find | -157
cu__hash | -80
cu__add_tag | +20
tag__prefix | -3
cu__find_tag_by_id | -2
cu__find_type_by_id | -3
cu__find_first_typedef_of_type | +38
cu__find_base_type_by_name | +68
cu__find_base_type_by_name_and_size | +72
cu__find_struct_by_name | +59
cus__find_struct_by_name | +8
cus__find_tag_by_id | +5
cus__find_cu_by_name | -6
lexblock__find_tag_by_id | -173
cu__find_variable_by_id | -197
list__find_tag_by_id | -308
cu__find_parameter_by_id | -60
tag__ptr_name | +6
tag__name | +15
variable__type | +13
variable__name | +7
class_member__size | +6
parameter__name | -119
tag__parameter | -14
parameter__type | -143
type__fprintf | -29
union__fprintf | +6
class__add_vtable_entry | -9
type__add_member | -6
type__clone_members | -3
enumeration__add | -6
function__name | -156
ftype__has_parm_of_type | -39
class__find_holes | -27
class__has_hole_ge | -3
type__nr_members_of_type | +3
lexblock__account_inline_expansions | +3
cu__account_inline_expansions | -18
ftype__fprintf_parms | +46
function__tag_fprintf | +24
lexblock__fprintf | -6
ftype__fprintf | +3
function__fprintf_stats | -18
function__size | -6
class__vtable_fprintf | -11
class__fprintf | -21
tag__fprintf | -35
60 functions changed, 513 bytes added, 2054 bytes removed, diff: -1541
/home/acme/git/pahole/ctf_loader.c:
struct ctf_short_type | +0
14 structs changed
type__init | -14
type__new | -9
class__new | -12
create_new_base_type | -7
create_new_base_type_float | -7
create_new_array | -8
create_new_subroutine_type | -9
create_full_members | -18
create_short_members | -18
create_new_class | +1
create_new_union | +1
create_new_enumeration | -19
create_new_forward_decl | -2
create_new_typedef | +3
create_new_tag | -5
load_types | +16
class__fixup_ctf_bitfields | -3
17 functions changed, 21 bytes added, 131 bytes removed, diff: -110
/home/acme/git/pahole/dwarf_loader.c:
17 structs changed
zalloc | -56
tag__init | +3
array_type__new | +20
type__init | -24
class_member__new | +46
inline_expansion__new | +12
class__new | +81
lexblock__init | +19
function__new | +43
die__create_new_array | +20
die__create_new_parameter | +4
die__create_new_label | +4
die__create_new_subroutine_type | +113
die__create_new_enumeration | -21
die__process_class | +79
die__process_namespace | +76
die__create_new_inline_expansion | +4
die__process_function | +147
__die__process_tag | +34
die__process_unit | +56
die__process | +90
21 functions changed, 851 bytes added, 101 bytes removed, diff: +750
/home/acme/git/pahole/dwarves.c:
struct ptr_table | +16
struct cu_orig_info | +32
2 structs changed
tag__decl_line | +68
tag__decl_file | +70
tag__orig_id | +71
ptr_table__init | +46
ptr_table__exit | +37
ptr_table__add | +183
ptr_table__add_with_id | +165
ptr_table__entry | +64
cu__table_add_tag | +171
cu__table_nullify_type_entry | +38
10 functions changed, 913 bytes added, diff: +913
/home/acme/git/pahole/ctf_loader.c:
2 structs changed
tag__alloc | +52
1 function changed, 52 bytes added, diff: +52
/home/acme/git/pahole/dwarf_loader.c:
struct dwarf_tag | +48
struct dwarf_cu | +4104
4 structs changed
dwarf_cu__init | +83
hashtags__hash | +61
hash_64 | +124
hlist_add_head | +78
hashtags__find | +161
cu__hash | +95
tag__is_tag_type | +171
tag__is_type | +85
tag__is_union | +28
tag__is_struct | +57
tag__is_typedef | +28
tag__is_enumeration | +28
dwarf_cu__find_tag_by_id | +56
dwarf_cu__find_type_by_id | +63
tag__alloc | +114
__tag__print_type_not_found | +108
namespace__recode_dwarf_types | +346
tag__namespace | +14
tag__has_namespace | +86
tag__is_namespace | +28
type__recode_dwarf_specification | +182
tag__type | +14
__tag__print_abstract_origin_not_found | +105
ftype__recode_dwarf_types | +322
tag__ftype | +14
tag__parameter | +14
lexblock__recode_dwarf_types | +736
tag__lexblock | +14
tag__label | +14
tag__recode_dwarf_type | +766
tag__ptr_to_member_type | +14
cu__recode_dwarf_types_table | +88
cu__recode_dwarf_types | +48
dwarf_tag__decl_file | +77
strings__ptr | +33
dwarf_tag__decl_line | +59
dwarf_tag__orig_id | +59
dwarf_tag__orig_type | +59
38 functions changed, 4432 bytes added, diff: +4432
build/libdwarves.so.1.0.0:
147 functions changed, 6782 bytes added, 2286 bytes removed, diff: +4496
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 00:29:35 +01:00
|
|
|
}
|
2009-03-31 20:58:29 +02:00
|
|
|
conf.no_semicolon = false;
|
|
|
|
|
2022-04-15 20:25:58 +02:00
|
|
|
fclose(fp);
|
2022-04-15 22:35:54 +02:00
|
|
|
|
2007-01-19 00:13:56 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:22:23 +01:00
|
|
|
static enum load_steal_kind pdwtags_stealer(struct cu *cu,
|
2022-01-26 20:20:36 +01:00
|
|
|
struct conf_load *conf_load __maybe_unused,
|
|
|
|
void *thr_data __maybe_unused)
|
2007-01-19 00:13:56 +01:00
|
|
|
{
|
2009-03-23 18:22:23 +01:00
|
|
|
cu__emit_tags(cu);
|
2022-04-15 22:35:54 +02:00
|
|
|
|
|
|
|
return LSK__KEEPIT;
|
2007-01-19 00:13:56 +01:00
|
|
|
}
|
|
|
|
|
2009-03-23 18:22:23 +01:00
|
|
|
static struct conf_load pdwtags_conf_load = {
|
|
|
|
.steal = pdwtags_stealer,
|
2019-04-15 18:51:28 +02:00
|
|
|
.conf_fprintf = &conf,
|
2022-04-13 17:35:06 +02:00
|
|
|
.extra_dbg_info = 1,
|
2022-04-15 20:25:58 +02:00
|
|
|
.get_addr_info = 1,
|
2009-03-23 18:22:23 +01:00
|
|
|
};
|
|
|
|
|
2009-02-13 13:57:23 +01:00
|
|
|
/* Name and version of program. */
|
|
|
|
ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
|
|
|
|
|
2007-05-26 15:29:02 +02:00
|
|
|
static const struct argp_option pdwtags__options[] = {
|
2009-04-02 17:38:41 +02:00
|
|
|
{
|
|
|
|
.name = "format_path",
|
|
|
|
.key = 'F',
|
|
|
|
.arg = "FORMAT_LIST",
|
|
|
|
.doc = "List of debugging formats to try"
|
|
|
|
},
|
2007-05-26 15:29:02 +02:00
|
|
|
{
|
|
|
|
.key = 'V',
|
|
|
|
.name = "verbose",
|
|
|
|
.doc = "show details",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = NULL,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-13 15:25:35 +02:00
|
|
|
static error_t pdwtags__options_parser(int key, char *arg __maybe_unused,
|
2007-05-26 15:29:02 +02:00
|
|
|
struct argp_state *state)
|
|
|
|
{
|
|
|
|
switch (key) {
|
2008-11-18 17:09:13 +01:00
|
|
|
case ARGP_KEY_INIT:
|
|
|
|
if (state->child_inputs != NULL)
|
|
|
|
state->child_inputs[0] = state->input;
|
|
|
|
break;
|
2009-04-02 17:38:41 +02:00
|
|
|
case 'F': pdwtags_conf_load.format_path = arg; break;
|
2007-05-26 15:29:02 +02:00
|
|
|
case 'V': conf.show_decl_info = 1; break;
|
|
|
|
default: return ARGP_ERR_UNKNOWN;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-31 12:30:55 +01:00
|
|
|
static const char pdwtags__args_doc[] = "FILE";
|
2007-05-26 15:29:02 +02:00
|
|
|
|
|
|
|
static struct argp pdwtags__argp = {
|
|
|
|
.options = pdwtags__options,
|
|
|
|
.parser = pdwtags__options_parser,
|
|
|
|
.args_doc = pdwtags__args_doc,
|
|
|
|
};
|
|
|
|
|
2007-01-19 00:13:56 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2016-03-15 16:29:38 +01:00
|
|
|
int remaining, rc = EXIT_FAILURE, err;
|
2008-10-01 17:47:42 +02:00
|
|
|
struct cus *cus = cus__new();
|
2007-01-19 00:41:25 +01:00
|
|
|
|
2021-10-28 14:27:08 +02:00
|
|
|
if (dwarves__init() || cus == NULL) {
|
2007-01-19 00:13:56 +01:00
|
|
|
fputs("pwdtags: insufficient memory\n", stderr);
|
2009-03-11 16:31:17 +01:00
|
|
|
goto out;
|
2007-01-19 00:13:56 +01:00
|
|
|
}
|
|
|
|
|
2021-10-28 14:27:08 +02:00
|
|
|
dwarves__resolve_cacheline_size(&pdwtags_conf_load, 0);
|
|
|
|
|
2009-02-10 00:43:56 +01:00
|
|
|
if (argp_parse(&pdwtags__argp, argc, argv, 0, &remaining, NULL) ||
|
|
|
|
remaining == argc) {
|
|
|
|
argp_help(&pdwtags__argp, stderr, ARGP_HELP_SEE, argv[0]);
|
2009-03-11 16:31:17 +01:00
|
|
|
goto out;
|
2009-02-10 00:43:56 +01:00
|
|
|
}
|
|
|
|
|
2022-04-15 22:35:54 +02:00
|
|
|
err = cus__load_file(cus, &pdwtags_conf_load, argv[remaining]);
|
2016-03-15 16:29:38 +01:00
|
|
|
if (err == 0) {
|
2009-03-23 18:22:23 +01:00
|
|
|
rc = EXIT_SUCCESS;
|
2022-04-15 22:35:54 +02:00
|
|
|
headers_print();
|
2016-03-15 16:29:38 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2016-03-15 18:25:58 +01:00
|
|
|
cus__fprintf_load_files_err(cus, "pdwtags", argv + remaining, err, stderr);
|
2009-03-11 16:31:17 +01:00
|
|
|
out:
|
|
|
|
cus__delete(cus);
|
|
|
|
dwarves__exit();
|
|
|
|
return rc;
|
2007-01-19 00:13:56 +01:00
|
|
|
}
|