@@ -534,10 +534,6 @@ void DecompilerWidget::showVariableTooltip(QHelpEvent *event, RzCodeAnnotation *
534534 QString tooltipContent;
535535 if (var) {
536536 tooltipContent = formatVarValue (var);
537- } else {
538- // TODO: track the value of the synthetic/untracked variables and show it in the tooltip.
539- tooltipContent = QString (" <b>%1</b><br><i>(Synthetic/Untracked Variable)</i>" )
540- .arg (QString::fromUtf8 (annotation->variable .name ));
541537 }
542538 QToolTip::showText (event->globalPos (), tooltipContent, ui->textEdit );
543539}
@@ -555,36 +551,32 @@ QString DecompilerWidget::formatVarValue(RzAnalysisVar *var)
555551 }
556552 char *rawVal = rz_core_analysis_var_display (core, var, false );
557553 QString displayValue = rawVal ? QString::fromUtf8 (rawVal).trimmed () : " ??" ;
558- if (rawVal && typeStr.trimmed ().contains (" *" )) {
559- char *eq = strchr (rawVal, ' =' );
560- if (eq) {
561- QString left = QString::fromUtf8 (rawVal, eq - rawVal).trimmed ();
562- ut64 stackAddr = rz_num_math (core->num , left.toUtf8 ().constData ());
563- if (stackAddr != 0 ) {
564- ut64 pointedAddr = 0 ;
565- int ptrSize = core->analysis ->bits / 8 ;
566- int pointedAddr_state =
567- rz_io_read_at_mapped (core->io , stackAddr, (ut8 *)&pointedAddr, ptrSize);
568- if (pointedAddr_state > 0 && pointedAddr != 0 ) {
569- ut8 buf[256 ];
570- int str_state =
571- rz_io_read_at_mapped (core->io , pointedAddr, buf, sizeof (buf) - 1 );
572- if (str_state != 0 ) {
573- buf[sizeof (buf) - 1 ] = 0 ;
574- if (isprint (buf[0 ]) || buf[0 ] == ' \0 ' ) {
575- displayValue +=
576- QString (" <br><font color='#f1c40f'>value: \" %1\" </font>" )
577- .arg (QString::fromUtf8 (
578- reinterpret_cast <const char *>(buf)));
579- }
580- }
554+ rz_mem_free (rawVal);
555+ if (typeStr.contains (" *" )) {
556+ ut64 pointedAddr = 0 ;
557+ int ptrSize = core->analysis ->bits / 8 ;
558+ bool pointedAddr_state = false ;
559+ if (var->storage .type == RZ_ANALYSIS_VAR_STORAGE_REG) {
560+ pointedAddr = rz_debug_reg_get (core->dbg , var->storage .reg );
561+ pointedAddr_state = (pointedAddr != 0 );
562+ } else if (var->storage .type == RZ_ANALYSIS_VAR_STORAGE_STACK) {
563+ ut64 stackAddr = rz_core_analysis_var_addr (core, var);
564+ pointedAddr_state =
565+ rz_io_read_at_mapped (core->io , stackAddr, (ut8 *)&pointedAddr, ptrSize);
566+ }
567+ if (pointedAddr_state && pointedAddr) {
568+ ut8 buf[256 ];
569+ bool str_state = rz_io_read_at_mapped (core->io , pointedAddr, buf, sizeof (buf) - 1 );
570+ if (str_state) {
571+ size_t len = strnlen ((const char *)buf, sizeof (buf));
572+ if (len > 0 && rz_str_is_printable ((const char *)buf)) {
573+ QString str = QString::fromUtf8 ((const char *)buf, len);
574+ displayValue += QString (" \n value: \" %1\" " ).arg (str);
581575 }
582576 }
583577 }
584578 }
585- rz_mem_free (rawVal);
586- return QString (" <b>%1</b> (%2)<br>Value: %3" )
587- .arg (QString::fromUtf8 (var->name ), typeStr, displayValue);
579+ return QString (" %1 (%2)\n Value: %3" ).arg (QString::fromUtf8 (var->name ), typeStr, displayValue);
588580}
589581
590582bool DecompilerWidget::eventFilter (QObject *obj, QEvent *event)
0 commit comments