projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a new 'info proc files' subcommand of 'info proc'.
[deliverable/binutils-gdb.git]
/
gdb
/
source.c
diff --git
a/gdb/source.c
b/gdb/source.c
index 3b4920fe8a4028b0d85a5096d3f4445233fb05b3..ec0ea3b81e37fd10c3a75ab030a5688a37aef66e 100644
(file)
--- a/
gdb/source.c
+++ b/
gdb/source.c
@@
-42,6
+42,7
@@
#include "ui-out.h"
#include "readline/readline.h"
#include "common/enum-flags.h"
#include "ui-out.h"
#include "readline/readline.h"
#include "common/enum-flags.h"
+#include "common/scoped_fd.h"
#include <algorithm>
#include "common/pathstuff.h"
#include <algorithm>
#include "common/pathstuff.h"
@@
-478,13
+479,12
@@
add_path (const char *dirname, char **which_path, int parse_separators)
else
dir_vec.emplace_back (xstrdup (dirname));
else
dir_vec.emplace_back (xstrdup (dirname));
- struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
-
for (const gdb::unique_xmalloc_ptr<char> &name_up : dir_vec)
{
char *name = name_up.get ();
char *p;
struct stat st;
for (const gdb::unique_xmalloc_ptr<char> &name_up : dir_vec)
{
char *name = name_up.get ();
char *p;
struct stat st;
+ gdb::unique_xmalloc_ptr<char> new_name_holder;
/* Spaces and tabs will have been removed by buildargv().
NAME is the start of the directory.
/* Spaces and tabs will have been removed by buildargv().
NAME is the start of the directory.
@@
-530,16
+530,17
@@
add_path (const char *dirname, char **which_path, int parse_separators)
}
if (name[0] == '~')
}
if (name[0] == '~')
- n
ame = tilde_expand (name
);
+ n
ew_name_holder.reset (tilde_expand (name)
);
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
- n
ame = concat (name, ".", (char *)NULL
);
+ n
ew_name_holder.reset (concat (name, ".", (char *) NULL)
);
#endif
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
#endif
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
- name = concat (current_directory, SLASH_STRING, name, (char *)NULL);
+ new_name_holder.reset (concat (current_directory, SLASH_STRING, name,
+ (char *) NULL));
else
else
- n
ame = savestring (name, p - name
);
-
make_cleanup (xfree, name
);
+ n
ew_name_holder.reset (savestring (name, p - name)
);
+
name = new_name_holder.get (
);
/* Unless it's a variable, check existence. */
if (name[0] != '$')
/* Unless it's a variable, check existence. */
if (name[0] != '$')
@@
-629,8
+630,6
@@
add_path (const char *dirname, char **which_path, int parse_separators)
skip_dup:
;
}
skip_dup:
;
}
-
- do_cleanups (back_to);
}
}
@@
-1215,24
+1214,21
@@
find_source_lines (struct symtab *s, int desc)
static int
get_filename_and_charpos (struct symtab *s, char **fullname)
{
static int
get_filename_and_charpos (struct symtab *s, char **fullname)
{
- int desc, linenums_changed = 0;
- struct cleanup *cleanups;
+ int linenums_changed = 0;
-
desc = open_source_file (s
);
- if (desc < 0)
+
scoped_fd desc (open_source_file (s)
);
+ if (desc
.get ()
< 0)
{
if (fullname)
*fullname = NULL;
return 0;
}
{
if (fullname)
*fullname = NULL;
return 0;
}
- cleanups = make_cleanup_close (desc);
if (fullname)
*fullname = s->fullname;
if (s->line_charpos == 0)
linenums_changed = 1;
if (linenums_changed)
if (fullname)
*fullname = s->fullname;
if (s->line_charpos == 0)
linenums_changed = 1;
if (linenums_changed)
- find_source_lines (s, desc);
- do_cleanups (cleanups);
+ find_source_lines (s, desc.get ());
return linenums_changed;
}
return linenums_changed;
}
@@
-1541,10
+1537,8
@@
static void
forward_search_command (const char *regex, int from_tty)
{
int c;
forward_search_command (const char *regex, int from_tty)
{
int c;
- int desc;
int line;
char *msg;
int line;
char *msg;
- struct cleanup *cleanups;
line = last_line_listed + 1;
line = last_line_listed + 1;
@@
-1555,22
+1549,21
@@
forward_search_command (const char *regex, int from_tty)
if (current_source_symtab == 0)
select_source_symtab (0);
if (current_source_symtab == 0)
select_source_symtab (0);
-
desc = open_source_file (current_source_symtab
);
- if (desc < 0)
+
scoped_fd desc (open_source_file (current_source_symtab)
);
+ if (desc
.get ()
< 0)
perror_with_name (symtab_to_filename_for_display (current_source_symtab));
perror_with_name (symtab_to_filename_for_display (current_source_symtab));
- cleanups = make_cleanup_close (desc);
if (current_source_symtab->line_charpos == 0)
if (current_source_symtab->line_charpos == 0)
- find_source_lines (current_source_symtab, desc);
+ find_source_lines (current_source_symtab, desc
.get ()
);
if (line < 1 || line > current_source_symtab->nlines)
error (_("Expression not found"));
if (line < 1 || line > current_source_symtab->nlines)
error (_("Expression not found"));
- if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
+ if (lseek (desc.get (), current_source_symtab->line_charpos[line - 1], 0)
+ < 0)
perror_with_name (symtab_to_filename_for_display (current_source_symtab));
perror_with_name (symtab_to_filename_for_display (current_source_symtab));
- discard_cleanups (cleanups);
- gdb_file_up stream (fdopen (desc, FDOPEN_MODE));
+ gdb_file_up stream (fdopen (desc.release (), FDOPEN_MODE));
clearerr (stream.get ());
while (1)
{
clearerr (stream.get ());
while (1)
{
@@
-1626,10
+1619,8
@@
static void
reverse_search_command (const char *regex, int from_tty)
{
int c;
reverse_search_command (const char *regex, int from_tty)
{
int c;
- int desc;
int line;
char *msg;
int line;
char *msg;
- struct cleanup *cleanups;
line = last_line_listed - 1;
line = last_line_listed - 1;
@@
-1640,22
+1631,21
@@
reverse_search_command (const char *regex, int from_tty)
if (current_source_symtab == 0)
select_source_symtab (0);
if (current_source_symtab == 0)
select_source_symtab (0);
-
desc = open_source_file (current_source_symtab
);
- if (desc < 0)
+
scoped_fd desc (open_source_file (current_source_symtab)
);
+ if (desc
.get ()
< 0)
perror_with_name (symtab_to_filename_for_display (current_source_symtab));
perror_with_name (symtab_to_filename_for_display (current_source_symtab));
- cleanups = make_cleanup_close (desc);
if (current_source_symtab->line_charpos == 0)
if (current_source_symtab->line_charpos == 0)
- find_source_lines (current_source_symtab, desc);
+ find_source_lines (current_source_symtab, desc
.get ()
);
if (line < 1 || line > current_source_symtab->nlines)
error (_("Expression not found"));
if (line < 1 || line > current_source_symtab->nlines)
error (_("Expression not found"));
- if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
+ if (lseek (desc.get (), current_source_symtab->line_charpos[line - 1], 0)
+ < 0)
perror_with_name (symtab_to_filename_for_display (current_source_symtab));
perror_with_name (symtab_to_filename_for_display (current_source_symtab));
- discard_cleanups (cleanups);
- gdb_file_up stream (fdopen (desc, FDOPEN_MODE));
+ gdb_file_up stream (fdopen (desc.release (), FDOPEN_MODE));
clearerr (stream.get ());
while (line > 1)
{
clearerr (stream.get ());
while (line > 1)
{
This page took
0.02545 seconds
and
4
git commands to generate.