[patch][commit] Two problems with --gprof

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch][commit] Two problems with --gprof

Dave Brolley-2
Hi,

I've committed this patch which addresses two minor problems with the
--gprof option.

1) The change to sidcpuutil.h addresses a problem in which
--gprof=<file>,cycles was not recognized (i.e. cycles specified with no
value -- default should be 1).

2) The change to commonCfg.cxx fixes an off-by-one problem which was
causing an underflow.

Tested on the internal port which exposed the problems.

Dave

sid/include/ChangeLog:
2006-09-27  Dave Brolley  <[hidden email]>

        * sidcpuutil.h (basic_cpu::configure): Set gprof_prev_cycle to
        total_insn_count when gprof 'cycles' not specified.

sid/main/dynamic/ChangeLog:
2006-09-27  Dave Brolley  <[hidden email]>

        * commonCfg.cxx (profile_opt_gprof_value): Handle "gprof=<file>,cycles".


Index: sid/include/sidcpuutil.h
===================================================================
RCS file: /cvs/src/src/sid/include/sidcpuutil.h,v
retrieving revision 1.38
diff -c -p -r1.38 sidcpuutil.h
*** sid/include/sidcpuutil.h 26 Jun 2006 21:04:00 -0000 1.38
--- sid/include/sidcpuutil.h 27 Sep 2006 20:22:50 -0000
*************** namespace sidutil
*** 662,668 ****
     // Set the state so that the next insn will be sampled,
     // followed by samples at the specified interval.
     gprof_counter = step_insn_count - 1;
!    gprof_prev_cycle = this->total_insn_count - 1;
   }
       }
     return;
--- 662,668 ----
     // Set the state so that the next insn will be sampled,
     // followed by samples at the specified interval.
     gprof_counter = step_insn_count - 1;
!    gprof_prev_cycle = this->total_insn_count;
   }
       }
     return;
Index: sid/main/dynamic/commonCfg.cxx
===================================================================
RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.cxx,v
retrieving revision 1.17
diff -c -p -r1.17 commonCfg.cxx
*** sid/main/dynamic/commonCfg.cxx 19 Sep 2006 18:40:56 -0000 1.17
--- sid/main/dynamic/commonCfg.cxx 27 Sep 2006 20:22:50 -0000
*************** SessionCfg::profile_opt_gprof_value (con
*** 776,793 ****
      profile_config_error (opt); // doesn't return
 
    vector<string> sub_parts = sidutil::tokenize (opt_parts[1], ",");
    string value = sub_parts[0];
!   if (size == 3)
      {
!       if (sub_parts.size () != 2 || sub_parts[1] != "cycles")
! profile_config_error (opt); // doesn't return
!
!       unsigned n;
!       sid::component::status s = sidutil::parse_attribute (opt_parts[2], n);
!       if (s != sid::component::ok)
  profile_config_error (opt); // doesn't return
 
!       value += "," + opt_parts[2];
      }
 
    need_gprof = true;
--- 776,800 ----
      profile_config_error (opt); // doesn't return
 
    vector<string> sub_parts = sidutil::tokenize (opt_parts[1], ",");
+   if (sub_parts.size () > 2)
+     profile_config_error (opt); // doesn't return
+
    string value = sub_parts[0];
!   if (sub_parts.size () == 2)
      {
!       if (sub_parts[1] != "cycles")
  profile_config_error (opt); // doesn't return
 
!       if (size == 3)
! {
!  unsigned n;
!  sid::component::status s = sidutil::parse_attribute (opt_parts[2], n);
!  if (s != sid::component::ok)
!    profile_config_error (opt); // doesn't return
!  value += "," + opt_parts[2];
! }
!       else
! value += ",1";
      }
 
    need_gprof = true;
Reply | Threaded
Open this post in threaded view
|

Re: [patch][commit] Two problems with --gprof

Dave Brolley-2
Ooops --- I got 1) and 2) reversed below...

Dave Brolley wrote:

> Hi,
>
> I've committed this patch which addresses two minor problems with the
> --gprof option.
>
> 1) The change to sidcpuutil.h addresses a problem in which
> --gprof=<file>,cycles was not recognized (i.e. cycles specified with
> no value -- default should be 1).
>
> 2) The change to commonCfg.cxx fixes an off-by-one problem which was
> causing an underflow.
>
> Tested on the internal port which exposed the problems.
>
> Dave
>
>------------------------------------------------------------------------
>
>sid/include/ChangeLog:
>2006-09-27  Dave Brolley  <[hidden email]>
>
> * sidcpuutil.h (basic_cpu::configure): Set gprof_prev_cycle to
> total_insn_count when gprof 'cycles' not specified.
>
>sid/main/dynamic/ChangeLog:
>2006-09-27  Dave Brolley  <[hidden email]>
>
> * commonCfg.cxx (profile_opt_gprof_value): Handle "gprof=<file>,cycles".
>
>  
>
>------------------------------------------------------------------------
>
>Index: sid/include/sidcpuutil.h
>===================================================================
>RCS file: /cvs/src/src/sid/include/sidcpuutil.h,v
>retrieving revision 1.38
>diff -c -p -r1.38 sidcpuutil.h
>*** sid/include/sidcpuutil.h 26 Jun 2006 21:04:00 -0000 1.38
>--- sid/include/sidcpuutil.h 27 Sep 2006 20:22:50 -0000
>*************** namespace sidutil
>*** 662,668 ****
>      // Set the state so that the next insn will be sampled,
>      // followed by samples at the specified interval.
>      gprof_counter = step_insn_count - 1;
>!    gprof_prev_cycle = this->total_insn_count - 1;
>    }
>        }
>      return;
>--- 662,668 ----
>      // Set the state so that the next insn will be sampled,
>      // followed by samples at the specified interval.
>      gprof_counter = step_insn_count - 1;
>!    gprof_prev_cycle = this->total_insn_count;
>    }
>        }
>      return;
>Index: sid/main/dynamic/commonCfg.cxx
>===================================================================
>RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.cxx,v
>retrieving revision 1.17
>diff -c -p -r1.17 commonCfg.cxx
>*** sid/main/dynamic/commonCfg.cxx 19 Sep 2006 18:40:56 -0000 1.17
>--- sid/main/dynamic/commonCfg.cxx 27 Sep 2006 20:22:50 -0000
>*************** SessionCfg::profile_opt_gprof_value (con
>*** 776,793 ****
>      profile_config_error (opt); // doesn't return
>  
>    vector<string> sub_parts = sidutil::tokenize (opt_parts[1], ",");
>    string value = sub_parts[0];
>!   if (size == 3)
>      {
>!       if (sub_parts.size () != 2 || sub_parts[1] != "cycles")
>! profile_config_error (opt); // doesn't return
>!
>!       unsigned n;
>!       sid::component::status s = sidutil::parse_attribute (opt_parts[2], n);
>!       if (s != sid::component::ok)
>   profile_config_error (opt); // doesn't return
>  
>!       value += "," + opt_parts[2];
>      }
>  
>    need_gprof = true;
>--- 776,800 ----
>      profile_config_error (opt); // doesn't return
>  
>    vector<string> sub_parts = sidutil::tokenize (opt_parts[1], ",");
>+   if (sub_parts.size () > 2)
>+     profile_config_error (opt); // doesn't return
>+
>    string value = sub_parts[0];
>!   if (sub_parts.size () == 2)
>      {
>!       if (sub_parts[1] != "cycles")
>   profile_config_error (opt); // doesn't return
>  
>!       if (size == 3)
>! {
>!  unsigned n;
>!  sid::component::status s = sidutil::parse_attribute (opt_parts[2], n);
>!  if (s != sid::component::ok)
>!    profile_config_error (opt); // doesn't return
>!  value += "," + opt_parts[2];
>! }
>!       else
>! value += ",1";
>      }
>  
>    need_gprof = true;
>  
>