Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit ceff2e8

Browse files
Add version and edition autodetection to the symbolicator
1 parent 23c2fbe commit ceff2e8

File tree

1 file changed

+81
-23
lines changed

1 file changed

+81
-23
lines changed

tools/SymbolicatorScript.livecodescript

Lines changed: 81 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,31 @@ on startup
2828
end try
2929

3030
-- If help was requested, show it then exit
31-
if "h" or "help" is among the keys of tArgs then
31+
if the number of elements of tArgs is zero or "help" is among the keys of tArgs then
3232
showHelp
3333
quit 0
3434
end if
3535

36+
-- Show debugging information?
37+
if "d" or "debug" is among the keys of tArgs then put true into sDebugging
38+
39+
-- Show verbose information?
40+
if "v" or "verbose" is among the keys of tArgs then put true into sVerbose
41+
42+
-- Read the crash log file
43+
local tCrashLog
44+
put url ("file:" & tArgs["__inputs__"]) into tCrashLog
45+
if the result is not empty then
46+
write "Failed to read" && quote & tArgs["__inputs__"] & quote & return to stderr
47+
quit -1
48+
end if
49+
3650
-- Set some default options if they weren't specified
51+
local tGuessSucceeded
52+
local tVersion
53+
local tEdition
54+
put guessVersionAndEdition(tCrashLog, tVersion, tEdition) into tGuessSucceeded
3755
if "staging-url" is not among the keys of tArgs then put kStagingUrl into tArgs["staging-url"]
38-
if "edition" is not among the keys of tArgs then put "community" into tArgs["edition"]
3956
if "repo" is not among the keys of tArgs then
4057
-- Assumes we're in the main repo folder
4158
if "fetch" is among the keys of tArgs then
@@ -47,18 +64,16 @@ on startup
4764
end if
4865
end if
4966

50-
-- Show debugging information?
51-
if "d" or "debug" is among the keys of tArgs then put true into sDebugging
52-
53-
-- Show verbose information?
54-
if "v" or "verbose" is among the keys of tArgs then put true into sVerbose
55-
5667
-- Dump the input arguments to stderr if debugging is enabled
5768
debugPrint dumpArray(tArgs)
5869

5970
-- Check that the mandatory options are present
60-
if "version" is not among the keys of tArgs then
61-
write "Error: version tag must be specified" & return to stderr
71+
if "version" is not among the keys of tArgs and not tGuessSucceeded then
72+
write "Error: version could not be auto-detected" & return to stderr
73+
quit -1
74+
end if
75+
if "edition" is not among the keys of tArgs and not tGuessSucceeded then
76+
write "Error: edition could not be auto-detected" & return to stderr
6277
quit -1
6378
end if
6479
if "fetch" is among the keys of tArgs and "cache-dir" is not among the keys of tArgs then
@@ -74,9 +89,9 @@ on startup
7489
quit -1
7590
end if
7691

77-
-- Version of LiveCode we're symbolicating
78-
local tVersion
79-
put tArgs["version"] into tVersion
92+
-- Version and edition of LiveCode we're symbolicating
93+
if "version" is among the keys of tArgs then put tArgs["version"] into tVersion
94+
if "edition" is among the keys of tArgs then put tArgs["edition"] into tEdition
8095

8196
-- Download the symbols for the requested version if necessary
8297
local tSymbolDir
@@ -95,17 +110,9 @@ on startup
95110
quit -1
96111
end try
97112
else
98-
put tArgs["symbol-dir"] into tSymbolDir
99-
end if
100-
put pathToSymbolFileForVersion(tSymbolDir, tArgs["edition"]) into tSymbolPath
101-
102-
-- Read the crash log file
103-
local tCrashLog
104-
put url ("file:" & tArgs["__inputs__"]) into tCrashLog
105-
if the result is not empty then
106-
write "Failed to read" && quote & tArgs["__inputs__"] & quote & return to stderr
107-
quit -1
113+
put pathToSymbolDirForVersion(tArgs["symbol-dir"], tVersion) into tSymbolDir
108114
end if
115+
put pathToSymbolFileForVersion(tSymbolDir, tEdition) into tSymbolPath
109116

110117
-- Process the crashlog file
111118
local tSymbolicatedLog
@@ -545,6 +552,57 @@ end fetchSymbolsForRevision
545552
---------- SYMBOLICATION ----------
546553
-----------------------------------
547554

555+
-- Guesses the LiveCode engine version and edition from the crash log
556+
private function guessVersionAndEdition pLog, @rVersion, @rEdition
557+
-- Find the line that contains the embedded version information
558+
local tVersionLineNumber
559+
put lineOffset("Version:", pLog) into tVersionLineNumber
560+
if tVersionLineNumber is zero then return false
561+
562+
-- Version line has the form "Version: 8.0.0.13012 [DP 12]"
563+
local tVersionLine
564+
local tVersionNumber
565+
local tVersionSuffix
566+
put line tVersionLineNumber of pLog into tVersionLine
567+
if (char 2 to -1 of word 3 of tVersionLine) is among the items of "RC,DP" then
568+
put "-" & toLower(char 2 to -1 of word 3 of tVersionLine) into tVersionSuffix
569+
put "-" & (char 1 to -2 of word 4 of tVersionLine) after tVersionSuffix
570+
end if
571+
set the itemDelimiter to "."
572+
put (item 1 to 3 of (word 2 of tVersionLine)) into tVersionNumber
573+
put (tVersionNumber & tVersionSuffix) into rVersion
574+
verbosePrint "Auto-detected version as" && rVersion
575+
576+
-- Find the line that contains the process name
577+
local tProcessLineNumber
578+
put lineOffset("Process:", pLog) into tProcessLineNumber
579+
if tProcessLineNumber is zero then return false
580+
581+
-- Look for keywords in the line
582+
local tProcessLine
583+
put line tProcessLineNumber of pLog into tProcessLine
584+
switch
585+
case "LiveCode-Community" is among the words of tProcessLine
586+
put "community" into rEdition
587+
break
588+
589+
case "LiveCode-Indy" is among the words of tProcessLine
590+
put "indy" into rEdition
591+
break
592+
593+
case "LiveCode-Business" is among the words of tProcessLine
594+
put "business" into rEdition
595+
break
596+
597+
default
598+
return false
599+
break
600+
end switch
601+
602+
-- The autodetection seems to have worked
603+
verbosePrint "Auto-detected edition as" && rEdition
604+
return true
605+
end guessVersionAndEdition
548606

549607
-- Finds the line range in the given log that corresponds to the stack trace of the crashed thread
550608
private command findStackTraceLineRange pLog, @rStart, @rEnd

0 commit comments

Comments
 (0)