| Index: gdb/nacl-manifest.c
|
| diff --git a/gdb/nacl-manifest.c b/gdb/nacl-manifest.c
|
| index 2ae402753e6fc43dd3f65203351990977d4304f8..927a2692c345a9dc25486737ec87469ac2b64b6f 100644
|
| --- a/gdb/nacl-manifest.c
|
| +++ b/gdb/nacl-manifest.c
|
| @@ -21,8 +21,11 @@
|
|
|
| #include "command.h"
|
| #include "completer.h"
|
| +#include "exec.h"
|
| +#include "observer.h"
|
| #include "readline/readline.h"
|
| #include "solib.h"
|
| +#include "symfile.h"
|
|
|
| #include <ctype.h>
|
| #include <stdio.h>
|
| @@ -157,6 +160,25 @@ json_on_end_member (struct json_manifest_reader *r, const char *member)
|
| --r->nesting;
|
| }
|
|
|
| +static void
|
| +append_dir_name (struct json_manifest_reader *r,
|
| + char *full_path,
|
| + int max_path_size,
|
| + char *name)
|
| +{
|
| + full_path[0] = '\0';
|
| + if (r->dirname)
|
| + {
|
| + if (strlen (r->dirname) + strlen (SLASH_STRING) >= max_path_size)
|
| + error (_("Mapped file name in manifest is too long."));
|
| + strcpy (full_path, r->dirname);
|
| + strcat (full_path, SLASH_STRING);
|
| + }
|
| + if (strlen (full_path) + strlen (name) >= max_path_size)
|
| + error (_("Mapped file name in manifest is too long."));
|
| + strcat (full_path, name);
|
| +}
|
| +
|
| static struct file_list *
|
| json_append_file_list (struct json_manifest_reader *r,
|
| struct file_list **nacl_file_list,
|
| @@ -168,17 +190,7 @@ json_append_file_list (struct json_manifest_reader *r,
|
| if (strlen(original_name) >= MANIFEST_MAX_STRING_SIZE)
|
| error (_("Original file name in manifest is too long."));
|
| strcpy (curr->original_name, original_name);
|
| -
|
| - if (r->dirname)
|
| - {
|
| - strcpy (curr->name, r->dirname);
|
| - if (strlen(curr->name) + strlen(SLASH_STRING) >= MANIFEST_MAX_STRING_SIZE)
|
| - error (_("Mapped file name in manifest is too long."));
|
| - strcat (curr->name, SLASH_STRING);
|
| - }
|
| - if (strlen(curr->name) + strlen(name) >= MANIFEST_MAX_STRING_SIZE)
|
| - error (_("Mapped file name in manifest is too long."));
|
| - strcat (curr->name, name);
|
| + append_dir_name (r, curr->name, MANIFEST_MAX_STRING_SIZE, name);
|
|
|
| curr->next = *nacl_file_list;
|
| *nacl_file_list = curr;
|
| @@ -194,9 +206,17 @@ json_on_string_value (struct json_manifest_reader *r, const char *value)
|
| {
|
| /* We'll xfree nacl_program_filename_* in nacl_manifest_free. */
|
| if (strcmp (r->members[1], "x86-32") == 0)
|
| - nacl_program_filename_32 = xstrdup (value);
|
| + {
|
| + nacl_program_filename_32 = malloc (MANIFEST_MAX_STRING_SIZE);
|
| + append_dir_name (r, nacl_program_filename_32,
|
| + MANIFEST_MAX_STRING_SIZE, value);
|
| + }
|
| else if (strcmp (r->members[1], "x86-64") == 0)
|
| - nacl_program_filename_64 = xstrdup (value);
|
| + {
|
| + nacl_program_filename_64 = malloc (MANIFEST_MAX_STRING_SIZE);
|
| + append_dir_name (r, nacl_program_filename_64,
|
| + MANIFEST_MAX_STRING_SIZE, value);
|
| + }
|
| }
|
| else if (r->nesting == 4 &&
|
| strcmp (r->members[0], "files") == 0 &&
|
| @@ -329,6 +349,19 @@ nacl_irt_command (char *args, int from_tty)
|
| }
|
| }
|
|
|
| +static struct observer *about_to_proceed_observer = NULL;
|
| +
|
| +static void
|
| +about_to_proceed_hook ()
|
| +{
|
| + if (exec_bfd == NULL)
|
| + {
|
| + const char *filename = nacl_manifest_find ("NaClMain");
|
| + exec_file_attach (filename, 0);
|
| + symbol_file_add (filename, SYMFILE_MAINLINE, NULL, 0);
|
| + }
|
| +}
|
| +
|
| static void
|
| nacl_manifest_command (char *args, int from_tty)
|
| {
|
| @@ -355,6 +388,12 @@ nacl_manifest_command (char *args, int from_tty)
|
|
|
| solib_add (NULL, from_tty, NULL, 1);
|
|
|
| + if (about_to_proceed_observer == NULL)
|
| + {
|
| + about_to_proceed_observer
|
| + = observer_attach_about_to_proceed (about_to_proceed_hook);
|
| + }
|
| +
|
| do_cleanups(old_chain);
|
| }
|
| }
|
|
|