gdbver.pp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. Program to detect the version of libgdb that will be
  3. used for linking
  4. }
  5. program find_gdb_version;
  6. {$R-}
  7. {$ifdef unix}
  8. {$Linklib c}
  9. {$endif}
  10. {$LINKLIB libgdb.a}
  11. uses
  12. strings;
  13. const
  14. { This variable should be change with change in GDB CVS PM }
  15. Current_cvs_version : longint = 503;
  16. Max_version_length = 255;
  17. var
  18. version : array[0..0] of char;cvar;external;
  19. gdbversion : pchar;
  20. subver_str : string;
  21. i, version_number,
  22. subversion_number : longint;
  23. subsubversion_number : longint;
  24. error : word;
  25. only_ver : boolean;
  26. begin
  27. only_ver:=(Paramcount>0) and (ParamStr(1)='-n');
  28. getmem(gdbversion,Max_version_length+1);
  29. strlcopy(gdbversion,@version,Max_version_length);
  30. gdbversion[Max_version_length]:=#0;
  31. if (gdbversion[0] in ['4','5','6','7','8','9']) and (gdbversion[1]='.') then
  32. begin
  33. if not only_ver then
  34. Writeln('GDB version is ',pchar(@version));
  35. version_number:=ord(gdbversion[0])-ord('0');
  36. i:=2;
  37. subver_str:='';
  38. while gdbversion[i] in ['0'..'9'] do
  39. begin
  40. subver_str:=subver_str+gdbversion[i];
  41. inc(i);
  42. end;
  43. val(subver_str,subversion_number,error);
  44. inc(i);
  45. subver_str:='';
  46. while gdbversion[i] in ['0'..'9'] do
  47. begin
  48. subver_str:=subver_str+gdbversion[i];
  49. inc(i);
  50. end;
  51. if subver_str<>'' then
  52. val(subver_str,subsubversion_number,error);
  53. { 5.02.90 is a pretest of 5.03.. PM }
  54. if subsubversion_number>=90 then
  55. inc(subversion_number);
  56. if (error=0) and (subversion_number>=0) and
  57. (subversion_number<=99) then
  58. version_number:=version_number*100+subversion_number;
  59. end
  60. else if (gdbversion[0]='2') and (gdbversion[1]='0') and
  61. (gdbversion[2] in ['0'..'9']) and (gdbversion[3] in ['0'..'9']) then
  62. begin
  63. { CVS version from 2000 to 2099,
  64. assume current_cvs_version PM }
  65. version_number:=Current_cvs_version;
  66. end
  67. else
  68. begin
  69. if not only_ver then
  70. Writeln('Unsupported GDB version');
  71. version_number:=0;
  72. end;
  73. freemem(gdbversion);
  74. if only_ver then
  75. Write(version_number);
  76. Halt(version_number);
  77. end.