linux编译调试c程序
Nagaraj from my company made this little util recently to run against a compiled assembly and see if it is a Debug or Release version. I added the DOS ErrorLevel return codes.
我公司的Nagaraj最近制作了这个小工具,可以在已编译的程序集中运行,并查看它是Debug还是Release版本。 我添加了DOS ErrorLevel返回代码。
using System;
使用系统;
using System.IO;
使用System.IO;
using System.Diagnostics;
使用System.Diagnostics;
using System.Reflection;
使用System.Reflection;
namespace Foo.Tools
命名空间Foo.Tools
{
{
class BuildFind
BuildFind类
{
{
public static int GetBuildType(string AssemblyName)
公共静态int GetBuildType(字符串AssemblyName)
{
{
Assembly assm = Assembly.LoadFrom(AssemblyName);
装配体=装配体.LoadFrom(AssemblyName);
object[] attributes = assm.GetCustomAttributes(typeof(DebuggableAttribute), false);
对象[]属性= assm.GetCustomAttributes(typeof运算(DebuggableAttribute),假);
if (attributes.Length == 0)
如果(attributes.Length == 0)
{
{
Console.WriteLine(String.Format("{0} is a RELEASE Build....", AssemblyName));
Console .WriteLine( String .Format( “ {0}是一个RELEASE Build ....” ,AssemblyName));
return 0;
返回0;
}
}
foreach (Attribute attr in attributes)
的foreach(在属性属性ATTR)
{
{
if (attr is DebuggableAttribute)
如果(attr是DebuggableAttribute )
{
{
DebuggableAttribute d = attr as DebuggableAttribute;
DebuggableAttribute d = attr作为DebuggableAttribute ;
Console.WriteLine( String.Format("Run time Optimizer is enabled : {0}", !d.IsJITOptimizerDisabled));
Console .WriteLine( String .Format( “运行时优化器已启用:{0}” ,!d.IsJITOptimizerDisabled));
Console.WriteLine( String.Format("Run time Tracking is enabled : {0}", d.IsJITTrackingEnabled));
Console .WriteLine( String .Format( “运行时跟踪已启用:{0}” ,d.IsJITTrackingEnabled));
if (d.IsJITOptimizerDisabled == true)
如果(d.IsJITOptimizerDisabled == true )
{
{
Console.WriteLine(String.Format("{0} is a DEBUG Build....", AssemblyName));
Console .WriteLine( String .Format( “ {0}是一个DEBUG Build ....” ,AssemblyName));
return 1;
返回1;
}
}
else
其他
{
{
Console.WriteLine(String.Format("{0} is a RELEASE Build....", AssemblyName));
Console .WriteLine( String .Format( “ {0}是一个RELEASE版本...。” ,AssemblyName));
return 0;
返回0;
}
}
}
}
}
}
return 3;
返回3;
}
}
[STAThread]
[ STAThread ]
static int Main(string[] args)
static int Main(字符串[] args)
{
{
if (args.Length == 0)
如果(args.Length == 0)
{
{
Console.WriteLine("Usage GetBuildType <assemblyName>");
Console .WriteLine( “用法GetBuildType <assemblyName>” );
return 2;
返回2;
}
}
return BuildFind.GetBuildType(args[0]);
返回BuildFind .GetBuildType(args [0]);
}
}
}
}
}
}
linux编译调试c程序