psrcgen: turn IGNORE_UPPER_DIRECTORY to command line switch
This commit is contained in:
parent
c1cff4cefc
commit
5966f5fe91
37
psrcgen.c
37
psrcgen.c
|
@ -15,6 +15,8 @@
|
|||
#include "dwarves.h"
|
||||
#include "dutil.h"
|
||||
|
||||
static bool g_strip_upper_directory = false;
|
||||
|
||||
#define IGNORE_UPPER_DIRECTORY 1
|
||||
#define NO_WRITE_FILES 0
|
||||
|
||||
|
@ -176,10 +178,12 @@ static srcfile_t *find_or_create_srcfile(const char *filename)
|
|||
|
||||
filename += startswith( filename, "/" );
|
||||
|
||||
#if IGNORE_UPPER_DIRECTORY
|
||||
|
||||
if( !g_strip_upper_directory )
|
||||
{
|
||||
if( startswith( filename, "../" ))
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
if( startswith( filename, "usr/" ))
|
||||
return NULL;
|
||||
|
@ -187,14 +191,13 @@ static srcfile_t *find_or_create_srcfile(const char *filename)
|
|||
if( startswith( filename, "fs/root/build/host/glibc-2.29/" ))
|
||||
return NULL;
|
||||
|
||||
#if !IGNORE_UPPER_DIRECTORY
|
||||
if( g_strip_upper_directory )
|
||||
filename += startswith( filename, "../" );
|
||||
#endif
|
||||
|
||||
filename += startswith( filename, "/fs/root/build/x86_64/lccrt/" );
|
||||
filename += startswith( filename, "fs/root/build/x86_64/lccrt/" );
|
||||
filename += startswith( filename, "./" );
|
||||
filename += startswith( filename, ".obj/" );
|
||||
|
||||
include_detector_push(filename);
|
||||
|
||||
list_for_each_entry(srcfile, &g_SourceFiles, node)
|
||||
|
@ -263,6 +266,7 @@ static void add_srcfile_tag(struct tag *tag, struct cu *cu)
|
|||
|
||||
static struct conf_fprintf conf = {
|
||||
.emit_stats = 0,
|
||||
.classes_as_structs = 1,
|
||||
};
|
||||
|
||||
static void print_type(struct tag *tag, struct cu *cu, FILE *fp)
|
||||
|
@ -400,14 +404,6 @@ static int cu__emit_tags(struct cu *cu)
|
|||
uint32_t i;
|
||||
struct tag *tag;
|
||||
struct function *function;
|
||||
const char *name = cu->name;
|
||||
|
||||
#if IGNORE_UPPER_DIRECTORY
|
||||
if( startswith(name, "../" ))
|
||||
return 0;
|
||||
#else
|
||||
name += startswith(name, "../" );
|
||||
#endif
|
||||
|
||||
include_detector_init();
|
||||
|
||||
|
@ -452,7 +448,17 @@ static const struct argp_option pdwtags__options[] = {
|
|||
.name = "format_path",
|
||||
.key = 'F',
|
||||
.arg = "FORMAT_LIST",
|
||||
.doc = "List of debugging formats to try"
|
||||
.doc = "List of debugging formats to try",
|
||||
},
|
||||
{
|
||||
.name = "classes_as_structs",
|
||||
.key = 'S',
|
||||
.doc = "force classes to be presented as structs",
|
||||
},
|
||||
{
|
||||
.name = "strip_upper_directory",
|
||||
.key = 'u',
|
||||
.doc = "strip upper directory from file paths",
|
||||
},
|
||||
{
|
||||
.key = 'V',
|
||||
|
@ -474,6 +480,8 @@ static error_t pdwtags__options_parser(int key, char *arg __maybe_unused,
|
|||
break;
|
||||
case 'F': pdwtags_conf_load.format_path = arg; break;
|
||||
case 'V': conf.show_decl_info = 1; break;
|
||||
case 'S': conf.classes_as_structs = 1; break;
|
||||
case 'u': g_strip_upper_directory = true; break;
|
||||
default: return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
return 0;
|
||||
|
@ -518,3 +526,4 @@ out:
|
|||
dwarves__exit();
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue