X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Fxml-syscall.c;h=382446828eda783ec65a9ce996a79dfe2d9df35e;hb=a0f8cd12efd921e4471afaf3e53c2b984ecf850a;hp=3f5585c65ac6a814da0e9215961892f152a158a6;hpb=d5cd603472bb4b3c14782728aa55bbafdfe783e8;p=platform%2Fupstream%2Fbinutils.git diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c index 3f5585c..3824468 100644 --- a/gdb/xml-syscall.c +++ b/gdb/xml-syscall.c @@ -1,7 +1,7 @@ /* Functions that provide the mechanism to parse a syscall XML file and get its values. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009-2014 Free Software Foundation, Inc. This file is part of GDB. @@ -28,8 +28,6 @@ #include "filenames.h" -#include "gdb_assert.h" - #ifndef HAVE_LIBEXPAT /* Dummy functions to indicate that there's no support for fetching @@ -80,6 +78,10 @@ get_syscall_names (void) #else /* ! HAVE_LIBEXPAT */ +/* Variable that will hold the last known data-directory. This is useful to + know whether we should re-read the XML info for the target. */ +static char *my_gdb_datadir = NULL; + /* Structure which describes a syscall. */ typedef struct syscall_desc { @@ -122,7 +124,7 @@ static const char *xml_syscall_file = NULL; static struct syscalls_info * allocate_syscalls_info (void) { - return XZALLOC (struct syscalls_info); + return XCNEW (struct syscalls_info); } static void @@ -147,7 +149,7 @@ free_syscalls_info (void *arg) xfree (sysinfo); } -struct cleanup * +static struct cleanup * make_cleanup_free_syscalls_info (struct syscalls_info *sysinfo) { return make_cleanup (free_syscalls_info, sysinfo); @@ -157,7 +159,7 @@ static void syscall_create_syscall_desc (struct syscalls_info *sysinfo, const char *name, int number) { - struct syscall_desc *sysdesc = XZALLOC (struct syscall_desc); + struct syscall_desc *sysdesc = XCNEW (struct syscall_desc); sysdesc->name = xstrdup (name); sysdesc->number = number; @@ -165,17 +167,6 @@ syscall_create_syscall_desc (struct syscalls_info *sysinfo, VEC_safe_push (syscall_desc_p, sysinfo->syscalls, sysdesc); } -/* Handle the start of a element. */ -static void -syscall_start_syscalls_info (struct gdb_xml_parser *parser, - const struct gdb_xml_element *element, - void *user_data, - VEC(gdb_xml_value_s) *attributes) -{ - struct syscall_parsing_data *data = user_data; - struct syscalls_info *sysinfo = data->sysinfo; -} - /* Handle the start of a element. */ static void syscall_start_syscall (struct gdb_xml_parser *parser, @@ -202,6 +193,7 @@ syscall_start_syscall (struct gdb_xml_parser *parser, _("Unknown attribute name '%s'."), attrs[i].name); } + gdb_assert (name); syscall_create_syscall_desc (data->sysinfo, name, number); } @@ -222,7 +214,7 @@ static const struct gdb_xml_element syscalls_info_children[] = { static const struct gdb_xml_element syselements[] = { { "syscalls_info", NULL, syscalls_info_children, - GDB_XML_EF_NONE, syscall_start_syscalls_info, NULL }, + GDB_XML_EF_NONE, NULL, NULL }, { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL } }; @@ -231,19 +223,13 @@ syscall_parse_xml (const char *document, xml_fetch_another fetcher, void *fetcher_baton) { struct cleanup *result_cleanup; - struct gdb_xml_parser *parser; struct syscall_parsing_data data; - char *expanded_text; - int i; - - parser = gdb_xml_create_parser_and_cleanup (_("syscalls info"), - syselements, &data); - memset (&data, 0, sizeof (struct syscall_parsing_data)); data.sysinfo = allocate_syscalls_info (); result_cleanup = make_cleanup_free_syscalls_info (data.sysinfo); - if (gdb_xml_parse (parser, document) == 0) + if (gdb_xml_parse_quick (_("syscalls info"), NULL, + syselements, document, &data) == 0) { /* Parsed successfully. */ discard_cleanups (result_cleanup); @@ -280,7 +266,8 @@ xml_init_syscalls_info (const char *filename) if (dirname != NULL) make_cleanup (xfree, dirname); - sysinfo = syscall_parse_xml (full_file, xml_fetch_content_from_file, dirname); + sysinfo = syscall_parse_xml (full_file, + xml_fetch_content_from_file, dirname); do_cleanups (back_to); return sysinfo; @@ -291,6 +278,18 @@ xml_init_syscalls_info (const char *filename) static void init_sysinfo (void) { + /* Should we re-read the XML info for this target? */ + if (my_gdb_datadir && filename_cmp (my_gdb_datadir, gdb_datadir) != 0) + { + /* The data-directory changed from the last time we used it. + It means that we have to re-read the XML info. */ + have_initialized_sysinfo = 0; + xfree (my_gdb_datadir); + my_gdb_datadir = NULL; + if (sysinfo) + free_syscalls_info ((void *) sysinfo); + } + /* Did we already try to initialize the structure? */ if (have_initialized_sysinfo) return; @@ -302,16 +301,18 @@ init_sysinfo (void) if (sysinfo == NULL) { if (xml_syscall_file) - warning (_("\ -Could not load the syscall XML file `%s'."), xml_syscall_file); + warning (_("Could not load the syscall XML file `%s/%s'."), + gdb_datadir, xml_syscall_file); else - warning (_("\ -There is no XML file to open.")); + warning (_("There is no XML file to open.")); - warning (_("\ -GDB will not be able to display syscall names nor to verify if\n\ -any provided syscall numbers are valid.")); + warning (_("GDB will not be able to display " + "syscall names nor to verify if\n" + "any provided syscall numbers are valid.")); } + + /* Saving the data-directory used to read this XML info. */ + my_gdb_datadir = xstrdup (gdb_datadir); } static int