Jump to content
Anders Melander

MAP2PDB - Profiling with VTune

Recommended Posts

7 minutes ago, Attila Kovacs said:

This still rocks! Thx! 😉

Thanks. I'm not using it that much myself at the moment because it takes VTune about an hour (no kidding!) to resolve the symbols of the application I'm working on 😕

 

Share this post


Link to post

I would like to implement support for reading of JEDI .jdbg files: https://bitbucket.org/anders_melander/map2pdb/issues/2/parser-for-jdbg-files

 

Does anyone know if .jdbg parser code exists? Otherwise I can probably write it based on TJclBinDebugGenerator.Create: https://github.com/andremussche/asmprofiler/blob/b785168f7caec8ff91d59d912dfb0e9e4519f803/Source/EXT/jcl/JclDebug.pas#L2358

 

Edit: nevermind, found .jdbg parser - TJclBinDebugScanner.

Edited by Jan Rysavy

Share this post


Link to post

Excellent work ... Thanks !

I was using the tool with some map file and I got an AV error. I started investigating and I found a bug in the map parser 

// debug.info.reader.map.pas (line 349):
var SegmentID: Cardinal := HexToInt16(Reader.LineBuffer, n);

The SegmentID should be read as a DECIMAL value and not as a HEX ! if the map file contains more than 9 segment, the next segment is emitted like (0010:xxxxx) but you're reading it like a hex (so its ID becomes 16 !) and then there is this line 

FSegments[ListIndex] := Result; // FSegments[10 .. ListIndex - 1] = nil => AV

 A simple fix

  function DecToInt32(const s: string; var Offset: integer): integer;
  var
    P: PChar;
  begin
    Result := 0;
    P := PChar(s);
    while Ord(P^) in [$30 .. $39] do
    begin
      Result := (Result * 10) + (Ord(P^) - $30);
      Inc(P);
      Inc(Offset);
    end;
  end;
// ...
var SegmentID: Cardinal := DecToInt32(reader.LineBuffer, n);

 

  • Thanks 3

Share this post


Link to post

Yup. That pretty much sums it up.

Like everything else Atlassian touches it only gets worse with time.

 

My plan is to switch everything to Gitlab at some time but other stuff keeps getting in the way.

  • Like 1

Share this post


Link to post
22 minutes ago, Anders Melander said:

My plan is to switch everything to Gitlab at some time but other stuff keeps getting in the way

Much simpler to switch to github, for gitlab you have to apply for free hosting of open source. 

  • Like 1

Share this post


Link to post
8 minutes ago, Vincent Parrett said:

Much simpler to switch to github

Yes, it is - but I like the spirit of Gitlab.

I need to get some real-life experience with it anyway because I also plan to switch the company from BitBucket to Gitlab at some point. Github is way too expensive for enterprise use.

 

8 minutes ago, Vincent Parrett said:

for gitlab you have to apply for free hosting of open source. 

I've had a Gitlab account for quite some time. AFAIR I didn't need to "apply". I think I just checked a box somewhere.

Edited by Anders Melander
  • Like 1

Share this post


Link to post

@Anders Melander I am using Code Commit for my latest project, during lock down I needed to swap out the On Premise version of BitBucket.

It has the feature of locating the service at a particular data center and encrypting the source code at rest.

 

It's worth a look if you haven't already. Then again I don't know what you are looking for.

  • Thanks 1

Share this post


Link to post

Are any of you running MAP2PDB with the current version of Intel VTune 2023.1? Both AMD uProf and WinDBG correctly load my PDBs created by the latest version of MAP2PDB, but VTune only shows function addresses without symbolic names.

Share this post


Link to post

Incredible tool, congrats.


I've tried to use it with Sydney 10.4.1 and VTune 2023.1.0.
 

Unfortunately, I was not able to get the function as name, I get only func addresses:
image.thumb.png.829647b085ce0c09b7d8e2041edbc34f.png

 

I've tried with:

D:\x\develop\qem\rosetta_cnc_1>map2pdb.exe rosettacncpph1.64.map -bind
map2pdb - Copyright (c) 2021 Anders Melander
Version 2.8.0

and also with:

D:\x\develop\qem\rosetta_cnc_1>map2pdb.exe -bind rosettacncpph1.64.map
map2pdb - Copyright (c) 2021 Anders Melander
Version 2.8.0

Map is set to Detailed on Sydney 10.4.1:
image.thumb.png.c7ddcff82caf64eba091f142282eaeb7.png

 

D:\x\develop\qem\rosetta_cnc_1>map2pdb.exe rosettacncpph1.64.map -bind -v
map2pdb - Copyright (c) 2021 Anders Melander
Version 2.8.0

Constructed a new PDB GUID: {5D8591F1-8F38-4E7B-BAE4-1BB55536733F}
Output filename not specified. Defaulting to rosettacncpph1.64.pdb
Reading MAP file
- Segments
- Modules
- Symbols
Warning: [116390] Failed to resolve symbol to module: [0004:00000000000002C8] SysInit.TlsLast
Warning: [116392] Failed to resolve symbol to module: [0003:00000000FE7F6000] SysInit.__ImageBase
- Line numbers
Collected 3.996 modules, 182.925 symbols, 525.223 lines, 985 source files
Constructing PDB file
- Collecting source file names
- Module streams
- Strings stream
- PDB Info stream
- TPI stream
- Symbols stream
- DBI stream
- IPI stream
- Finalizing PDB file
- 9.068 blocks written in 3 intervals
PE filename not specified. Defaulting to rosettacncpph1.64.exe
Patching PE file
- PE32+ image (64-bit)
- Adding .debug section.
- PDB file name has been stored in debug data.
- PE file has been updated.
Elapsed time: 00:00:00.874

 

I hope you have a simple solution to my possible mistakes.

Edited by shineworld

Share this post


Link to post

I just want to add that I installed an older version of VTune 2022.4.1 and the function names are displayed correctly. The problem seems to be related to the new version VTune 2023.1.

Share this post


Link to post
9 minutes ago, Jan Rysavy said:

I just want to add that I installed an older version of VTune 2022.4.1 and the function names are displayed correctly. The problem seems to be related to the new version VTune 2023.1.

I've tried to find a way to download the older version (2022.4.1) but no way found on the intel VTune pages....

Share this post


Link to post

I just upgraded from 2023.0.0 where it worked to 2023.1.0 where it does not.

 

What I noticed in the change log of VTune 2023.1.0 is this:

 

Debug Support 

Support for Large PDB Files 
Starting with the 2023.1 version, on Windows* systems, you can resolve debug information from PDB files larger than 4GB. 

 

Could it be that the address bitness written by map2pdb is not correct now?

 

In the collection log of VTune I can see this warning:

 

Cannot locate debugging information for file `somepath\Tests.exe'. Cannot match the module with the symbol file `somepath\Tests.pdb'. Make sure to specify the correct path to the symbol file in the Binary/Symbol Search list of directories.

Edited by Stefan Glienke

Share this post


Link to post
45 minutes ago, shineworld said:

I've tried to find a way to download the older version (2022.4.1) but no way found on the intel VTune pages....

This might help:

https://www.intel.com/content/www/us/en/developer/articles/troubleshooting/older-version-product.html

 

14 hours ago, Jan Rysavy said:

PDBs created by the latest version of MAP2PDB, but VTune only shows function addresses without symbolic names.

Please create an issue at the repository: https://bitbucket.org/anders_melander/map2pdb/issues/new

 

The problem is most likely caused by msdia140.dll; The library VTune uses to read pdb files. You can try replacing the one that VTune installs with an older version. See:

 

Share this post


Link to post
2 minutes ago, Stefan Glienke said:

Could it be that the address bitness written by map2pdb is not correct now?

Please elaborate

Share this post


Link to post
Just now, Anders Melander said:

Please elaborate

I can't - as I confirmed the breaking change is from 2023.0.0 to 2023.1.0 and that explicit mention of large pdb file support was the most obvious clue. I don't know anything about the pdb format.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×