Failed to create pdb file from C++ Builder map

Issue #9 open
pheuvelgoogle created an issue

Trying to create pdb file from a C++ Builder map, get following output:

map2pdb - Copyright (c) 2021 Anders Melander
Version 3.1.2

Fatal: [   44] Modules overlap: C:\PROGRAM, C:\PROGRAM
0001:0003AD33 00000297 C=CODE    S=_TEXT    G=(none)   M=C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\22.0\LIB\WIN32\DEBUG\RTL.LIB|System.Internal.ExcUtils ACBP=A9

Map file was generated for a 32-bit Windows target using RS 11.3, map file options set as recommended.

Using map2pdb version 3.1.2

Map file (zipped) attached.

Thank you!

Comments (17)

  1. Anders@Melander

    I have fixed the problem of the map parser not handling module names with path and aliases (path|alias) but in addition to that there are multiple other issues.

    Segment size

    The segment size is a 64 bit number which is normally specified with 8 hex digits ending with H.

    In your map file it’s a 9 digit hex number…

     Start Length Name Class
     0001:00401000 0009DF6A4H _TEXT                  CODE
    

    I have now rewritten the hex number reader to handle this.

    Module overlaps

    For example:

     0001:000346B8 0000668E C=CODE    S=_TEXT    G=(none)   M=C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\22.0\LIB\WIN32\DEBUG\RTL.LIB|System.Character ACBP=A9
     0001:0003AD33 00000297 C=CODE    S=_TEXT    G=(none)   M=C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\22.0\LIB\WIN32\DEBUG\RTL.LIB|System.Internal.ExcUtils ACBP=A9
    
    Module Start Size End
    System.Character 000346B8 0000668E 0003AD45
    System.Internal.ExcUtils 0003AD33 00000297 0003AFC9

    So the start of System.Internal.ExcUtils is within the range [Start..End] of System.Character.

    I am now handling this by moving and/or shrinking the overlapping module depending on how the overlap is positioned relative to the other module. If the module can not be shrunk (it’s too small) or if there are still overlaps after being shrunk, I ignore the module.

    Line number and source file information

    Well, there aren’t any…
    The map file should contain a number of sections that look something like this:

    Line numbers for System(System.pas) segment .text
    
      4729 0001:000043A8  4730 0001:000043AC  4731 0001:000043B1  4732 0001:000043B8
      4733 0001:000043BE  4734 0001:000043C5  4735 0001:000043CA
    

    This contains the mapping between addresses and source files & line numbers. Without this information I seriously doubt that you can use the generated pdb file for anything.

    Can I get you to investigate if you can get C++ Builder to generate line number information in the map file. In Delphi this is done by specifying the Detailed map file linker option.

  2. pheuvelgoogle reporter

    Thanks very much, Anders! I’ll have a look at this when I get home.

    Regards, Pat Heuvel

  3. pheuvelgoogle reporter

    Sorry, I thought I’d updated the zip file. If this one is identical, I don’t know what else to do. As I said in my previous comment, I selected Detailed Segment Map. Maybe David Millington could help with parameter suggestions?

  4. Anders@Melander

    Also, be aware that Bitbucket sucks ass, so you have to verify that it actually attaches the correct file when the new file has the same name as an old. A bug that it shares with Jira, FWIW.

  5. Anders@Melander

    The map file is slightly different now but still no line number information

    Maybe David Millington could help with parameter suggestions?

    Yes, perhaps. Do you know how to reach him?

    Maybe ask in the forum.

  6. Anders@Melander

    Waitamoment… Didn’t I see madExcept in your map file. When using madExcept, are you able to get source info & line numbers in the bug reports?

    If so then madExcept must somehow be able to set up the project to produce the required information because, as far as I know, it also gets it from the map file.

  7. pheuvelgoogle reporter

    Can’t find where I put the original comment on Delphi-praxis! I emailed the following to David Millington:

    Gday David,

    I'm trying to get a C++ Builder map file to Anders Melander in the hope of getting a PDB file to use with Intel's vtune.

    To that end, how do I get line numbers into the file? I'm currently working with RAD Studio 11.3 Enterprise, and I think I have all the settings on, but I've obviously missed at least one!

    My project uses the classic (Embarcadero) compiler and FMX, and the target is 32-bit Windows.

    The map2pdb issue I raised should be here: https://bitbucket.org/anders_melander/map2pdb/issues/9/failed-to-create-pdb-file-from-c-builder

    Regards and thanks,
    Pat Heuvel

  8. pheuvelgoogle reporter

    Yes you did, and yes, you’re right. And “link in function names and line numbers” is checked.

  9. Anders@Melander

    I think madExcept is reading the line number information from the tds file.

    I don’t have a tds reader in map2pdb.

  10. pheuvelgoogle reporter

    Oh well, it was worth a try! Thanks for your efforts! Hopefully Mr Millington can shed some light on it.

  11. Anders@Melander

    You’re welcome.

    I can probably add a tds reader at some point but right now I’m too busy.

  12. Log in to comment