sourceMaps.map is a build product in release mode, stored in {ProjectPath}/{ModuleName}/build/{product}/cache/default/default@CompileArkTS/esmodule/release/sourceMaps.map.

The .so files with debugging information are stored in {ProjectPath}/{ModuleName}/build/{product}/intermediates/libs.
For details, see Retaining Debugging Information with .so Files in Release Builds.

nameCache.json is an obfuscation mapping table, a build product in release mode, stored in {ProjectPath}/{ModuleName}/build/{product}/cache/default/default@CompileArkTS/esmodule/release/obfuscation.

set_source_files_properties(crash.cpp PROPERTIES COMPILE_FLAGS "-O0 -g -DNDEBUG")
Typically, symbol tables and debugging information are stripped from .so files in release builds.

To retain the symbol table and debugging information in the .so file, configure the following under buildOption/externalNativeOptions in the build-profile.json5 file: "arguments": "-DCMAKE_BUILD_TYPE=RelWithDebInfo".
{
"apiType": "stageMode",
"buildOption": {
"externalNativeOptions": {
"path": "./src/main/cpp/CMakeLists.txt",
"arguments": "-DCMAKE_BUILD_TYPE=RelWithDebInfo",
"cppFlags": "",
}
},
} The compilation yields two .so outputs:

llvm-addr2line (stored in sdk/default/openharmony/native/llvm/bin under the DevEco Studio installation directory) is a tool that resolves function addresses to file names and line numbers.
Given an address in an executable file or an offset address in a relocatable object, the tool uses debugging information to find the associated file name and line number.
The table below lists common parameters.
Name | Description |
|---|---|
-a | Displays the address in hexadecimal notation. |
-C | Decodes symbolic names to user-level names. |
-e | Sets the name of the executable file whose address needs to be converted. |
-f | Displays the file name, line number, and function name. |
-F | Displays the function name and file line number. |
-j | Reads the offset of the specified part instead of the absolute address. |
-p | Configures each address information to appear on a separate line. |
Examples:
View the file name, line number, and function name.
llvm-addr2line -f -e File.so
Find the code location corresponding to a specific address.
llvm-addr2line 0x00000000004005e7 -e test -f -C -s
Sample code:
llvm-addr2line -e libapplication.so 00003714 -f -C

ASan stack trace analysis




Actual code line mapping:
70->29
71->30
72->31
73->32
sourceMap structure

The sourceMaps.map file, as an individual module build product, is a merged file that contains the mapping relationships of all the files in that module. Each JSON has a key that serves as the primary key for the unique path of the build product. The running program's .abc file retains the corresponding key information. When an exception occurs during runtime and the code is attributed to this file, the output information is the key in the file. sources is the actual source code file information used for stack trace decompression; mappings is an encoded line and column number mapping table, with each file having an independent mapping relationship.
The following figure illustrates the structured parsing process for each key in the source map. Taking entry|har1|1.0.0|src/main/ets/pages/w.ts as an example, the fields are separated by the "|" delimiter and have the following meanings:
entry is the name of the module defined in the oh-package.json5 file, har1|1.0.0 is the name and version of the dependent HAR package defined in the oh-package.json5 file (or the module's own name and version if there is no dependent package), and src/main/ets/pages/w.ts is the path to the referenced source file.

For details about code obfuscation configuration, see Code Obfuscation.
The code obfuscation product is in effect an obfuscation mapping table: $ProjectPath\$ModuleName\build\$product\cache\default\default@CompileArkTS\esmodule\release\obfuscation\nameCache.json.
{
"home/src/main/ets/homeability/HomeAbility.ets": {
"IdentifierCache": {
"#AbilityConstant": "AbilityConstant",
"#hilog": "hilog",
"#UIAbility": "UIAbility",
"#Want": "Want",
"#window": "window",
"HomeAbility#onWindowStageCreate#__function": "i"
},
"MemberMethodCache": {
"onCreate:10:16": "onCreate",
"onDestroy:18:20": "onDestroy",
"onWindowStageCreate:22:33": "onWindowStageCreate",
"onWindowStageDestroy:35:38": "onWindowStageDestroy",
"onForeground:40:43": "onForeground",
"onBackground:45:48": "onBackground"
},
"obfName": "home/src/main/ets/homeability/HomeAbility.ets"
},
"compileSdkVersion": "5.0.0.25",
"entryPackageInfo": "home|1.0.0",
"PropertyCache": {
"integratedHsp": "i",
"asanClick": "j",
"Index_Params": "m",
"testNapi": "o",
"Index": "t",
"testObfuscation": "g2"
}
} "obfName": "home/src/main/ets/pages/a.ts"
Variables are classified as common variables and class method variables.
The format of the mapping relationship for common variables is as follows:
originalvariablename : obfuscatedvariablename
The format of the mapping relationship for class method variables is as follows:
/*--------------------------key---------------------------------- : -----------value----------*/ originalmethodname: originalmethodstartline: originalmethodendline : obfuscatedmethodname
When property obfuscation is enabled, the format of the member method mapping relationship is as follows:
/*--------------------------key--------------------------------- : -----------value----------*/ originalmethodname:originalmethodstartline:originalmethodendline : obfuscatedmethodname
When property obfuscation is not enabled, the format of the member method mapping relationship is as follows:
/*--------------------------key------------------------------------- : -----------value----------*/ originalmethodname : originalmethodstartline : originalmethodendline : originalmethodname
The format of the property name mapping relationship is as follows:
/*--------key------- : -----------value----------*/ originalpropertyname : obfuscatedmethodname
The exception stack is as follows:
Pid:58348
Uid:20020156
Reason:RangeError
Error name:RangeError
Error message:The number cannot be converted to a BigInt because it is not an integer
Stacktrace:
Cannot get SourceMap info, dump raw stack:
at g2 (home|home|1.0.0|src/main/ets/pages/a.ts:6:6)
at getVersion (home|home|1.0.0|src/main/ets/pages/a.ts:2:2)
at anonymous (home|home|1.0.0|src/main/ets/pages/Index.ts:61:61) at g2 (home/src/main/ets/pages/tool.ts:7:27) at getVersion (home/src/main/ets/pages/tool.ts:2:30) at anonymous (home/src/main/ets/pages/Index.ets:23:40)
a.ts is restored to tool.ts via sourceMap.
"home|home|1.0.0|src/main/ets/pages/a.ts": {
"version": 3,
"file": "tool.ts",
"sources": [
"home/src/main/ets/pages/tool.ts"
],
"names": [],
"mappings": "AAAA,MAAM,CAAC,OAAO,UAAU,UAAU,IAAI,MAAM;IAC1C,IAAI,KAAM,IAAiB,CAAA;IAC3B,UAAW;AACb,CAAC;AAED,eAA2B,MAAM;IAC/B,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;IACxB,OAAO,GAAG,CAAC;AACb,CAAC",
"sourceRoot": "",
"entry-package-info": "home|1.0.0"
} Check the obfuscation mapping table $ProjectPath\$ModuleName\build\$product\cache\default\default@CompileArkTS\esmodule\release\obfuscation\nameCache.json.
"home/src/main/ets/pages/tool.ts": {
"IdentifierCache": {
"getVersion#res": "h2",
"#testObfuscation:6:9": "g2"
},
"MemberMethodCache": {},
"obfName": "home/src/main/ets/pages/a.ts"
} The IdentifierCache and MemberMethodCache fields save the mapping relationship between the method names before and after obfuscation, in the following format: "source code method name:start line:end line":"obfuscated method name".
The "source code method name" in the source code represents the parent-child relationship. Therefore, you can use the number sign (#) to retain the last name after mapping.
The first stack has the obfuscated method name g2. If there are multiple g2 entries, you need to filter them by line number range. Therefore, use the above fields to restore this method name:
"#testObfuscation:6:9": "g2"
at testObfuscation (home/src/main/ets/pages/tool.ts:7:27) at getVersion (home/src/main/ets/pages/tool.ts:2:30) at anonymous (home/src/main/ets/pages/Index.ets:23:40)