Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
Every other embodiment obtained without creative efforts, shall fall within the protection scope of the present invention.
In the following, first introducing presently filed embodiment, the scheme and existing skill of the application will be confirmed with experimental data later
Any beneficial effect be able to achieve compared to there is what difference for art.
Referring to FIG. 1, it illustrates the flow chart of one embodiment of method of the capture lua code exception of the application, this reality
The method for applying the capture lua code exception of example can be adapted for including in the APP (application program) of lua code.
As shown in Figure 1, in a step 101, being arranged to call every time and be called by abnormality processing function when lua code
Lua code;
Later, in a step 102, it obtains the return value of abnormality processing function and is pressed into the return value of abnormality processing function
Lua storehouse;
Finally, in step 103, if lua code is abnormal, reverse calling applicational language function is with will be in lua storehouse
Error message passes to applicational language function.
In the present embodiment, for step 101, the device for capturing lua exception uses abnormality processing letter to lua code first
Number is once packed, and is all called by abnormality processing function when lua code so that calling every time.In some optional implementations
In example, abnormality processing function includes lua_pcall and lua_xpcall.Later, for step 102, wherein capture lua is abnormal
Device obtain abnormality processing function return value and by the return value be pressed into lua storehouse in, the return value of abnormality processing function
It is whether abnormal including at least lua code, such as return when true or false or true or normal nil and lua code
Error message when value or lua code exception.In a further embodiment, can also include error message additional information or
Person extends information, such as illustrates information etc. to error message.Finally, for step 103, if according to the return in lua storehouse
It is worth code abnormal, then reverse calling applicational language function is to pass to applicational language letter for the error message in lua storehouse
Number.Wherein, language function can be java function, C/C++ function or Python function etc. for write the function of APP to
Mistake is transmitted to application layer from bottom.
The method of the present embodiment calls lua code by using abnormality processing function, will pass to application extremely again later
Language function can to malfunction even if lua code and collapse, and abnormality processing function will not collapse, but by error message, it puts
On lua storehouse, pass.So that developer, either during app is developed, or app
After formally issuing use, lua layers of error message can be being got at the first time, can navigated in time very small
The wrong scene of probability is repaired in time.
With further reference to Fig. 2, it illustrates the flow charts of the method for another capture lua code exception of the application.
As shown in Fig. 2, in step 201, the error message that applicational language function captures is dished out to upper layer;
In step 202, the error message and upload that capture applicational language function is dished out on upper layer.
In the present embodiment, step 201, the device of capture lua code exception are received the applicational language function
The error message of the lua code transmitted from lua storehouse is dished out to upper layer.Later, in step 202, the application is captured on upper layer
Error message that language function is dished out and the server for being uploaded to APP, so that server can learn the exception of lua in real time.
With further reference to Fig. 3, it illustrates the flow charts of the method for another capture lua code exception of the application.It should
Refinement step of the process primarily directed to the step 101 in Fig. 1.
As shown in figure 3, in step 301, by lua code wrap in preset function;
In step 302, will call lua code revision is to call preset function by abnormality processing function.
In the present embodiment, for step 301, the device of capture lua code exception is by lua code wrap in preset function
In.Later, for step 302, the device for capturing lua code exception will call the instruction modification of lua code to pass through exception
Function is managed to call preset function, such as can will call the preset function comprising lua code by modifying the direction of pointer
Pointer modified is to be directed toward abnormality processing function (such as lua_pcall).So as to which the lua code of easy error is wired up,
Even if the error collapse of lua code nor affects on abnormality processing function to abnormal capture.
Simple illustration once is carried out to the interaction between lua and lua and other language below, so that those skilled in the art
Member more fully understands the scheme of the application.
Lua is an expanded type programming language, is designed to support the programming of universal process formula, and have related data to retouch
State facility.Good support is also provided to Object-Oriented Programming, functional expression programming and data drive type programming simultaneously.It summarizes and
It says that lua is a kind of language of light weight, and supports multiple P normal form, arbitrarily language can be carried out from the transformation needed.
As an expanded type language, lua does not have the concept of " main " program, it can only be embedded in work in a host program
Make, which is embedded into program or abbreviation host.Host program can call function to execute a bit of lua generation
Code, can read and write lua variable, can register C function and call by lua code.
Lua program generally not isolated operation, although the thing that can also can be done is with regard to fairly simple.The lua of standard is empty
What quasi- machine was write by C language, the function of lua is expanded generally by C/C++, such interface compatibility speed is faster.
Here emphasis records the stack of lua, convenient followed by description.
Data exchange between lua virtual machine and C/C++, which is substantially, to be constructed virtual stack by lua to interact no matter
When lua calls C, and called function all obtains a new stack, this stack is also independent from independently of the stack of C function itself
Lua stack before.Its inside contains all parameters that lua passes to C function, and C function is then put into the result to be returned
This stack is to return to caller here.
Based on the characteristic of above-mentioned lua this " parasitism work ", the thinking mutually called between java and lua language is very
It is obvious, it is exactly with jni (Java Native Interface, java local interface) as intermediary.
In order to solve drawbacks described above existing in the prior art, the portioned product of the prior art may pass through following method
To solve:
After general app collapse, system level can retain some crash infos, can be by these after app is again started up
Crash info is sent to background server.
Inventors have found that this is not institute firstly, this method needs operating system level that can save crash info
What some systems were all supported;Secondly, app needs to read the relevant log with oneself from system;Finally, app oneself is needed
Server can receive, save these logs, and the above work is a very large engineering.
Method provided by the embodiments of the present application ensures that one surely grabs effective log by the following method, and uploads to
Server.Specifically referring to FIG. 4, it illustrates a kind of exception catching flow diagrams that one embodiment of the application provides.It needs
Illustrate, although only giving in the present embodiment, abnormality processing function is lua_pcall and applicational language function is
The embodiment of java function, but it is not used in the protection scope of limitation the application, those skilled in the art can be according to following reality
It applies example and obtains other assembled schemes of the application, details are not described herein.
1) use lua_pcall, the functions such as pcall run lua code, it is ensured that lua in the process of running, at C layers
It does not collapse, even if error, will not lead to application crashes;
2) after lua layers of error, in C layers of reverse calling java code, to java layers of throw exception;
3) the java layers of information that catchs the exception;
4) exception information is uploaded to server by the bugly tool of Tencent.
As shown in figure 4,
1) it calls lua code every time in android, is all called by lua_pcall, which goes out in lua code
When wrong, it will not collapse, but by error message, it is placed on lua stack.
2) judged by the return value of lua_pcall, call (the has errors that whether malfunctions every time?), if without mistake,
Return step 1), it continues to execute.
If 3) malfunction, by jni function, reverse calling java function (call java function), calling when
It waits, the error message on lua stack, while passing to java function.
4) it is thrown abnormal (throw exception) in java function to upper layer, exception information is the mistake letter of lua
Breath.
5) the android bugly tool of certain Internet company offer is run simultaneously in android app, which can
To capture the exception (catch exception) that java function is dished out.
6) after android bugly captures exception, bugly server (send to can be uploaded to by network
server)。
So far, the exception catching of lua and upload have been fully completed, android developer, log in bugly clothes daily
Business device, so that it may check the error message that app is uploaded, repair in time.
The scheme of the application can make developer either during app exploitation, or formal in app
After issuing use, lua layers of error message can be being got at the first time, unusual small probability can be navigated in time
Mistake scene is repaired in time.
Referring to FIG. 5, the block diagram of the device for capturing lua code exception provided it illustrates one embodiment of the invention.
As shown in figure 5, the device 500 of capture lua code exception of the invention, including the processing of setup module 510, return value
Module 520 and transfer module 530.
Wherein, setup module 510 are configured to be arranged to call every time and be called by abnormality processing function when lua code
Lua code;Return value processing module 520 is configured to obtain the return value of abnormality processing function and returning abnormality processing function
Return value indentation lua storehouse, wherein the return value of abnormality processing function includes at least whether lua code abnormal and lua code
Error message when return value or lua code exception when normal;And transfer module 530, if being configured to lua code exception,
Then reverse calling applicational language function is to pass to applicational language function for the error message in lua storehouse.
In some alternative embodiments, the device 500 of above-mentioned capture lua code exception further includes that mistake is dished out module
(not shown) and capture uploading module (not shown).Wherein, mistake is dished out module, is configured to applicational language function
The error message of capture is dished out to upper layer;And capture uploading module, it is configured to the mistake letter that capture applicational language function is dished out
It ceases and uploads.
In some alternative embodiments, setup module 510 further comprises package module and calling modified module.Its
In, package module is configured to lua code wrap in preset function;And modified module is called, it is configured to that lua will be called
Code revision is to call preset function by abnormality processing function.
It should be appreciated that each step in all modules recorded in Fig. 5 and the method with reference to described in Fig. 1, Fig. 2 and Fig. 3
It is corresponding.The operation above with respect to method description and feature and corresponding technical effect are equally applicable to all in Fig. 5 as a result,
Module, details are not described herein.
It is worth noting that, the module in embodiment of the disclosure is not limited to the scheme of the disclosure, such as it is arranged
Module can be described as that the module called call lua code when lua code by abnormality processing function every time is arranged.Separately
Outside, it can also realize that related function module, such as setup module can also be realized with processor by hardware processor, herein
It repeats no more.
In further embodiments, the embodiment of the invention also provides a kind of nonvolatile computer storage medias, calculate
Machine storage medium is stored with computer executable instructions, which can be performed in above-mentioned any means embodiment
Capture lua code exception method;
As an implementation, nonvolatile computer storage media of the invention is stored with the executable finger of computer
It enables, computer executable instructions are set as:
Setting calls when lua code every time and calls the lua code by abnormality processing function;
It obtains the return value of the abnormality processing function and the return value of the abnormality processing function is pressed into lua storehouse,
Wherein, the return value of the abnormality processing function includes at least whether the lua code is abnormal and the lua code is normal
When return value or the lua code exception when error message;
If the lua code is abnormal, reverse calling applicational language function is to pass the error message in the lua storehouse
Pass the applicational language function.
As a kind of non-volatile computer readable storage medium storing program for executing, it can be used for storing non-volatile software program, non-volatile
Property computer executable program and module, such as the corresponding program of method of the capture lua code exception in the embodiment of the present invention
Instruction/module.One or more program instruction is stored in non-volatile computer readable storage medium storing program for executing, is held when by processor
When row, the method for capturing lua code exception in above-mentioned any means embodiment is executed.
Non-volatile computer readable storage medium storing program for executing may include storing program area and storage data area, wherein storage journey
It sequence area can application program required for storage program area, at least one function;Storage data area can be stored according to capture lua generation
The abnormal device of code uses created data etc..In addition, non-volatile computer readable storage medium storing program for executing may include high speed
Random access memory, can also include nonvolatile memory, a for example, at least disk memory, flush memory device or
Other non-volatile solid state memory parts.In some embodiments, it includes phase that non-volatile computer readable storage medium storing program for executing is optional
The memory remotely located for processor, these remote memories can be by being connected to the network to capture lua code exception
Device.The example of above-mentioned network includes but is not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
The embodiment of the present invention also provides a kind of computer program product, and computer program product is non-volatile including being stored in
Computer program on computer readable storage medium, computer program include program instruction, when program instruction is held by computer
When row, computer is made to execute the method that any of the above-described captures lua code exception.
Fig. 6 is the structural schematic diagram of electronic equipment provided in an embodiment of the present invention, as shown in fig. 6, the equipment includes:One
Or multiple processors 610 and memory 620, in Fig. 6 by taking a processor 610 as an example.Capture the method for lua code exception
Equipment can also include:Input unit 630 and output device 640.Processor 610, memory 620, input unit 630 and output
Device 640 can be connected by bus or other modes, in Fig. 6 for being connected by bus.Memory 620 is above-mentioned
Non-volatile computer readable storage medium storing program for executing.The non-volatile software journey that processor 610 is stored in memory 620 by operation
Sequence, instruction and module, thereby executing the various function application and data processing of server, i.e. realization above method embodiment
The method for capturing lua code exception.Input unit 630 can receive the number or character information of input, and generates and throw with information
Put the user setting and the related key signals input of function control of device.Output device 640 may include that the displays such as display screen are set
It is standby.
Method provided by the embodiment of the present invention can be performed in the said goods, has the corresponding functional module of execution method and has
Beneficial effect.The not technical detail of detailed description in the present embodiment, reference can be made to method provided by the embodiment of the present invention.
As an implementation, above-mentioned electronic apparatus application is in neural network language model, including:At at least one
Manage device;And the memory being connect at least one processor communication;Wherein, memory, which is stored with, to be handled by least one
The instruction that device executes, instruction is executed by least one processor, so that at least one processor can:
Setting calls when lua code every time and calls the lua code by abnormality processing function;
It obtains the return value of the abnormality processing function and the return value of the abnormality processing function is pressed into lua storehouse,
Wherein, the return value of the abnormality processing function includes at least whether the lua code is abnormal and the lua code is normal
When return value or the lua code exception when error message;
If the lua code is abnormal, reverse calling applicational language function is to pass the error message in the lua storehouse
Pass the applicational language function.
The electronic equipment of the embodiment of the present application exists in a variety of forms, including but not limited to:
(1) mobile communication equipment:The characteristics of this kind of equipment is that have mobile communication function, and to provide speech, data
Communication is main target.This Terminal Type includes:Smart phone (such as iPhone), multimedia handset, functional mobile phone and low
Hold mobile phone etc..
(2) super mobile personal computer equipment:This kind of equipment belongs to the scope of personal computer, there is calculating and processing function
Can, generally also have mobile Internet access characteristic.This Terminal Type includes:PDA, MID and UMPC equipment etc., such as iPad.
(3) portable entertainment device:This kind of equipment can show and play multimedia content.Such equipment includes:Audio,
Video player (such as iPod), handheld device, e-book and intelligent toy and portable car-mounted navigation equipment.
(4) server:There is provided the equipment of the service of calculating, the composition of server includes that processor, hard disk, memory, system are total
Line etc., server is similar with general computer architecture, but due to needing to provide highly reliable service, in processing energy
Power, stability, reliability, safety, scalability, manageability etc. are more demanding.
(5) other electronic devices with data interaction function.
The apparatus embodiments described above are merely exemplary, wherein unit can be as illustrated by the separation member
Or may not be and be physically separated, component shown as a unit may or may not be physical unit, i.e.,
It can be located in one place, or may be distributed over multiple network units.It can select according to the actual needs therein
Some or all of the modules achieves the purpose of the solution of this embodiment.Those of ordinary skill in the art are not paying creative labor
In the case where dynamic, it can understand and implement.
Through the above description of the embodiments, those skilled in the art can be understood that each embodiment can
It realizes by means of software and necessary general hardware platform, naturally it is also possible to pass through hardware.Based on this understanding, on
Stating technical solution, substantially the part that contributes to existing technology can be embodied in the form of software products in other words, should
Computer software product may be stored in a computer readable storage medium, such as ROM/RAM, magnetic disk, CD, including several fingers
It enables and using so that a computer equipment (can be personal computer, server or the network equipment etc.) executes each implementation
The method of certain parts of example or embodiment.
Finally it should be noted that:The above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although
Present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that:It still may be used
To modify the technical solutions described in the foregoing embodiments or equivalent replacement of some of the technical features;
And these are modified or replaceed, technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution spirit and
Range.