along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "arch-utils.h"
#include "symtab.h"
#include "expression.h"
#include "language.h"
}
/* Open a file named STRING, searching path PATH (dir names sep by some char)
- using mode MODE and protection bits PROT in the calls to open.
+ using mode MODE in the calls to open. You cannot use this function to
+ create files (O_CREAT).
OPTS specifies the function behaviour in specific cases.
>>>> eg executable, non-directory */
int
openp (const char *path, int opts, const char *string,
- int mode, int prot,
- char **filename_opened)
+ int mode, char **filename_opened)
{
int fd;
char *filename;
int len;
int alloclen;
+ /* The open syscall MODE parameter is not specified. */
+ gdb_assert ((mode & O_CREAT) == 0);
+
if (!path)
path = ".";
{
filename = alloca (strlen (string) + 1);
strcpy (filename, string);
- fd = open (filename, mode, prot);
+ fd = open (filename, mode);
if (fd >= 0)
goto done;
}
int fd;
fd = openp (source_path, OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH, filename,
- O_RDONLY, 0, full_pathname);
+ O_RDONLY, full_pathname);
if (fd < 0)
{
*full_pathname = NULL;
}
/* This function is capable of finding the absolute path to a
- source file, and opening it, provided you give it an
- OBJFILE and FILENAME. Both the DIRNAME and FULLNAME are only
- added suggestions on where to find the file.
+ source file, and opening it, provided you give it a FILENAME. Both the
+ DIRNAME and FULLNAME are only added suggestions on where to find the file.
- OBJFILE should be the objfile associated with a psymtab or symtab.
FILENAME should be the filename to open.
DIRNAME is the compilation directory of a particular source file.
Only some debug formats provide this info.
FULLNAME is set to NULL. */
static int
-find_and_open_source (struct objfile *objfile,
- const char *filename,
+find_and_open_source (const char *filename,
const char *dirname,
char **fullname)
{
}
}
- result = openp (path, OPF_SEARCH_IN_PATH, filename, OPEN_MODE, 0, fullname);
+ result = openp (path, OPF_SEARCH_IN_PATH, filename, OPEN_MODE, fullname);
if (result < 0)
{
/* Didn't work. Try using just the basename. */
p = lbasename (filename);
if (p != filename)
- result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, 0, fullname);
+ result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, fullname);
}
return result;
if (!s)
return -1;
- return find_and_open_source (s->objfile, s->filename, s->dirname,
- &s->fullname);
+ return find_and_open_source (s->filename, s->dirname, &s->fullname);
}
/* Finds the fullname that a symtab represents.
/* Don't check s->fullname here, the file could have been
deleted/moved/..., look for it again */
- r = find_and_open_source (s->objfile, s->filename, s->dirname,
- &s->fullname);
+ r = find_and_open_source (s->filename, s->dirname, &s->fullname);
if (r >= 0)
{
/* Don't check ps->fullname here, the file could have been
deleted/moved/..., look for it again */
- r = find_and_open_source (ps->objfile, ps->filename, ps->dirname,
- &ps->fullname);
+ r = find_and_open_source (ps->filename, ps->dirname, &ps->fullname);
if (r >= 0)
{
/* Don't index off the end of the line_charpos array. */
return 0;
annotate_source (s->fullname, line, s->line_charpos[line - 1],
- mid_statement, pc);
+ mid_statement, get_objfile_arch (s->objfile), pc);
current_source_line = line;
first_line_listed = line;
if (sal.symtab == 0)
{
+ struct gdbarch *gdbarch = get_current_arch ();
+
printf_filtered (_("No line number information available"));
if (sal.pc != 0)
{
address. */
printf_filtered (" for address ");
wrap_here (" ");
- print_address (sal.pc, gdb_stdout);
+ print_address (gdbarch, sal.pc, gdb_stdout);
}
else
printf_filtered (".");
else if (sal.line > 0
&& find_line_pc_range (sal, &start_pc, &end_pc))
{
+ struct gdbarch *gdbarch = get_objfile_arch (sal.symtab->objfile);
+
if (start_pc == end_pc)
{
printf_filtered ("Line %d of \"%s\"",
sal.line, sal.symtab->filename);
wrap_here (" ");
printf_filtered (" is at address ");
- print_address (start_pc, gdb_stdout);
+ print_address (gdbarch, start_pc, gdb_stdout);
wrap_here (" ");
printf_filtered (" but contains no code.\n");
}
sal.line, sal.symtab->filename);
wrap_here (" ");
printf_filtered (" starts at address ");
- print_address (start_pc, gdb_stdout);
+ print_address (gdbarch, start_pc, gdb_stdout);
wrap_here (" ");
printf_filtered (" and ends at ");
- print_address (end_pc, gdb_stdout);
+ print_address (gdbarch, end_pc, gdb_stdout);
printf_filtered (".\n");
}
/* x/i should display this line's code. */
- set_next_address (current_gdbarch, start_pc);
+ set_next_address (gdbarch, start_pc);
/* Repeating "info line" should do the following line. */
last_line_listed = sal.line + 1;
if (re_exec (buf) > 0)
{
/* Match! */
- fclose (stream);
+ do_cleanups (cleanups);
print_source_lines (current_source_symtab, line, line + 1, 0);
- set_internalvar (lookup_internalvar ("_"),
- value_from_longest (builtin_type_int32,
- (LONGEST) line));
+ set_internalvar_integer (lookup_internalvar ("_"), line);
current_source_line = max (line - lines_to_list / 2, 1);
return;
}
if (re_exec (buf) > 0)
{
/* Match! */
- fclose (stream);
+ do_cleanups (cleanups);
print_source_lines (current_source_symtab, line, line + 1, 0);
- set_internalvar (lookup_internalvar ("_"),
- value_from_longest (builtin_type_int32,
- (LONGEST) line));
+ set_internalvar_integer (lookup_internalvar ("_"), line);
current_source_line = max (line - lines_to_list / 2, 1);
return;
}
line--;
if (fseek (stream, current_source_symtab->line_charpos[line - 1], 0) < 0)
{
- fclose (stream);
+ do_cleanups (cleanups);
perror_with_name (current_source_symtab->filename);
}
}