- Timestamp:
- Sep 2, 2010 6:26:21 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/include/internal/ldrELFCommon.h
r31980 r32219 307 307 #endif 308 308 309 /* VirtualBox specific NOTE sections (added by Ramshankar */ 310 #ifdef VBOX 311 #define NT_VBOXCPU 0xace 312 #endif 313 309 314 /* Symbol Binding - ELFNN_ST_BIND - st_info */ 310 315 #define STB_LOCAL 0 /* Local symbol */ -
trunk/src/VBox/VMM/DBGFCoreWrite.cpp
r32218 r32219 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 18 19 /*******************************************************************************20 * Header Files *21 *******************************************************************************/22 #define LOG_GROUP LOG_GROUP_DBGF23 #include <iprt/param.h>24 #include <iprt/file.h>25 #include <VBox/dbgf.h>26 #include "DBGFInternal.h"27 #include <VBox/vm.h>28 #include <VBox/pgm.h>29 #include <VBox/err.h>30 #include <VBox/log.h>31 #include <VBox/mm.h>32 33 #include "../Runtime/include/internal/ldrELF64.h"34 35 /*******************************************************************************36 * Defined Constants And Macros *37 *******************************************************************************/38 #ifdef DEBUG_ramshankar39 # undef Log40 # define Log LogRel41 #endif42 #define DBGFLOG_NAME "DGBFCoreWrite"43 44 /**45 * DBGFCOREDATA: Core data.46 */47 typedef struct48 {49 const char *pszDumpPath; /* File path to dump the core into. */50 } DBGFCOREDATA, *PDBGFCOREDATA;51 52 17 53 18 /* … … 75 40 */ 76 41 42 /******************************************************************************* 43 * Header Files * 44 *******************************************************************************/ 45 #define LOG_GROUP LOG_GROUP_DBGF 46 #include <iprt/param.h> 47 #include <iprt/file.h> 48 49 #include "DBGFInternal.h" 50 51 #include <VBox/cpum.h> 52 #include "CPUMInternal.h" 53 #include <VBox/dbgf.h> 54 #include <VBox/vm.h> 55 #include <VBox/pgm.h> 56 #include <VBox/err.h> 57 #include <VBox/log.h> 58 #include <VBox/mm.h> 59 60 #include "../Runtime/include/internal/ldrELF64.h" 61 62 /******************************************************************************* 63 * Defined Constants And Macros * 64 *******************************************************************************/ 65 #ifdef DEBUG_ramshankar 66 # undef Log 67 # define Log LogRel 68 #endif 69 #define DBGFLOG_NAME "DGBFCoreWrite" 70 71 static const int s_NoteAlign = 4; 72 73 /** 74 * DBGFCOREDATA: Core data. 75 */ 76 typedef struct 77 { 78 const char *pszDumpPath; /* File path to dump the core into. */ 79 } DBGFCOREDATA, *PDBGFCOREDATA; 80 81 typedef struct 82 { 83 Elf64_Nhdr Hdr; /* 64-bit NOTE Header */ 84 char achName[8]; /* Name of NOTE section */ 85 } ELFNOTEHDR; 86 87 77 88 /** 78 89 * ELF function to write 64-bit ELF header. … … 88 99 static int Elf64WriteElfHdr(RTFILE hFile, uint16_t cProgHdrs, uint16_t cSecHdrs, uint64_t *pcbElfHdr) 89 100 { 90 AssertCompile(sizeof(uint32_t) == 4);91 92 101 Elf64_Ehdr ElfHdr; 93 102 RT_ZERO(ElfHdr); … … 155 164 156 165 /** 166 * Returns the size of the NOTE section given the size of the data. 167 * 168 * @param cb Size of the data part of the NOTE. 169 * 170 * @return The size of the NOTE section as rounded to the file alignment. 171 */ 172 static inline int Elf64NoteSectionSize(uint64_t cb) 173 { 174 return sizeof(ELFNOTEHDR) + RT_ALIGN_64(cb, s_NoteAlign); 175 } 176 177 178 /** 157 179 * Elf function to write 64-bit note header. 158 180 * 159 181 * @param hFile The file to write to. 160 182 * @param Type Type of this section. 161 * @param pszName Name of this section, will be limited to 8bytes.183 * @param pszName Name of this section, will be limited to 16 bytes. 162 184 * @param pcv Opaque pointer to the data, if NULL only computes size. 163 185 * @param cb Size of the data. … … 167 189 * @return IPRT status code. 168 190 */ 169 static int Elf64WriteNoteH eader(RTFILE hFile, uint16_t Type, const char *pszName, const void *pcv, uint64_t cb, uint64_t *pcbNoteHdr)191 static int Elf64WriteNoteHdr(RTFILE hFile, uint16_t Type, const char *pszName, const void *pcv, uint64_t cb, uint64_t *pcbNoteHdr) 170 192 { 171 193 AssertReturn(pcv, VERR_INVALID_POINTER); 172 194 AssertReturn(cb > 0, VERR_NO_DATA); 173 195 174 typedef struct175 {176 Elf64_Nhdr Hdr; /* 64-bit NOTE Header */177 char achName[8]; /* Name of NOTE section */178 } ELFNOTEHDR;179 180 196 ELFNOTEHDR ElfNoteHdr; 181 197 RT_ZERO(ElfNoteHdr); 182 RTStrCopy(ElfNoteHdr.achName, sizeof(ElfNoteHdr.achName) - 1, pszName);183 ElfNoteHdr.Hdr.n_namesz = (Elf64_Word)strlen(ElfNoteHdr.achName) + 1;198 RTStrCopy(ElfNoteHdr.achName, sizeof(ElfNoteHdr.achName), pszName); 199 ElfNoteHdr.Hdr.n_namesz = (Elf64_Word)strlen(ElfNoteHdr.achName); 184 200 ElfNoteHdr.Hdr.n_type = Type; 185 186 static const char s_achPad[3] = { 0, 0, 0 }; 187 uint64_t cbAlign = RT_ALIGN_64(cb, 4); 188 ElfNoteHdr.Hdr.n_descsz = cbAlign; 201 size_t cbNameAlign = RT_ALIGN_Z(ElfNoteHdr.Hdr.n_namesz, 8); 202 203 static const char s_achPad[7] = { 0, 0, 0, 0, 0, 0, 0 }; 204 uint64_t cbAlign = RT_ALIGN_64(cb, s_NoteAlign); 205 ElfNoteHdr.Hdr.n_descsz = (Elf64_Word)cbAlign; 189 206 190 207 /* … … 194 211 if (RT_SUCCESS(rc)) 195 212 { 213 if (cbNameAlign > ElfNoteHdr.Hdr.n_namesz) 214 rc = RTFileWrite(hFile, s_achPad, cbNameAlign - ElfNoteHdr.Hdr.n_namesz, NULL); 215 196 216 rc = RTFileWrite(hFile, pcv, cb, NULL /* full write */); 197 217 if (RT_SUCCESS(rc)) … … 236 256 * 237 257 * @return VBox status code. 238 * @remarks The VM must be suspended before calling this function.239 258 */ 240 259 static DECLCALLBACK(VBOXSTRICTRC) dbgfR3CoreWrite(PVM pVM, PVMCPU pVCpu, void *pvData) … … 259 278 * Compute size of the note section. 260 279 */ 261 uint64_t cbNoteSection = pVM->cCpus * sizeof(CPUMCTX);280 uint64_t cbNoteSection = Elf64NoteSectionSize(pVM->cCpus * sizeof(CPUMCTX)); 262 281 uint64_t off = 0; 263 282 … … 336 355 if (RT_SUCCESS(rc)) 337 356 { 338 for (uint32_t i Cpu = 0; iCpu < pVM->cCpus; iCpu++)357 for (uint32_t i = 0; i < pVM->cCpus; i++) 339 358 { 340 /** @todo -XXX- cpus */ 359 PCPUMCTX pCpuCtx = &pVM->aCpus[i].cpum.s.Guest; 360 rc = Elf64WriteNoteHdr(hFile, NT_VBOXCPU, "VBOXCPU", pCpuCtx, sizeof(CPUMCTX), NULL /* pcbNoteHdr */); 361 if (RT_FAILURE(rc)) 362 { 363 LogRel((DBGFLOG_NAME ":Elf64WriteNoteHdr failed for vCPU[%u] rc=%Rrc\n", i, rc)); 364 break; 365 } 341 366 } 342 367 }
Note:
See TracChangeset
for help on using the changeset viewer.