Author: trow
Date: 2005-10-10 10:52:07 -0400 (Mon, 10 Oct 2005)
New Revision: 51514
Modified:
trunk/heap-buddy/analyzer/Backtrace.cs
trunk/heap-buddy/analyzer/BacktracesReport.cs
trunk/heap-buddy/analyzer/OutfileReader.cs
trunk/heap-buddy/analyzer/Type.cs
trunk/heap-buddy/analyzer/TypesReport.cs
trunk/heap-buddy/analyzer/Util.cs
Log:
Cleaned up matching, and added matching to the backtraces
report.
Modified: trunk/heap-buddy/analyzer/Backtrace.cs
===================================================================
--- trunk/heap-buddy/analyzer/Backtrace.cs 2005-10-10 12:50:14 UTC (rev
51513)
+++ trunk/heap-buddy/analyzer/Backtrace.cs 2005-10-10 14:52:07 UTC (rev
51514)
@@ -59,6 +59,25 @@
frames = value;
}
}
+
+ public bool MatchesType (string pattern)
+ {
+ return Type.Matches (pattern);
+ }
+
+ public bool MatchesMethod (string pattern)
+ {
+ int n = Frames.Length;
+ for (int i = 0; i < n; ++i)
+ if (Util.ContainsNoCase (frames [i].MethodName,
pattern))
+ return true;
+ return false;
+ }
+
+ public bool Matches (string pattern)
+ {
+ return MatchesType (pattern) || MatchesMethod (pattern);
+ }
}
}
Modified: trunk/heap-buddy/analyzer/BacktracesReport.cs
===================================================================
--- trunk/heap-buddy/analyzer/BacktracesReport.cs 2005-10-10 12:50:14 UTC
(rev 51513)
+++ trunk/heap-buddy/analyzer/BacktracesReport.cs 2005-10-10 14:52:07 UTC
(rev 51514)
@@ -70,6 +70,7 @@
{
SortOrder order = SortOrder.ByTotalBytes;
int max_rows = 25;
+ string match_string = null;
bool ellipsize_names = true;
// Hacky free-form arg parser
@@ -88,7 +89,10 @@
order = SortOrder.ByAverageAge;
else if (arg == "all")
max_rows = -1;
- else if (arg == "full" || arg == "long" || arg
== "unellipsized")
+ else if (arg == "match" || arg == "matching" ||
arg == "like") {
+ ++i;
+ match_string = args [i];
+ } else if (arg == "full" || arg == "long" ||
arg == "unellipsized")
ellipsize_names = false;
else {
int n = -1;
@@ -122,6 +126,8 @@
table.SetStringify (4, "0.0");
foreach (Backtrace bt in reader.Backtraces) {
+ if (match_string != null && ! bt.Matches
(match_string))
+ continue;
table.AddRow (bt,
bt.LastObjectStats.AllocatedCount,
bt.LastObjectStats.AllocatedTotalBytes,
Modified: trunk/heap-buddy/analyzer/OutfileReader.cs
===================================================================
--- trunk/heap-buddy/analyzer/OutfileReader.cs 2005-10-10 12:50:14 UTC (rev
51513)
+++ trunk/heap-buddy/analyzer/OutfileReader.cs 2005-10-10 14:52:07 UTC (rev
51514)
@@ -1093,33 +1093,10 @@
get { return backtraces; }
}
-
///////////////////////////////////////////////////////////////////
-
public Type [] Types {
get { return types; }
}
- public ArrayList GetTypesMatching (Regex regex)
- {
- if (regex == null)
- return new ArrayList (types);
-
- ArrayList matches;
- matches = new ArrayList ();
- for (int i = 0; i < types.Length; ++i)
- if (regex.Match (types [i].Name).Success)
- matches.Add (types [i]);
- return matches;
- }
-
- public ArrayList GetTypesMatching (string regex)
- {
- if (regex == null)
- return new ArrayList (types);
-
- return GetTypesMatching (new Regex (regex));
- }
-
///////////////////////////////////////////////////////////////////
private void GetMethod (uint code, out string name, out string
args)
Modified: trunk/heap-buddy/analyzer/Type.cs
===================================================================
--- trunk/heap-buddy/analyzer/Type.cs 2005-10-10 12:50:14 UTC (rev 51513)
+++ trunk/heap-buddy/analyzer/Type.cs 2005-10-10 14:52:07 UTC (rev 51514)
@@ -39,6 +39,11 @@
// Total allocation stats for this type as of the
// last generation in which there were live objects.
public ObjectStats LastObjectStats;
+
+ public bool Matches (string pattern)
+ {
+ return Util.ContainsNoCase (Name, pattern);
+ }
}
}
Modified: trunk/heap-buddy/analyzer/TypesReport.cs
===================================================================
--- trunk/heap-buddy/analyzer/TypesReport.cs 2005-10-10 12:50:14 UTC (rev
51513)
+++ trunk/heap-buddy/analyzer/TypesReport.cs 2005-10-10 14:52:07 UTC (rev
51514)
@@ -99,7 +99,9 @@
table.SetStringify (3, "0.0");
table.SetStringify (4, "0.0");
- foreach (Type type in reader.GetTypesMatching
(match_string)) {
+ foreach (Type type in reader.Types) {
+ if (match_string != null && ! type.Matches
(match_string))
+ continue;
table.AddRow (type.Name,
type.LastObjectStats.AllocatedCount,
type.LastObjectStats.AllocatedTotalBytes,
Modified: trunk/heap-buddy/analyzer/Util.cs
===================================================================
--- trunk/heap-buddy/analyzer/Util.cs 2005-10-10 12:50:14 UTC (rev 51513)
+++ trunk/heap-buddy/analyzer/Util.cs 2005-10-10 14:52:07 UTC (rev 51514)
@@ -32,6 +32,16 @@
return base_time.AddSeconds (time_t);
}
+
/////////////////////////////////////////////////////////////////////////////////////
+
+ static public bool ContainsNoCase (string haystack, string
needle)
+ {
+ // FIXME: This could be much more efficient
+ return haystack.ToLower ().IndexOf (needle.ToLower ())
>= 0;
+ }
+
+
/////////////////////////////////////////////////////////////////////////////////////
+
static public string Ellipsize (int max_length, string str)
{
if (str.Length < max_length || max_length < 0)
@@ -45,6 +55,8 @@
return Ellipsize (40, (string) str);
}
+
/////////////////////////////////////////////////////////////////////////////////////
+
static public string PrettySize (uint num_bytes)
{
if (num_bytes < 1024)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches