while (<>){ if (/^struct/ || /^typedef struct/) { $n = $_; LINE: while (<>){ if (/MonoObject[ \t]*[a-z]/) { $scan = 1; $file = $ARGV; } else { if (/^\}/){ if (/\};/){ print "$n" if $scan == 1; $n = ""; } else { print "$_" if $scan == 1; } $scan = 0; last LINE; } } } } } Run like this: cd mono/mono/metadata perl a.pl *.h That will generate a list of things that the runtime depends on, it only looks for Object, so for each object returned here, you must also rerun this script to find other derived classes. MonoAppDomainSetup struct _MonoAppContext { MonoFSAsyncResult MonoArray MonoString MonoMarshalByRefObject MonoStringBuilder struct _MonoException { MonoAsyncResult struct _MonoReflectionType { MonoRealProxy MonoTransparentProxy MonoMethodMessage MonoStackFrame struct _MonoThread { MonoDateTimeFormatInfo MonoNumberFormatInfo MonoCompareInfo MonoCultureInfo MonoRegionInfo MonoSortKey MonoInterfaceTypeAttribute struct _MonoReflectionMethod { struct _MonoDelegate { struct _MonoReflectionField { struct _MonoReflectionProperty { struct _MonoReflectionEvent { MonoReflectionParameter struct _MonoReflectionMethodBody { struct _MonoReflectionAssembly { MonoReflectionILGen MonoReflectionExceptionHandlingClause MonoReflectionLocalVariableInfo MonoReflectionLocalBuilder MonoReflectionMarshal MonoReflectionParamBuilder MonoReflectionCtorBuilder MonoReflectionMethodBuilder MonoReflectionArrayMethod MonoReflectionFieldBuilder MonoReflectionPropertyBuilder struct _MonoReflectionModule { MonoReflectionAssemblyName MonoReflectionEventBuilder MonoReflectionCustomAttr MonoReflectionDllImportAttribute MonoReflectionUnmanagedFunctionPointerAttribute MonoReflectionDynamicMethod MonoReflectionSigHelper MonoManifestResourceInfo MonoProcessStartInfo MonoSocketAsyncResult MonoPeerCredData