@@ -28,13 +28,6 @@ func Core(coreFile, base string) (*Process, error) {
28
28
return nil , err
29
29
}
30
30
31
- // Double-check that we have complete data available for all mappings.
32
- for _ , m := range p .maps {
33
- if m .f == nil {
34
- return nil , fmt .Errorf ("incomplete mapping %x %x" , m .min , m .max )
35
- }
36
- }
37
-
38
31
// Sort then merge mappings, just to clean up a bit.
39
32
sort .Slice (p .maps , func (i , j int ) bool {
40
33
return p .maps [i ].min < p .maps [j ].min
@@ -56,6 +49,11 @@ func Core(coreFile, base string) (*Process, error) {
56
49
57
50
// Memory map all the mappings.
58
51
for _ , m := range maps {
52
+ if m .f == nil {
53
+ // Pretend this is read-as-zero.
54
+ m .contents = make ([]byte , m .max .Sub (m .min ))
55
+ continue
56
+ }
59
57
var err error
60
58
m .contents , err = syscall .Mmap (int (m .f .Fd ()), m .off , int (m .max .Sub (m .min )), syscall .PROT_READ , syscall .MAP_SHARED )
61
59
if err != nil {
@@ -151,9 +149,6 @@ func (p *Process) readLoad(f *os.File, e *elf.File, prog *elf.Prog) error {
151
149
}
152
150
if prog .Flags & elf .PF_W != 0 {
153
151
perm |= Write
154
- if prog .Filesz != prog .Memsz {
155
- return fmt .Errorf ("Data at address %x is not complete. The core has %x bytes, we need %x bytes" , min , prog .Filesz , prog .Memsz )
156
- }
157
152
}
158
153
if prog .Flags & elf .PF_X != 0 {
159
154
perm |= Exec
@@ -171,6 +166,7 @@ func (p *Process) readLoad(f *os.File, e *elf.File, prog *elf.Prog) error {
171
166
if prog .Filesz < uint64 (m .max .Sub (m .min )) {
172
167
// We only have partial data for this mapping in the core file.
173
168
// Trim the mapping and allocate an anonymous mapping for the remainder.
169
+ // The remainder will be read-as-zero.
174
170
m2 := & Mapping {min : m .min .Add (int64 (prog .Filesz )), max : m .max , perm : m .perm }
175
171
m .max = m2 .min
176
172
p .maps = append (p .maps , m2 )
@@ -247,10 +243,8 @@ func (p *Process) readNTFile(f *os.File, e *elf.File, desc []byte) error {
247
243
248
244
backing , err := os .Open (filepath .Join (p .base , name ))
249
245
if err != nil {
250
- // Can't find mapped file.
251
- // TODO: if we debug on a different machine,
252
- // provide a way to map from core's file spec to a real file.
253
- return fmt .Errorf ("can't open mapped file: %v\n " , err )
246
+ fmt .Fprintf (os .Stderr , "Missing data for addresses [%x %x] because of failure to %s. Assuming all zero.\n " , min , max , err )
247
+ // backing==nil means treat as all zero.
254
248
}
255
249
256
250
// TODO: this is O(n^2). Shouldn't be a big problem in practice.
@@ -294,7 +288,7 @@ func (p *Process) readNTFile(f *os.File, e *elf.File, desc []byte) error {
294
288
}
295
289
296
290
}
297
- if ! found {
291
+ if ! found && backing != nil {
298
292
p .exec = append (p .exec , m .f )
299
293
}
300
294
}
0 commit comments