-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli_info: implement ProcessName reporting #809
base: master
Are you sure you want to change the base?
Conversation
example output: ``` ./apitrace info ~/Downloads/unigi/Unigine_Heaven-4.0/bin/heaven_x64.trace { "FileName": "/home/okias/Downloads/unigi/Unigine_Heaven-4.0/bin/heaven_x64.trace", "ProcessName": "/home/okias/Downloads/unigi/Unigine_Heaven-4.0/bin/heaven_x64", "ContainerVersion": 6, "ContainerType": "Snappy", "API": "OpenGL + GLX/WGL/CGL", "FramesCount": 11252, "ActualDataSize": 524912758, "ContainerSize": 345934639 } ``` When `glretrace` will be invoked as shown below: ``` export TRACE=~/Downloads/unigi/Unigine_Heaven-4.0/bin/heaven_x64.trace (exec -a "$(./apitrace info ${TRACE} | jq '.["ProcessName"]')" ./glretrace ${TRACE}) ``` Mesa library will see it under original application or game name, which will retain drirc hacks needed for specific broken app/game to work (thus for trace to correctly replay). Signed-off-by: David Heidelberg <[email protected]>
@@ -81,6 +81,13 @@ getApiName(int api) { | |||
return trace::API_NAMES[api]; | |||
} | |||
|
|||
static const std::string | |||
getProcessName(std::string name) { | |||
if (name == "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (name.empty)()
, but per comment below, we can omit this function entilrely.
@@ -119,6 +127,9 @@ command(int argc, char *argv[]) | |||
return 1; | |||
} | |||
|
|||
auto &properties = p.getProperties(); | |||
std::string processName = properties.find("process.name")->second; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still looks incorrect to me.
Here properties
is a std::map
, and std::map::find
returns end
iterator when nothing is found, and per https://en.cppreference.com/w/cpp/container/map/end "attempting to access it results in undefined behavior."
Please use the standard std::map::find
pattern for this. That is, something along the lines of:
auto & it = properties.find("process.name");
if (it == properties.end()) {
std::cout << "none";
} else {
std::cout << '\"' << it->second << '\"';
}
example output:
When
glretrace
will be invoked as shown below:Mesa3D library will see it under original application or game name, which
will retain drirc hacks needed for specific broken app/game to work
(thus for trace to correctly replay).
Signed-off-by: David Heidelberg [email protected]