OLD | NEW |
1 /* Handle Native Client manifest files. | 1 /* Handle Native Client manifest files. |
2 | 2 |
3 Copyright (C) 2011 Free Software Foundation, Inc. | 3 Copyright (C) 2011 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GDB. | 5 This file is part of GDB. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 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 | 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 | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 /* GDB commands for specifying Native Client files. */ | 337 /* GDB commands for specifying Native Client files. */ |
338 | 338 |
339 static void | 339 static void |
340 nacl_irt_command (char *args, int from_tty) | 340 nacl_irt_command (char *args, int from_tty) |
341 { | 341 { |
342 if (args) | 342 if (args) |
343 { | 343 { |
| 344 char **argv; |
| 345 struct cleanup *old_chain; |
344 char *nacl_irt_filename; | 346 char *nacl_irt_filename; |
345 nacl_irt_filename = tilde_expand (args); | 347 |
| 348 argv = gdb_buildargv(args); |
| 349 old_chain = make_cleanup_freeargv(argv); |
| 350 if (*argv == NULL) |
| 351 » error (_("No IRT file name was specified")); |
| 352 |
| 353 nacl_irt_filename = tilde_expand (*argv); |
| 354 make_cleanup(xfree, nacl_irt_filename); |
| 355 |
346 symbol_file_add (nacl_irt_filename, from_tty ? SYMFILE_VERBOSE : 0, | 356 symbol_file_add (nacl_irt_filename, from_tty ? SYMFILE_VERBOSE : 0, |
347 NULL, OBJF_USERLOADED); | 357 NULL, OBJF_USERLOADED); |
348 xfree (nacl_irt_filename); | |
349 /* Recalculate frames. */ | 358 /* Recalculate frames. */ |
350 reinit_frame_cache (); | 359 reinit_frame_cache (); |
| 360 do_cleanups(old_chain); |
351 } | 361 } |
352 } | 362 } |
353 | 363 |
354 static struct observer *about_to_proceed_observer = NULL; | 364 static struct observer *about_to_proceed_observer = NULL; |
355 | 365 |
356 static void | 366 static void |
357 about_to_proceed_hook () | 367 about_to_proceed_hook () |
358 { | 368 { |
359 if (exec_bfd == NULL) | 369 if (exec_bfd == NULL) |
360 { | 370 { |
361 const char *filename = nacl_manifest_find ("NaClMain"); | 371 const char *filename = nacl_manifest_find ("NaClMain"); |
362 exec_file_attach (filename, 0); | 372 exec_file_attach (filename, 0); |
363 symbol_file_add (filename, SYMFILE_MAINLINE, NULL, 0); | 373 symbol_file_add (filename, SYMFILE_MAINLINE, NULL, 0); |
364 } | 374 } |
365 } | 375 } |
366 | 376 |
367 static void | 377 static void |
368 nacl_manifest_command (char *args, int from_tty) | 378 nacl_manifest_command (char *args, int from_tty) |
369 { | 379 { |
370 if (args) | 380 if (args) |
371 { | 381 { |
| 382 char **argv; |
| 383 struct cleanup *old_chain; |
372 char *manifest_filename; | 384 char *manifest_filename; |
373 struct cleanup *old_chain; | |
374 struct json_manifest_reader r = { 0 }; | 385 struct json_manifest_reader r = { 0 }; |
375 | 386 |
376 manifest_filename = tilde_expand (args); | 387 argv = gdb_buildargv (args); |
377 old_chain = make_cleanup (xfree, manifest_filename); | 388 old_chain = make_cleanup_freeargv (argv); |
| 389 if (*argv == NULL) |
| 390 » error (_("No manifest file name was specified")); |
| 391 |
| 392 manifest_filename = tilde_expand (*argv); |
| 393 make_cleanup (xfree, manifest_filename); |
378 | 394 |
379 r.file = fopen (manifest_filename, "r"); | 395 r.file = fopen (manifest_filename, "r"); |
380 if (!r.file) | 396 if (!r.file) |
381 perror_with_name (manifest_filename); | 397 perror_with_name (manifest_filename); |
382 make_cleanup_fclose (r.file); | 398 make_cleanup_fclose (r.file); |
383 | 399 |
384 r.dirname = ldirname (manifest_filename); | 400 r.dirname = ldirname (manifest_filename); |
385 make_cleanup (xfree, r.dirname); | 401 make_cleanup (xfree, r.dirname); |
386 | 402 |
387 /* TODO: Kill existing manifest only if new one parsed OK! */ | 403 /* TODO: Kill existing manifest only if new one parsed OK! */ |
(...skipping 19 matching lines...) Expand all Loading... |
407 | 423 |
408 c = add_com ("nacl-irt", class_files, nacl_irt_command, | 424 c = add_com ("nacl-irt", class_files, nacl_irt_command, |
409 _("Use FILE as Native Client IRT to be debugged.")); | 425 _("Use FILE as Native Client IRT to be debugged.")); |
410 set_cmd_completer (c, filename_completer); | 426 set_cmd_completer (c, filename_completer); |
411 | 427 |
412 c = add_com ("nacl-manifest", class_files, nacl_manifest_command, | 428 c = add_com ("nacl-manifest", class_files, nacl_manifest_command, |
413 _("Use FILE as Native Client manifest for the program" | 429 _("Use FILE as Native Client manifest for the program" |
414 " to be debugged.")); | 430 " to be debugged.")); |
415 set_cmd_completer (c, filename_completer); | 431 set_cmd_completer (c, filename_completer); |
416 } | 432 } |
OLD | NEW |