Print this page
11238 librtld_db demos should work with gcc 7


 359                 }
 360                 clear_breaks(ph);
 361 
 362                 /*
 363                  * If this was a BP at which we should stop
 364                  */
 365                 if (bpt->bl_flags & MASK_BP_STOP)
 366                         break;
 367 
 368                 (void) step_n(ph, 1, FLG_SN_NONE);
 369         }
 370 
 371         if (bpt->bl_flags & FLG_BP_USERDEF)
 372                 (void) printf("break point reached at addr: 0x%x\n",
 373                     EC_WORD(pstatus.pr_lwp.pr_reg[R_PC]));
 374 
 375         if (bpt->bl_flags & MASK_BP_SPECIAL)
 376                 handle_sp_break(ph);
 377 
 378         if (ph->pp_flags & FLG_PP_LMAPS) {
 379                 if (get_linkmaps(ph) != PS_OK)
 380                         (void) fprintf(stderr, "problem loading linkmaps\n");
 381         }
 382 
 383         return (bpt->bl_flags);
 384 }
 385 
 386 ulong_t
 387 is_plt(struct ps_prochandle *ph, ulong_t pc)
 388 {
 389         map_info_t      *mip;
 390         ulong_t         pltbase;
 391 
 392         if ((mip = addr_to_map(ph, pc)) == (map_info_t *)0)
 393                 return ((ulong_t)0);
 394 
 395         pltbase = mip->mi_pltbase;
 396         if ((mip->mi_flags & FLG_MI_EXEC) == 0)
 397                 pltbase += mip->mi_addr;
 398 
 399         if ((pc >= pltbase) && (pc <= (pltbase + mip->mi_pltsize)))


 482                                 (void) set_breakpoint(ph, rp.pi_target,
 483                                     FLG_BP_PLTRES);
 484                                 bpflags = continue_to_break(ph);
 485 
 486                                 (void) delete_breakpoint(ph, rp.pi_target,
 487                                     FLG_BP_PLTRES);
 488 
 489                                 if (bpflags & FLG_BP_PLTRES)
 490                                         (void) step_n(ph, rp.pi_nstep,
 491                                             FLG_SN_NONE);
 492                         } else if (rp.pi_skip_method == RD_RESOLVE_STEP)
 493                                 (void) step_n(ph, rp.pi_nstep, FLG_SN_NONE);
 494                 }
 495         }
 496 
 497         oper = PRCFAULT;
 498         if (writev(ph->pp_ctlfd, piov, 1) == -1)
 499                 perr("stn: PRCFAULT");
 500 
 501         if ((flgs & FLG_SN_VERBOSE) && (ph->pp_flags & FLG_PP_LMAPS)) {
 502                 if (get_linkmaps(ph) != PS_OK)
 503                         (void) fprintf(stderr, "problem loading linkmaps\n");
 504         }
 505 
 506         return (RET_OK);
 507 }
 508 
 509 void
 510 step_to_addr(struct ps_prochandle *ph, ulong_t addr)
 511 {
 512         pstatus_t       pstat;
 513         int             count = 0;
 514         ulong_t         caddr;
 515 
 516         if (read(ph->pp_statusfd, &pstat, sizeof (pstat)) == -1)
 517                 perr("sta: reading status");
 518 
 519         caddr = pstat.pr_lwp.pr_reg[R_PC];
 520 
 521         while ((caddr > addr) || ((caddr + 0xff) < addr)) {
 522                 (void) step_n(ph, 1, FLG_SN_NONE);


 359                 }
 360                 clear_breaks(ph);
 361 
 362                 /*
 363                  * If this was a BP at which we should stop
 364                  */
 365                 if (bpt->bl_flags & MASK_BP_STOP)
 366                         break;
 367 
 368                 (void) step_n(ph, 1, FLG_SN_NONE);
 369         }
 370 
 371         if (bpt->bl_flags & FLG_BP_USERDEF)
 372                 (void) printf("break point reached at addr: 0x%x\n",
 373                     EC_WORD(pstatus.pr_lwp.pr_reg[R_PC]));
 374 
 375         if (bpt->bl_flags & MASK_BP_SPECIAL)
 376                 handle_sp_break(ph);
 377 
 378         if (ph->pp_flags & FLG_PP_LMAPS) {
 379                 if (get_linkmaps(ph) != RET_OK)
 380                         (void) fprintf(stderr, "problem loading linkmaps\n");
 381         }
 382 
 383         return (bpt->bl_flags);
 384 }
 385 
 386 ulong_t
 387 is_plt(struct ps_prochandle *ph, ulong_t pc)
 388 {
 389         map_info_t      *mip;
 390         ulong_t         pltbase;
 391 
 392         if ((mip = addr_to_map(ph, pc)) == (map_info_t *)0)
 393                 return ((ulong_t)0);
 394 
 395         pltbase = mip->mi_pltbase;
 396         if ((mip->mi_flags & FLG_MI_EXEC) == 0)
 397                 pltbase += mip->mi_addr;
 398 
 399         if ((pc >= pltbase) && (pc <= (pltbase + mip->mi_pltsize)))


 482                                 (void) set_breakpoint(ph, rp.pi_target,
 483                                     FLG_BP_PLTRES);
 484                                 bpflags = continue_to_break(ph);
 485 
 486                                 (void) delete_breakpoint(ph, rp.pi_target,
 487                                     FLG_BP_PLTRES);
 488 
 489                                 if (bpflags & FLG_BP_PLTRES)
 490                                         (void) step_n(ph, rp.pi_nstep,
 491                                             FLG_SN_NONE);
 492                         } else if (rp.pi_skip_method == RD_RESOLVE_STEP)
 493                                 (void) step_n(ph, rp.pi_nstep, FLG_SN_NONE);
 494                 }
 495         }
 496 
 497         oper = PRCFAULT;
 498         if (writev(ph->pp_ctlfd, piov, 1) == -1)
 499                 perr("stn: PRCFAULT");
 500 
 501         if ((flgs & FLG_SN_VERBOSE) && (ph->pp_flags & FLG_PP_LMAPS)) {
 502                 if (get_linkmaps(ph) != RET_OK)
 503                         (void) fprintf(stderr, "problem loading linkmaps\n");
 504         }
 505 
 506         return (RET_OK);
 507 }
 508 
 509 void
 510 step_to_addr(struct ps_prochandle *ph, ulong_t addr)
 511 {
 512         pstatus_t       pstat;
 513         int             count = 0;
 514         ulong_t         caddr;
 515 
 516         if (read(ph->pp_statusfd, &pstat, sizeof (pstat)) == -1)
 517                 perr("sta: reading status");
 518 
 519         caddr = pstat.pr_lwp.pr_reg[R_PC];
 520 
 521         while ((caddr > addr) || ((caddr + 0xff) < addr)) {
 522                 (void) step_n(ph, 1, FLG_SN_NONE);