* [10/19] record_line
@ 2009-06-05 21:18 Ulrich Weigand
2009-06-06 1:15 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2009-06-05 21:18 UTC (permalink / raw)
To: gdb-patches
Hello,
the record_line routine calls gdbarch_addr_bits_remove on the PC it is
passed. As there is no appropriate objfile at hand in this routine,
the following patch moves this operation up into the callers of record_line,
which will use the objfile architecture of the file they are processing.
Bye,
Ulrich
ChangeLog:
* buildsym.c (record_line): Remove call to gdbarch_addr_bits_remove.
* coffread.c (coff_symtab_read): Call gdbarch_addr_bits_remove before
calling record_line.
(enter_linenos): Likewise.
* dbxread.c (process_one_symbol): Likewise.
* dwarf2read.c (dwarf_decode_lines): Likewise.
* mdebugread.c (psymtab_to_symtab_1): Likewise.
* xcoffread.c (enter_line_range): Likewise.
Index: gdb-head/gdb/buildsym.c
===================================================================
--- gdb-head.orig/gdb/buildsym.c
+++ gdb-head/gdb/buildsym.c
@@ -731,8 +731,6 @@ record_line (struct subfile *subfile, in
* sizeof (struct linetable_entry))));
}
- pc = gdbarch_addr_bits_remove (current_gdbarch, pc);
-
/* Normally, we treat lines as unsorted. But the end of sequence
marker is special. We sort line markers at the same PC by line
number, so end of sequence markers (which have line == 0) appear
Index: gdb-head/gdb/coffread.c
===================================================================
--- gdb-head.orig/gdb/coffread.c
+++ gdb-head/gdb/coffread.c
@@ -1024,7 +1024,8 @@ coff_symtab_read (long symtab_offset, un
for which we do not have any other statement-line-number. */
if (fcn_last_line == 1)
record_line (current_subfile, fcn_first_line,
- fcn_first_line_addr);
+ gdbarch_addr_bits_remove (gdbarch,
+ fcn_first_line_addr));
else
enter_linenos (fcn_line_ptr, fcn_first_line, fcn_last_line,
objfile);
@@ -1350,6 +1351,7 @@ static void
enter_linenos (long file_offset, int first_line,
int last_line, struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
char *rawptr;
struct internal_lineno lptr;
@@ -1382,9 +1384,12 @@ enter_linenos (long file_offset, int fir
/* The next function, or the sentinel, will have L_LNNO32 zero;
we exit. */
if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line)
- record_line (current_subfile, first_line + L_LNNO32 (&lptr),
- lptr.l_addr.l_paddr
- + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)));
+ {
+ CORE_ADDR addr = lptr.l_addr.l_paddr;
+ addr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+ record_line (current_subfile, first_line + L_LNNO32 (&lptr),
+ gdbarch_addr_bits_remove (gdbarch, addr));
+ }
else
break;
}
Index: gdb-head/gdb/dbxread.c
===================================================================
--- gdb-head.orig/gdb/dbxread.c
+++ gdb-head/gdb/dbxread.c
@@ -2790,7 +2790,11 @@ process_one_symbol (int type, int desc,
which may have an N_FUN stabs at the end of the function,
but no N_SLINE stabs. */
if (sline_found_in_function)
- record_line (current_subfile, 0, last_function_start + valu);
+ {
+ CORE_ADDR addr = last_function_start + valu;
+ record_line (current_subfile, 0,
+ gdbarch_addr_bits_remove (gdbarch, addr));
+ }
within_function = 0;
new = pop_context ();
@@ -3006,14 +3010,15 @@ no enclosing block"));
if (within_function && sline_found_in_function == 0)
{
- if (processing_gcc_compilation == 2)
- record_line (current_subfile, desc, last_function_start);
- else
- record_line (current_subfile, desc, valu);
+ CORE_ADDR addr = processing_gcc_compilation == 2 ?
+ last_function_start : valu;
+ record_line (current_subfile, desc,
+ gdbarch_addr_bits_remove (gdbarch, addr));
sline_found_in_function = 1;
}
else
- record_line (current_subfile, desc, valu);
+ record_line (current_subfile, desc,
+ gdbarch_addr_bits_remove (gdbarch, valu));
break;
case N_BCOMM:
Index: gdb-head/gdb/dwarf2read.c
===================================================================
--- gdb-head.orig/gdb/dwarf2read.c
+++ gdb-head/gdb/dwarf2read.c
@@ -7247,6 +7247,7 @@ dwarf_decode_lines (struct line_header *
unsigned char op_code, extended_op, adj_opcode;
CORE_ADDR baseaddr;
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
const int decode_for_pst_p = (pst != NULL);
struct subfile *last_subfile = NULL, *first_subfile = current_subfile;
@@ -7266,6 +7267,7 @@ dwarf_decode_lines (struct line_header *
int is_stmt = lh->default_is_stmt;
int basic_block = 0;
int end_sequence = 0;
+ CORE_ADDR addr;
if (!decode_for_pst_p && lh->num_file_names >= file)
{
@@ -7306,16 +7308,18 @@ dwarf_decode_lines (struct line_header *
{
lh->file_names[file - 1].included_p = 1;
if (!decode_for_pst_p)
- {
- if (last_subfile != current_subfile)
- {
- if (last_subfile)
- record_line (last_subfile, 0, address);
- last_subfile = current_subfile;
- }
+ {
+ if (last_subfile != current_subfile)
+ {
+ addr = gdbarch_addr_bits_remove (gdbarch, address);
+ if (last_subfile)
+ record_line (last_subfile, 0, addr);
+ last_subfile = current_subfile;
+ }
/* Append row to matrix using current values. */
- record_line (current_subfile, line,
- check_cu_functions (address, cu));
+ addr = check_cu_functions (address, cu);
+ addr = gdbarch_addr_bits_remove (gdbarch, addr);
+ record_line (current_subfile, line, addr);
}
}
basic_block = 1;
@@ -7379,16 +7383,18 @@ dwarf_decode_lines (struct line_header *
{
lh->file_names[file - 1].included_p = 1;
if (!decode_for_pst_p)
- {
- if (last_subfile != current_subfile)
- {
- if (last_subfile)
- record_line (last_subfile, 0, address);
- last_subfile = current_subfile;
- }
- record_line (current_subfile, line,
- check_cu_functions (address, cu));
- }
+ {
+ if (last_subfile != current_subfile)
+ {
+ addr = gdbarch_addr_bits_remove (gdbarch, address);
+ if (last_subfile)
+ record_line (last_subfile, 0, addr);
+ last_subfile = current_subfile;
+ }
+ addr = check_cu_functions (address, cu);
+ addr = gdbarch_addr_bits_remove (gdbarch, addr);
+ record_line (current_subfile, line, addr);
+ }
}
basic_block = 0;
break;
@@ -7468,7 +7474,10 @@ dwarf_decode_lines (struct line_header *
{
lh->file_names[file - 1].included_p = 1;
if (!decode_for_pst_p)
- record_line (current_subfile, 0, address);
+ {
+ addr = gdbarch_addr_bits_remove (gdbarch, address);
+ record_line (current_subfile, 0, addr);
+ }
}
}
Index: gdb-head/gdb/mdebugread.c
===================================================================
--- gdb-head.orig/gdb/mdebugread.c
+++ gdb-head/gdb/mdebugread.c
@@ -3966,6 +3966,7 @@ psymtab_to_symtab_1 (struct partial_symt
if (processing_gcc_compilation != 0)
{
+ struct gdbarch *gdbarch = get_objfile_arch (pst->objfile);
/* This symbol table contains stabs-in-ecoff entries. */
@@ -4060,7 +4061,8 @@ psymtab_to_symtab_1 (struct partial_symt
{
/* Handle encoded stab line number. */
valu += ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (pst->objfile));
- record_line (current_subfile, sh.index, valu);
+ record_line (current_subfile, sh.index,
+ gdbarch_addr_bits_remove (gdbarch, valu));
}
}
else if (sh.st == stProc || sh.st == stStaticProc
Index: gdb-head/gdb/xcoffread.c
===================================================================
--- gdb-head.orig/gdb/xcoffread.c
+++ gdb-head/gdb/xcoffread.c
@@ -765,6 +765,8 @@ enter_line_range (struct subfile *subfil
CORE_ADDR startaddr, /* offsets to line table */
CORE_ADDR endaddr, unsigned *firstLine)
{
+ struct objfile *objfile = this_symtab_psymtab->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
unsigned int curoffset;
CORE_ADDR addr;
void *ext_lnno;
@@ -777,7 +779,7 @@ enter_line_range (struct subfile *subfil
return;
curoffset = beginoffset;
limit_offset =
- ((struct coff_symfile_info *) this_symtab_psymtab->objfile->deprecated_sym_private)
+ ((struct coff_symfile_info *) objfile->deprecated_sym_private)
->max_lineno_offset;
if (endoffset != 0)
@@ -793,7 +795,7 @@ enter_line_range (struct subfile *subfil
else
limit_offset -= 1;
- abfd = this_symtab_psymtab->objfile->obfd;
+ abfd = objfile->obfd;
linesz = coff_data (abfd)->local_linesz;
ext_lnno = alloca (linesz);
@@ -807,8 +809,7 @@ enter_line_range (struct subfile *subfil
addr = (int_lnno.l_lnno
? int_lnno.l_addr.l_paddr
: read_symbol_nvalue (int_lnno.l_addr.l_symndx));
- addr += ANOFFSET (this_symtab_psymtab->objfile->section_offsets,
- SECT_OFF_TEXT (this_symtab_psymtab->objfile));
+ addr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (addr < startaddr || (endaddr && addr >= endaddr))
return;
@@ -816,11 +817,12 @@ enter_line_range (struct subfile *subfil
if (int_lnno.l_lnno == 0)
{
*firstLine = read_symbol_lineno (int_lnno.l_addr.l_symndx);
- record_line (subfile, 0, addr);
+ record_line (subfile, 0, gdbarch_addr_bits_remove (gdbarch, addr));
--(*firstLine);
}
else
- record_line (subfile, *firstLine + int_lnno.l_lnno, addr);
+ record_line (subfile, *firstLine + int_lnno.l_lnno,
+ gdbarch_addr_bits_remove (gdbarch, addr));
curoffset += linesz;
}
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [10/19] record_line
2009-06-05 21:18 [10/19] record_line Ulrich Weigand
@ 2009-06-06 1:15 ` Eli Zaretskii
2009-06-08 14:53 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2009-06-06 1:15 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> Date: Fri, 5 Jun 2009 23:18:16 +0200 (CEST)
> From: "Ulrich Weigand" <uweigand@de.ibm.com>
>
> the record_line routine calls gdbarch_addr_bits_remove on the PC it is
> passed. As there is no appropriate objfile at hand in this routine,
> the following patch moves this operation up into the callers of record_line,
> which will use the objfile architecture of the file they are processing.
Maybe I'm missing something, but isn't this rather inelegant? We are
moving some detail that is private to record_line into its callers,
just because record_line doesn't know the architecture nor the objfile
to get the architecture from? Why not simply pass the architecture or
the objfile to record_line instead?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [10/19] record_line
2009-06-06 1:15 ` Eli Zaretskii
@ 2009-06-08 14:53 ` Ulrich Weigand
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2009-06-08 14:53 UTC (permalink / raw)
To: eliz; +Cc: gdb-patches
Eli Zaretskii wrote:
> > Date: Fri, 5 Jun 2009 23:18:16 +0200 (CEST)
> > From: "Ulrich Weigand" <uweigand@de.ibm.com>
> >
> > the record_line routine calls gdbarch_addr_bits_remove on the PC it is
> > passed. As there is no appropriate objfile at hand in this routine,
> > the following patch moves this operation up into the callers of record_line,
> > which will use the objfile architecture of the file they are processing.
>
> Maybe I'm missing something, but isn't this rather inelegant? We are
> moving some detail that is private to record_line into its callers,
> just because record_line doesn't know the architecture nor the objfile
> to get the architecture from? Why not simply pass the architecture or
> the objfile to record_line instead?
Well, I guess I didn't really express this in the patch email, but it seemed
to me that calling gdbarch_addr_bits_remove should't really be a private
detail of record_line. IMO this routine should simply take an actual PC
as input, as its comment states -- whatever hacks are required to compute
an actual PC value from information found in the object file should be done
in the symbol readers themselves (this might actually depend on the format).
For the purposes of this patch series, passing an objfile in to record_line
would work for me as well. It just didn't seem quite the right thing ..
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-06-08 14:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-05 21:18 [10/19] record_line Ulrich Weigand
2009-06-06 1:15 ` Eli Zaretskii
2009-06-08 14:53 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox