Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

okias
Copy link
Contributor

@okias okias commented Jun 27, 2022

example output:

export TRACE=~/Downloads/unigi/Unigine_Heaven-4.0/bin/heaven_x64.trace
./apitrace info $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})

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]

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]>
@okias okias marked this pull request as ready for review June 30, 2022 21:27
@@ -81,6 +81,13 @@ getApiName(int api) {
return trace::API_NAMES[api];
}

static const std::string
getProcessName(std::string name) {
if (name == "")
Copy link
Member

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;
Copy link
Member

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 << '\"';
}

@jrfonseca jrfonseca added the CLI label Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants