Index: breakpoint.c =================================================================== RCS file: /nile.c/cvs/Dev/gdb/gdb-5/gdb/breakpoint.c,v retrieving revision 1.1.1.1.2.6 diff -u -5 -r1.1.1.1.2.6 breakpoint.c --- breakpoint.c 5 Feb 2002 08:59:32 -0000 1.1.1.1.2.6 +++ breakpoint.c 6 Feb 2002 11:22:00 -0000 @@ -4726,23 +4726,41 @@ (*addr_string)[i] = savestring (addr_start, (*address) - addr_start); } } } - /* Convert each SAL into a real PC. Verify that the PC can be inserted as a breakpoint. If it can't throw an error. */ void breakpoint_sals_to_pc (struct symtabs_and_lines *sals, - char *address) + char *address, + char **address_string) { int i; for (i = 0; i < sals->nelts; i++) { resolve_sal_pc (&sals->sals[i]); + /* If the PC for the breakpoint points to the first instruction + of a function (ie the begining of a function prologue), then + skip the prologue. What happens is that certain smart linkers + such as the Tru64 linker perform some optimizations which + sometimes cause part of the prologue to be skipped. The + consequence for the user is that his breakpoint is never hit + even though his code is actually executed. + + Do not perform this adjustment if the user asked to put the + breakpoint at a specified address (using the *addr notation). + If the user goes down to this level, it is likely that he knows + what he is doing. */ + + if (address_string[i] != NULL && + address_string[i][0] != '*' && + get_pc_function_start (sals->sals[i].pc) == sals->sals[i].pc) + sals->sals[i].pc = SKIP_PROLOGUE (sals->sals[i].pc); + /* It's possible for the PC to be nonzero, but still an illegal value on some targets. For example, on HP-UX if you start gdb, and before running the inferior you try to set a breakpoint on a shared library function @@ -4834,11 +4852,11 @@ make_cleanup (free, addr_string[i]); } /* Resolve all line numbers to PC's and verify that the addresses are ok for the target. */ - breakpoint_sals_to_pc (&sals, addr_start); + breakpoint_sals_to_pc (&sals, addr_start, addr_string); /* Verify that condition can be parsed, before setting any breakpoints. Allocate a separate condition expression for each breakpoint. */ thread = -1; /* No specific thread yet */ @@ -4994,11 +5012,11 @@ memory. */ if (*address_end != '\0') error ("Garbage %s following breakpoint address", address_end); /* Resolve all line numbers to PC's. */ - breakpoint_sals_to_pc (&sals, args->address); + breakpoint_sals_to_pc (&sals, args->address, addr_string); /* Verify that conditions can be parsed, before setting any breakpoints. */ for (i = 0; i < sals.nelts; i++) { @@ -7087,10 +7105,27 @@ s = b->addr_string; sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL); for (i = 0; i < sals.nelts; i++) { resolve_sal_pc (&sals.sals[i]); + + /* If the PC for the breakpoint points to the first instruction + of a function (ie the begining of a function prologue), then + skip the prologue. What happens is that certain smart linkers + such as the Tru64 linker perform some optimizations which + sometimes cause part of the prologue to be skipped. The + consequence for the user is that his breakpoint is never + hit even though his code is actually executed. + + Do not perform this adjustment if the user asked to put the + breakpoint at a specified address (using the *addr notation). + If the user goes down to this level, it is likely that he knows + what he is doing. */ + + if (s[0] != '*' && + get_pc_function_start (sals.sals[i].pc) == sals.sals[i].pc) + sals.sals[i].pc = SKIP_PROLOGUE (sals.sals[i].pc); /* Reparse conditions, they might contain references to the old symtab. */ if (b->cond_string != NULL) {