SHOW:
|
|
- or go back to the newest paste.
| 1 | ======= script code start ======= | |
| 2 | ||
| 3 | %{
| |
| 4 | #include <stdlib.h> | |
| 5 | #include <sys/socket.h> | |
| 6 | %} | |
| 7 | ||
| 8 | function sockname:string(sock:long) | |
| 9 | %{
| |
| 10 | struct sockaddr *addr = (struct sockaddr *) malloc (sizeof (struct sockaddr)) | |
| 11 | if (addr != NULL) {
| |
| 12 | size_t *addrlen = sizeof (struct sockaddr) | |
| 13 | ||
| 14 | ret = getsockname (sock, addr, addrlen) | |
| 15 | if (ret < 0) {
| |
| 16 | print ("error\n")
| |
| 17 | } | |
| 18 | } | |
| 19 | %} | |
| 20 | ||
| 21 | probe syscall.connect.return {
| |
| 22 | if ($return >= 0) {
| |
| 23 | sockname ($return) | |
| 24 | } | |
| 25 | } | |
| 26 | ||
| 27 | ======= script code end ======= | |
| 28 | ||
| 29 | ======= run start ======= | |
| 30 | ||
| 31 | [root@rhel5-stap stps]# stap -g strace-connect.stp -c "curl www.google.com" | |
| 32 | Pass 4: compilation failed. Try again with another '--vp 0001' option. | |
| 33 | ||
| 34 | [root@rhel5-stap stps]# stap -g --vp 0001 strace-connect.stp -c "curl www.google.com" | |
| 35 | Pass 4: compiled C into "stap_b7800dfc97ca81afbd4921aaa452d856_6437.ko" in 740usr/190sys/932real ms. | |
| 36 | Pass 4: compilation failed. Try again with another '--vp 0001' option. | |
| 37 | ||
| 38 | - | ======= run end ======= |
| 38 | + | ======= run end ======= |
| 39 | ||
| 40 | ======= /tmp/stappA7iFn/stap_27428.c code start ======= | |
| 41 | ||
| 42 | #ifndef MAXNESTING | |
| 43 | #define MAXNESTING 10 | |
| 44 | #endif | |
| 45 | #ifndef MAXSTRINGLEN | |
| 46 | #define MAXSTRINGLEN 128 | |
| 47 | #endif | |
| 48 | #ifndef MAXACTION | |
| 49 | #define MAXACTION 1000 | |
| 50 | #endif | |
| 51 | #ifndef MAXACTION_INTERRUPTIBLE | |
| 52 | #define MAXACTION_INTERRUPTIBLE (MAXACTION * 10) | |
| 53 | #endif | |
| 54 | #ifndef MAXTRYLOCK | |
| 55 | #define MAXTRYLOCK MAXACTION | |
| 56 | #endif | |
| 57 | #ifndef TRYLOCKDELAY | |
| 58 | #define TRYLOCKDELAY 100 | |
| 59 | #endif | |
| 60 | #ifndef MAXMAPENTRIES | |
| 61 | #define MAXMAPENTRIES 2048 | |
| 62 | #endif | |
| 63 | #ifndef MAXERRORS | |
| 64 | #define MAXERRORS 0 | |
| 65 | #endif | |
| 66 | #ifndef MAXSKIPPED | |
| 67 | #define MAXSKIPPED 100 | |
| 68 | #endif | |
| 69 | #ifndef MINSTACKSPACE | |
| 70 | #define MINSTACKSPACE 1024 | |
| 71 | #endif | |
| 72 | #ifndef INTERRUPTIBLE | |
| 73 | #define INTERRUPTIBLE 1 | |
| 74 | #endif | |
| 75 | #ifndef STP_OVERLOAD_INTERVAL | |
| 76 | #define STP_OVERLOAD_INTERVAL 1000000000LL | |
| 77 | #endif | |
| 78 | #ifndef STP_OVERLOAD_THRESHOLD | |
| 79 | #define STP_OVERLOAD_THRESHOLD 500000000LL | |
| 80 | #endif | |
| 81 | #ifndef STP_NO_OVERLOAD | |
| 82 | #define STP_OVERLOAD | |
| 83 | #endif | |
| 84 | #define STP_SKIP_BADVARS 0 | |
| 85 | #include "runtime.h" | |
| 86 | #include "stack.c" | |
| 87 | #include "stat.c" | |
| 88 | #include <linux/string.h> | |
| 89 | #include <linux/timer.h> | |
| 90 | #include <linux/sched.h> | |
| 91 | #include <linux/delay.h> | |
| 92 | #include <linux/profile.h> | |
| 93 | #include <linux/random.h> | |
| 94 | #include <linux/vermagic.h> | |
| 95 | #include <linux/utsname.h> | |
| 96 | #include <linux/version.h> | |
| 97 | #include "loc2c-runtime.h" | |
| 98 | #ifndef read_trylock | |
| 99 | #define read_trylock(x) ({ read_lock(x); 1; })
| |
| 100 | #endif | |
| 101 | ||
| 102 | typedef char string_t[MAXSTRINGLEN]; | |
| 103 | ||
| 104 | #define STAP_SESSION_STARTING 0 | |
| 105 | #define STAP_SESSION_RUNNING 1 | |
| 106 | #define STAP_SESSION_ERROR 2 | |
| 107 | #define STAP_SESSION_STOPPING 3 | |
| 108 | #define STAP_SESSION_STOPPED 4 | |
| 109 | static atomic_t session_state = ATOMIC_INIT (STAP_SESSION_STARTING); | |
| 110 | static atomic_t error_count = ATOMIC_INIT (0); | |
| 111 | static atomic_t skipped_count = ATOMIC_INIT (0); | |
| 112 | static atomic_t skipped_count_lowstack = ATOMIC_INIT (0); | |
| 113 | static atomic_t skipped_count_reentrant = ATOMIC_INIT (0); | |
| 114 | static atomic_t skipped_count_uprobe_reg = ATOMIC_INIT (0); | |
| 115 | static atomic_t skipped_count_uprobe_unreg = ATOMIC_INIT (0); | |
| 116 | ||
| 117 | struct context {
| |
| 118 | atomic_t busy; | |
| 119 | const char *probe_point; | |
| 120 | int actionremaining; | |
| 121 | unsigned nesting; | |
| 122 | string_t error_buffer; | |
| 123 | const char *last_error; | |
| 124 | const char *last_stmt; | |
| 125 | struct pt_regs *regs; | |
| 126 | unsigned long *unwaddr; | |
| 127 | struct kretprobe_instance *pi; | |
| 128 | int regparm; | |
| 129 | va_list *mark_va_list; | |
| 130 | const char * marker_name; | |
| 131 | const char * marker_format; | |
| 132 | void *data; | |
| 133 | #ifdef STP_TIMING | |
| 134 | Stat *statp; | |
| 135 | #endif | |
| 136 | #ifdef STP_OVERLOAD | |
| 137 | cycles_t cycles_base; | |
| 138 | cycles_t cycles_sum; | |
| 139 | #endif | |
| 140 | union {
| |
| 141 | struct probe_1404_locals {
| |
| 142 | int64_t __tmp0; | |
| 143 | } probe_1404; | |
| 144 | struct function__dwarf_tvar_get_return_0_locals {
| |
| 145 | int64_t __retvalue; | |
| 146 | } function__dwarf_tvar_get_return_0; | |
| 147 | struct function_sockname_locals {
| |
| 148 | int64_t sock; | |
| 149 | string_t __retvalue; | |
| 150 | } function_sockname; | |
| 151 | } locals [MAXNESTING]; | |
| 152 | }; | |
| 153 | ||
| 154 | static void *contexts = NULL; /* alloc_percpu */ | |
| 155 | ||
| 156 | ||
| 157 | ||
| 158 | #include <stdlib.h> | |
| 159 | #include <sys/socket.h> | |
| 160 | ||
| 161 | ||
| 162 | ||
| 163 | #define N(a) [a]=#a | |
| 164 | ||
| 165 | static const char * const errlist[] = {
| |
| 166 | /* from asm-generic/errno-base.h */ | |
| 167 | [1] = "EPERM", | |
| 168 | [2] = "ENOENT", | |
| 169 | [3] = "ESRCH", | |
| 170 | [4] = "EINTR", | |
| 171 | [5] = "EIO", | |
| 172 | [6] = "ENXIO", | |
| 173 | [7] = "E2BIG", | |
| 174 | [8] = "ENOEXEC", | |
| 175 | [9] = "EBADF", | |
| 176 | [10]= "ECHILD", | |
| 177 | [11]= "EAGAIN", | |
| 178 | [12]= "ENOMEM", | |
| 179 | [13]= "EACCES", | |
| 180 | [14]= "EFAULT", | |
| 181 | [15]= "ENOTBLK", | |
| 182 | [16]= "EBUSY", | |
| 183 | [17]= "EEXIST", | |
| 184 | [18]= "EXDEV", | |
| 185 | [19]= "ENODEV", | |
| 186 | [20]= "ENOTDIR", | |
| 187 | [21]= "EISDIR", | |
| 188 | [22]= "EINVAL", | |
| 189 | [23]= "ENFILE", | |
| 190 | [24]= "EMFILE", | |
| 191 | [25]= "ENOTTY", | |
| 192 | [26]= "ETXTBSY", | |
| 193 | [27]= "EFBIG", | |
| 194 | [28]= "ENOSPC", | |
| 195 | [29]= "ESPIPE", | |
| 196 | [30]= "EROFS", | |
| 197 | [31]= "EMLINK", | |
| 198 | [32]= "EPIPE", | |
| 199 | [33]= "EDOM", | |
| 200 | [34]= "ERANGE", | |
| 201 | /* end of errno-base.h */ | |
| 202 | /* The rest of this is arch-dependent */ | |
| 203 | #ifdef EDEADLK | |
| 204 | N(EDEADLK), | |
| 205 | #endif | |
| 206 | #ifdef ENAMETOOLONG | |
| 207 | N(ENAMETOOLONG), | |
| 208 | #endif | |
| 209 | #ifdef ENOLCK | |
| 210 | N(ENOLCK), | |
| 211 | #endif | |
| 212 | #ifdef ENOSYS | |
| 213 | N(ENOSYS), | |
| 214 | #endif | |
| 215 | #ifdef ENOTEMPTY | |
| 216 | N(ENOTEMPTY), | |
| 217 | #endif | |
| 218 | #ifdef ELOOP | |
| 219 | N(ELOOP), | |
| 220 | #endif | |
| 221 | #ifdef ENOMSG | |
| 222 | N(ENOMSG), | |
| 223 | #endif | |
| 224 | #ifdef EIDRM | |
| 225 | N(EIDRM), | |
| 226 | #endif | |
| 227 | #ifdef ECHRNG | |
| 228 | N(ECHRNG), | |
| 229 | #endif | |
| 230 | #ifdef EL2NSYNC | |
| 231 | N(EL2NSYNC), | |
| 232 | #endif | |
| 233 | #ifdef EL3HLT | |
| 234 | N(EL3HLT), | |
| 235 | #endif | |
| 236 | #ifdef EL3RST | |
| 237 | N(EL3RST), | |
| 238 | #endif | |
| 239 | #ifdef ELNRNG | |
| 240 | N(ELNRNG), | |
| 241 | #endif | |
| 242 | #ifdef EUNATCH | |
| 243 | N(EUNATCH), | |
| 244 | #endif | |
| 245 | #ifdef ENOCSI | |
| 246 | N(ENOCSI), | |
| 247 | #endif | |
| 248 | #ifdef EL2HLT | |
| 249 | N(EL2HLT), | |
| 250 | #endif | |
| 251 | #ifdef EBADE | |
| 252 | N(EBADE), | |
| 253 | #endif | |
| 254 | #ifdef EBADR | |
| 255 | N(EBADR), | |
| 256 | #endif | |
| 257 | #ifdef EXFULL | |
| 258 | N(EXFULL), | |
| 259 | #endif | |
| 260 | #ifdef ENOANO | |
| 261 | N(ENOANO), | |
| 262 | #endif | |
| 263 | #ifdef EBADRQC | |
| 264 | N(EBADRQC), | |
| 265 | #endif | |
| 266 | #ifdef EBADSLT | |
| 267 | N(EBADSLT), | |
| 268 | #endif | |
| 269 | #ifdef EBFONT | |
| 270 | N(EBFONT), | |
| 271 | #endif | |
| 272 | #ifdef ENOSTR | |
| 273 | N(ENOSTR), | |
| 274 | #endif | |
| 275 | #ifdef ENODATA | |
| 276 | N(ENODATA), | |
| 277 | #endif | |
| 278 | #ifdef ETIME | |
| 279 | N(ETIME), | |
| 280 | #endif | |
| 281 | #ifdef ENOSR | |
| 282 | N(ENOSR), | |
| 283 | #endif | |
| 284 | #ifdef ENONET | |
| 285 | N(ENONET), | |
| 286 | #endif | |
| 287 | #ifdef ENOPKG | |
| 288 | N(ENOPKG), | |
| 289 | #endif | |
| 290 | #ifdef EREMOTE | |
| 291 | N(EREMOTE), | |
| 292 | #endif | |
| 293 | #ifdef ENOLINK | |
| 294 | N(ENOLINK), | |
| 295 | #endif | |
| 296 | #ifdef EADV | |
| 297 | N(EADV), | |
| 298 | #endif | |
| 299 | #ifdef ESRMNT | |
| 300 | N(ESRMNT), | |
| 301 | #endif | |
| 302 | #ifdef ECOMM | |
| 303 | N(ECOMM), | |
| 304 | #endif | |
| 305 | #ifdef EPROTO | |
| 306 | N(EPROTO), | |
| 307 | #endif | |
| 308 | #ifdef EMULTIHOP | |
| 309 | N(EMULTIHOP), | |
| 310 | #endif | |
| 311 | #ifdef EDOTDOT | |
| 312 | N(EDOTDOT), | |
| 313 | #endif | |
| 314 | #ifdef EBADMSG | |
| 315 | N(EBADMSG), | |
| 316 | #endif | |
| 317 | #ifdef EOVERFLOW | |
| 318 | N(EOVERFLOW), | |
| 319 | #endif | |
| 320 | #ifdef ENOTUNIQ | |
| 321 | N(ENOTUNIQ), | |
| 322 | #endif | |
| 323 | #ifdef EBADFD | |
| 324 | N(EBADFD), | |
| 325 | #endif | |
| 326 | #ifdef EREMCHG | |
| 327 | N(EREMCHG), | |
| 328 | #endif | |
| 329 | #ifdef ELIBACC | |
| 330 | N(ELIBACC), | |
| 331 | #endif | |
| 332 | #ifdef ELIBBAD | |
| 333 | N(ELIBBAD), | |
| 334 | #endif | |
| 335 | #ifdef ELIBSCN | |
| 336 | N(ELIBSCN), | |
| 337 | #endif | |
| 338 | #ifdef ELIBMAX | |
| 339 | N(ELIBMAX), | |
| 340 | #endif | |
| 341 | #ifdef ELIBEXEC | |
| 342 | N(ELIBEXEC), | |
| 343 | #endif | |
| 344 | #ifdef EILSEQ | |
| 345 | N(EILSEQ), | |
| 346 | #endif | |
| 347 | #ifdef ERESTART | |
| 348 | N(ERESTART), | |
| 349 | #endif | |
| 350 | #ifdef ESTRPIPE | |
| 351 | N(ESTRPIPE), | |
| 352 | #endif | |
| 353 | #ifdef EUSERS | |
| 354 | N(EUSERS), | |
| 355 | #endif | |
| 356 | #ifdef ENOTSOCK | |
| 357 | N(ENOTSOCK), | |
| 358 | #endif | |
| 359 | #ifdef EDESTADDRREQ | |
| 360 | N(EDESTADDRREQ), | |
| 361 | #endif | |
| 362 | #ifdef EMSGSIZE | |
| 363 | N(EMSGSIZE), | |
| 364 | #endif | |
| 365 | #ifdef EPROTOTYPE | |
| 366 | N(EPROTOTYPE), | |
| 367 | #endif | |
| 368 | #ifdef ENOPROTOOPT | |
| 369 | N(ENOPROTOOPT), | |
| 370 | #endif | |
| 371 | #ifdef EPROTONOSUPPORT | |
| 372 | N(EPROTONOSUPPORT), | |
| 373 | #endif | |
| 374 | #ifdef ESOCKTNOSUPPORT | |
| 375 | N(ESOCKTNOSUPPORT), | |
| 376 | #endif | |
| 377 | #ifdef EOPNOTSUPP | |
| 378 | N(EOPNOTSUPP), | |
| 379 | #endif | |
| 380 | #ifdef EPFNOSUPPORT | |
| 381 | N(EPFNOSUPPORT), | |
| 382 | #endif | |
| 383 | #ifdef EAFNOSUPPORT | |
| 384 | N(EAFNOSUPPORT), | |
| 385 | #endif | |
| 386 | #ifdef EADDRINUSE | |
| 387 | N(EADDRINUSE), | |
| 388 | #endif | |
| 389 | #ifdef EADDRNOTAVAIL | |
| 390 | N(EADDRNOTAVAIL), | |
| 391 | #endif | |
| 392 | #ifdef ENETDOWN | |
| 393 | N(ENETDOWN), | |
| 394 | #endif | |
| 395 | #ifdef ENETUNREACH | |
| 396 | N(ENETUNREACH), | |
| 397 | #endif | |
| 398 | #ifdef ENETRESET | |
| 399 | N(ENETRESET), | |
| 400 | #endif | |
| 401 | #ifdef ECONNABORTED | |
| 402 | N(ECONNABORTED), | |
| 403 | #endif | |
| 404 | #ifdef ECONNRESET | |
| 405 | N(ECONNRESET), | |
| 406 | #endif | |
| 407 | #ifdef ENOBUFS | |
| 408 | N(ENOBUFS), | |
| 409 | #endif | |
| 410 | #ifdef EISCONN | |
| 411 | N(EISCONN), | |
| 412 | #endif | |
| 413 | #ifdef ENOTCONN | |
| 414 | N(ENOTCONN), | |
| 415 | #endif | |
| 416 | #ifdef ESHUTDOWN | |
| 417 | N(ESHUTDOWN), | |
| 418 | #endif | |
| 419 | #ifdef ETOOMANYREFS | |
| 420 | N(ETOOMANYREFS), | |
| 421 | #endif | |
| 422 | #ifdef ETIMEDOUT | |
| 423 | N(ETIMEDOUT), | |
| 424 | #endif | |
| 425 | #ifdef ECONNREFUSED | |
| 426 | N(ECONNREFUSED), | |
| 427 | #endif | |
| 428 | #ifdef EHOSTDOWN | |
| 429 | N(EHOSTDOWN), | |
| 430 | #endif | |
| 431 | #ifdef EHOSTUNREACH | |
| 432 | N(EHOSTUNREACH), | |
| 433 | #endif | |
| 434 | #ifdef EALREADY | |
| 435 | N(EALREADY), | |
| 436 | #endif | |
| 437 | #ifdef EINPROGRESS | |
| 438 | N(EINPROGRESS), | |
| 439 | #endif | |
| 440 | #ifdef ESTALE | |
| 441 | N(ESTALE), | |
| 442 | #endif | |
| 443 | #ifdef EUCLEAN | |
| 444 | N(EUCLEAN), | |
| 445 | #endif | |
| 446 | #ifdef ENOTNAM | |
| 447 | N(ENOTNAM), | |
| 448 | #endif | |
| 449 | #ifdef ENAVAIL | |
| 450 | N(ENAVAIL), | |
| 451 | #endif | |
| 452 | #ifdef EISNAM | |
| 453 | N(EISNAM), | |
| 454 | #endif | |
| 455 | #ifdef EREMOTEIO | |
| 456 | N(EREMOTEIO), | |
| 457 | #endif | |
| 458 | #ifdef EDQUOT | |
| 459 | N(EDQUOT), | |
| 460 | #endif | |
| 461 | #ifdef ENOMEDIUM | |
| 462 | N(ENOMEDIUM), | |
| 463 | #endif | |
| 464 | #ifdef EMEDIUMTYPE | |
| 465 | N(EMEDIUMTYPE), | |
| 466 | #endif | |
| 467 | #ifdef ECANCELED | |
| 468 | N(ECANCELED), | |
| 469 | #endif | |
| 470 | #ifdef ENOKEY | |
| 471 | N(ENOKEY), | |
| 472 | #endif | |
| 473 | #ifdef EKEYEXPIRED | |
| 474 | N(EKEYEXPIRED), | |
| 475 | #endif | |
| 476 | #ifdef EKEYREVOKED | |
| 477 | N(EKEYREVOKED), | |
| 478 | #endif | |
| 479 | #ifdef EKEYREJECTED | |
| 480 | N(EKEYREJECTED), | |
| 481 | #endif | |
| 482 | #ifdef EOWNERDEAD | |
| 483 | N(EOWNERDEAD), | |
| 484 | #endif | |
| 485 | #ifdef ENOTRECOVERABLE | |
| 486 | N(ENOTRECOVERABLE), | |
| 487 | #endif | |
| 488 | #if defined (EDEADLOCK) && EDEADLOCK != EDEADLK | |
| 489 | N(EDEADLOCK), | |
| 490 | #endif | |
| 491 | #ifdef E | |
| 492 | N(EADV), | |
| 493 | #endif | |
| 494 | }; | |
| 495 | #undef N | |
| 496 | static const int Maxerrno = sizeof(errlist)/sizeof(char *); | |
| 497 | ||
| 498 | ||
| 499 | ||
| 500 | static long _stp_returnval(struct pt_regs *regs) {
| |
| 501 | if (regs) {
| |
| 502 | #if defined (STAPCONF_X86_UNIREGS) && (defined (__x86_64__) || defined (__i386__)) | |
| 503 | return regs->ax; | |
| 504 | #elif defined (__i386__) | |
| 505 | return regs->eax; | |
| 506 | #elif defined (__x86_64__) | |
| 507 | // TODO: Handle -m32 apps. | |
| 508 | return regs->rax; | |
| 509 | #elif defined (__powerpc64__) | |
| 510 | return regs->gpr[3]; | |
| 511 | #elif defined (__ia64__) | |
| 512 | return regs->r8; | |
| 513 | #elif defined (__sparc64__) | |
| 514 | return regs->u_regs[UREG_RETPC]; | |
| 515 | #elif defined (__s390x__) | |
| 516 | return regs->gprs[2]; | |
| 517 | #elif defined (__arm__) | |
| 518 | return regs->ARM_r0; | |
| 519 | #else | |
| 520 | _stp_error("returnval() not defined for this architecture");
| |
| 521 | return 0; | |
| 522 | #endif | |
| 523 | } else {
| |
| 524 | _stp_error("returnval() not defined in this context");
| |
| 525 | return 0; | |
| 526 | } | |
| 527 | } | |
| 528 | ||
| 529 | ||
| 530 | ||
| 531 | static void function__dwarf_tvar_get_return_0 (struct context * __restrict__ c); | |
| 532 | ||
| 533 | static void function_sockname (struct context * __restrict__ c); | |
| 534 | ||
| 535 | static void function__dwarf_tvar_get_return_0 (struct context* __restrict__ c) {
| |
| 536 | struct function__dwarf_tvar_get_return_0_locals * __restrict__ l = | |
| 537 | & c->locals[c->nesting+1].function__dwarf_tvar_get_return_0; | |
| 538 | (void) l; | |
| 539 | #define CONTEXT c | |
| 540 | #define THIS l | |
| 541 | if (0) goto out; | |
| 542 | c->last_stmt = "identifier '$return' at strace-connect.stp:20:6"; | |
| 543 | if (unlikely (c->nesting+2 >= MAXNESTING)) {
| |
| 544 | c->last_error = "MAXNESTING exceeded"; | |
| 545 | return; | |
| 546 | } else {
| |
| 547 | c->nesting ++; | |
| 548 | } | |
| 549 | l->__retvalue = 0; | |
| 550 | #define return goto out | |
| 551 | {
| |
| 552 | {
| |
| 553 | {
| |
| 554 | { int64_t value = fetch_register (0);THIS->__retvalue = value; }
| |
| 555 | } | |
| 556 | goto out; | |
| 557 | if (0) goto deref_fault; | |
| 558 | deref_fault: | |
| 559 | goto out; | |
| 560 | } | |
| 561 | /* pure */ | |
| 562 | } | |
| 563 | #undef return | |
| 564 | out: | |
| 565 | ; | |
| 566 | c->nesting --; | |
| 567 | #undef CONTEXT | |
| 568 | #undef THIS | |
| 569 | } | |
| 570 | ||
| 571 | ||
| 572 | static void function_sockname (struct context* __restrict__ c) {
| |
| 573 | struct function_sockname_locals * __restrict__ l = | |
| 574 | & c->locals[c->nesting+1].function_sockname; | |
| 575 | (void) l; | |
| 576 | #define CONTEXT c | |
| 577 | #define THIS l | |
| 578 | if (0) goto out; | |
| 579 | c->last_stmt = "identifier 'sockname' at strace-connect.stp:6:10"; | |
| 580 | if (unlikely (c->nesting+2 >= MAXNESTING)) {
| |
| 581 | c->last_error = "MAXNESTING exceeded"; | |
| 582 | return; | |
| 583 | } else {
| |
| 584 | c->nesting ++; | |
| 585 | } | |
| 586 | l->__retvalue[0] = '\0'; | |
| 587 | #define return goto out | |
| 588 | {
| |
| 589 | ||
| 590 | struct sockaddr *addr = (struct sockaddr *) malloc (sizeof (struct sockaddr)) | |
| 591 | if (addr != NULL) {
| |
| 592 | size_t *addrlen = sizeof (struct sockaddr) | |
| 593 | ||
| 594 | ret = getsockname (sock, addr, addrlen) | |
| 595 | if (ret < 0) {
| |
| 596 | print ("error\n")
| |
| 597 | } | |
| 598 | } | |
| 599 | ||
| 600 | } | |
| 601 | #undef return | |
| 602 | out: | |
| 603 | ; | |
| 604 | c->nesting --; | |
| 605 | #undef CONTEXT | |
| 606 | #undef THIS | |
| 607 | } | |
| 608 | ||
| 609 | ||
| 610 | #ifdef STP_TIMING | |
| 611 | static __cacheline_aligned Stat time_probe_0; | |
| 612 | #endif | |
| 613 | ||
| 614 | static void probe_1404 (struct context * __restrict__ c) {
| |
| 615 | struct probe_1404_locals * __restrict__ l = | |
| 616 | & c->locals[0].probe_1404; | |
| 617 | (void) l; | |
| 618 | #ifdef STP_TIMING | |
| 619 | c->statp = & time_probe_0; | |
| 620 | #endif | |
| 621 | bspcache(c->unwaddr, c->regs); | |
| 622 | {
| |
| 623 | unsigned numtrylock = 0; | |
| 624 | (void) numtrylock; | |
| 625 | if (0) goto unlock_; | |
| 626 | } | |
| 627 | c->actionremaining -= 1; | |
| 628 | if (unlikely (c->actionremaining <= 0)) {
| |
| 629 | c->last_error = "MAXACTION exceeded"; | |
| 630 | goto out; | |
| 631 | } | |
| 632 | if (((( | |
| 633 | ({
| |
| 634 | function__dwarf_tvar_get_return_0 (c); | |
| 635 | if (unlikely(c->last_error)) goto out; | |
| 636 | c->locals[c->nesting+1].function__dwarf_tvar_get_return_0.__retvalue; | |
| 637 | })) >= (((int64_t)0LL))))) {
| |
| 638 | (void) | |
| 639 | ({
| |
| 640 | l->__tmp0 = | |
| 641 | ({
| |
| 642 | function__dwarf_tvar_get_return_0 (c); | |
| 643 | if (unlikely(c->last_error)) goto out; | |
| 644 | c->locals[c->nesting+1].function__dwarf_tvar_get_return_0.__retvalue; | |
| 645 | }); | |
| 646 | c->locals[c->nesting+1].function_sockname.sock = l->__tmp0; | |
| 647 | function_sockname (c); | |
| 648 | if (unlikely(c->last_error)) goto out; | |
| 649 | c->locals[c->nesting+1].function_sockname.__retvalue; | |
| 650 | }); | |
| 651 | c->actionremaining -= 1; | |
| 652 | if (unlikely (c->actionremaining <= 0)) {
| |
| 653 | c->last_error = "MAXACTION exceeded"; | |
| 654 | goto out; | |
| 655 | } | |
| 656 | } | |
| 657 | out: | |
| 658 | _stp_print_flush(); | |
| 659 | unlock_: ; | |
| 660 | } | |
| 661 | ||
| 662 | ||
| 663 | /* ---- dwarf probes ---- */ | |
| 664 | #if ! defined(CONFIG_KPROBES) | |
| 665 | #error "Need CONFIG_KPROBES!" | |
| 666 | #endif | |
| 667 | ||
| 668 | static int enter_kprobe_probe (struct kprobe *inst, struct pt_regs *regs); | |
| 669 | static int enter_kretprobe_probe (struct kretprobe_instance *inst, struct pt_regs *regs); | |
| 670 | #if defined(STAPCONF_UNREGISTER_KPROBES) | |
| 671 | static void * stap_unreg_kprobes[1]; | |
| 672 | #endif | |
| 673 | static struct stap_dwarf_kprobe {
| |
| 674 | union { struct kprobe kp; struct kretprobe krp; } u;
| |
| 675 | #ifdef __ia64__ | |
| 676 | struct kprobe dummy; | |
| 677 | #endif | |
| 678 | } stap_dwarf_kprobes[1]; | |
| 679 | static struct stap_dwarf_probe {
| |
| 680 | const unsigned return_p:1; | |
| 681 | const unsigned maxactive_p:1; | |
| 682 | unsigned registered_p:1; | |
| 683 | const unsigned short maxactive_val; | |
| 684 | const char module[7]; | |
| 685 | const char section[7]; | |
| 686 | const char pp[61]; | |
| 687 | const unsigned long address; | |
| 688 | void (* const ph) (struct context*); | |
| 689 | } stap_dwarf_probes[] = {
| |
| 690 | { .return_p=1, .address=(unsigned long)0x21f094ULL, .module="kernel", .section="_stext", .pp="kernel.function(\"sys_connect@net/socket.c:1534\").return?", .ph=&probe_1404 },
| |
| 691 | }; | |
| 692 | ||
| 693 | static int enter_kprobe_probe (struct kprobe *inst, struct pt_regs *regs) {
| |
| 694 | int kprobe_idx = ((uintptr_t)inst-(uintptr_t)stap_dwarf_kprobes)/sizeof(struct stap_dwarf_kprobe); | |
| 695 | struct stap_dwarf_probe *sdp = &stap_dwarf_probes[((kprobe_idx >= 0 && kprobe_idx < 1)?kprobe_idx:0)]; | |
| 696 | struct context* __restrict__ c; | |
| 697 | #if !INTERRUPTIBLE | |
| 698 | unsigned long flags; | |
| 699 | #endif | |
| 700 | #if defined(STP_TIMING) || defined(STP_OVERLOAD) | |
| 701 | cycles_t cycles_atstart = get_cycles (); | |
| 702 | #endif | |
| 703 | #if INTERRUPTIBLE | |
| 704 | preempt_disable (); | |
| 705 | #else | |
| 706 | local_irq_save (flags); | |
| 707 | #endif | |
| 708 | if (unlikely ((((unsigned long) (& c)) & (THREAD_SIZE-1)) | |
| 709 | < (MINSTACKSPACE + sizeof (struct thread_info)))) {
| |
| 710 | atomic_inc (& skipped_count); | |
| 711 | #ifdef STP_TIMING | |
| 712 | atomic_inc (& skipped_count_lowstack); | |
| 713 | #endif | |
| 714 | goto probe_epilogue; | |
| 715 | } | |
| 716 | if (atomic_read (&session_state) != STAP_SESSION_RUNNING) | |
| 717 | goto probe_epilogue; | |
| 718 | c = per_cpu_ptr (contexts, smp_processor_id()); | |
| 719 | if (atomic_inc_return (& c->busy) != 1) {
| |
| 720 | #if !INTERRUPTIBLE | |
| 721 | atomic_inc (& skipped_count); | |
| 722 | #endif | |
| 723 | #ifdef STP_TIMING | |
| 724 | atomic_inc (& skipped_count_reentrant); | |
| 725 | #ifdef DEBUG_REENTRANCY | |
| 726 | _stp_warn ("Skipped %s due to %s residency on cpu %u\n", sdp->pp, c->probe_point ?: "?", smp_processor_id());
| |
| 727 | #endif | |
| 728 | #endif | |
| 729 | atomic_dec (& c->busy); | |
| 730 | goto probe_epilogue; | |
| 731 | } | |
| 732 | ||
| 733 | c->last_stmt = 0; | |
| 734 | c->last_error = 0; | |
| 735 | c->nesting = 0; | |
| 736 | c->regs = 0; | |
| 737 | c->unwaddr = 0; | |
| 738 | c->probe_point = sdp->pp; | |
| 739 | c->pi = 0; | |
| 740 | c->regparm = 0; | |
| 741 | c->marker_name = NULL; | |
| 742 | c->marker_format = NULL; | |
| 743 | #if INTERRUPTIBLE | |
| 744 | c->actionremaining = MAXACTION_INTERRUPTIBLE; | |
| 745 | #else | |
| 746 | c->actionremaining = MAXACTION; | |
| 747 | #endif | |
| 748 | #ifdef STP_TIMING | |
| 749 | c->statp = 0; | |
| 750 | #endif | |
| 751 | c->regs = regs; | |
| 752 | (*sdp->ph) (c); | |
| 753 | #if defined(STP_TIMING) || defined(STP_OVERLOAD) | |
| 754 | {
| |
| 755 | cycles_t cycles_atend = get_cycles (); | |
| 756 | int32_t cycles_elapsed = ((int32_t)cycles_atend > (int32_t)cycles_atstart) | |
| 757 | ? ((int32_t)cycles_atend - (int32_t)cycles_atstart) | |
| 758 | : (~(int32_t)0) - (int32_t)cycles_atstart + (int32_t)cycles_atend + 1; | |
| 759 | #ifdef STP_TIMING | |
| 760 | if (likely (c->statp)) _stp_stat_add(*c->statp, cycles_elapsed); | |
| 761 | #endif | |
| 762 | #ifdef STP_OVERLOAD | |
| 763 | {
| |
| 764 | cycles_t interval = (cycles_atend > c->cycles_base) | |
| 765 | ? (cycles_atend - c->cycles_base) | |
| 766 | : (STP_OVERLOAD_INTERVAL + 1); | |
| 767 | c->cycles_sum += cycles_elapsed; | |
| 768 | if (interval > STP_OVERLOAD_INTERVAL) {
| |
| 769 | if (c->cycles_sum > STP_OVERLOAD_THRESHOLD) {
| |
| 770 | _stp_error ("probe overhead exceeded threshold");
| |
| 771 | atomic_set (&session_state, STAP_SESSION_ERROR); | |
| 772 | atomic_inc (&error_count); | |
| 773 | } | |
| 774 | c->cycles_base = cycles_atend; | |
| 775 | c->cycles_sum = 0; | |
| 776 | } | |
| 777 | } | |
| 778 | #endif | |
| 779 | } | |
| 780 | #endif | |
| 781 | c->probe_point = 0; | |
| 782 | if (unlikely (c->last_error && c->last_error[0])) {
| |
| 783 | if (c->last_stmt != NULL) | |
| 784 | _stp_softerror ("%s near %s", c->last_error, c->last_stmt);
| |
| 785 | else | |
| 786 | _stp_softerror ("%s", c->last_error);
| |
| 787 | atomic_inc (& error_count); | |
| 788 | if (atomic_read (& error_count) > MAXERRORS) {
| |
| 789 | atomic_set (& session_state, STAP_SESSION_ERROR); | |
| 790 | _stp_exit (); | |
| 791 | } | |
| 792 | } | |
| 793 | atomic_dec (&c->busy); | |
| 794 | probe_epilogue: | |
| 795 | if (unlikely (atomic_read (& skipped_count) > MAXSKIPPED)) {
| |
| 796 | atomic_set (& session_state, STAP_SESSION_ERROR); | |
| 797 | _stp_exit (); | |
| 798 | } | |
| 799 | #if INTERRUPTIBLE | |
| 800 | preempt_enable_no_resched (); | |
| 801 | #else | |
| 802 | local_irq_restore (flags); | |
| 803 | #endif | |
| 804 | return 0; | |
| 805 | } | |
| 806 | ||
| 807 | static int enter_kretprobe_probe (struct kretprobe_instance *inst, struct pt_regs *regs) {
| |
| 808 | struct kretprobe *krp = inst->rp; | |
| 809 | int kprobe_idx = ((uintptr_t)krp-(uintptr_t)stap_dwarf_kprobes)/sizeof(struct stap_dwarf_kprobe); | |
| 810 | struct stap_dwarf_probe *sdp = &stap_dwarf_probes[((kprobe_idx >= 0 && kprobe_idx < 1)?kprobe_idx:0)]; | |
| 811 | struct context* __restrict__ c; | |
| 812 | #if !INTERRUPTIBLE | |
| 813 | unsigned long flags; | |
| 814 | #endif | |
| 815 | #if defined(STP_TIMING) || defined(STP_OVERLOAD) | |
| 816 | cycles_t cycles_atstart = get_cycles (); | |
| 817 | #endif | |
| 818 | #if INTERRUPTIBLE | |
| 819 | preempt_disable (); | |
| 820 | #else | |
| 821 | local_irq_save (flags); | |
| 822 | #endif | |
| 823 | if (unlikely ((((unsigned long) (& c)) & (THREAD_SIZE-1)) | |
| 824 | < (MINSTACKSPACE + sizeof (struct thread_info)))) {
| |
| 825 | atomic_inc (& skipped_count); | |
| 826 | #ifdef STP_TIMING | |
| 827 | atomic_inc (& skipped_count_lowstack); | |
| 828 | #endif | |
| 829 | goto probe_epilogue; | |
| 830 | } | |
| 831 | if (atomic_read (&session_state) != STAP_SESSION_RUNNING) | |
| 832 | goto probe_epilogue; | |
| 833 | c = per_cpu_ptr (contexts, smp_processor_id()); | |
| 834 | if (atomic_inc_return (& c->busy) != 1) {
| |
| 835 | #if !INTERRUPTIBLE | |
| 836 | atomic_inc (& skipped_count); | |
| 837 | #endif | |
| 838 | #ifdef STP_TIMING | |
| 839 | atomic_inc (& skipped_count_reentrant); | |
| 840 | #ifdef DEBUG_REENTRANCY | |
| 841 | _stp_warn ("Skipped %s due to %s residency on cpu %u\n", sdp->pp, c->probe_point ?: "?", smp_processor_id());
| |
| 842 | #endif | |
| 843 | #endif | |
| 844 | atomic_dec (& c->busy); | |
| 845 | goto probe_epilogue; | |
| 846 | } | |
| 847 | ||
| 848 | c->last_stmt = 0; | |
| 849 | c->last_error = 0; | |
| 850 | c->nesting = 0; | |
| 851 | c->regs = 0; | |
| 852 | c->unwaddr = 0; | |
| 853 | c->probe_point = sdp->pp; | |
| 854 | c->pi = 0; | |
| 855 | c->regparm = 0; | |
| 856 | c->marker_name = NULL; | |
| 857 | c->marker_format = NULL; | |
| 858 | #if INTERRUPTIBLE | |
| 859 | c->actionremaining = MAXACTION_INTERRUPTIBLE; | |
| 860 | #else | |
| 861 | c->actionremaining = MAXACTION; | |
| 862 | #endif | |
| 863 | #ifdef STP_TIMING | |
| 864 | c->statp = 0; | |
| 865 | #endif | |
| 866 | c->regs = regs; | |
| 867 | c->pi = inst; | |
| 868 | (*sdp->ph) (c); | |
| 869 | #if defined(STP_TIMING) || defined(STP_OVERLOAD) | |
| 870 | {
| |
| 871 | cycles_t cycles_atend = get_cycles (); | |
| 872 | int32_t cycles_elapsed = ((int32_t)cycles_atend > (int32_t)cycles_atstart) | |
| 873 | ? ((int32_t)cycles_atend - (int32_t)cycles_atstart) | |
| 874 | : (~(int32_t)0) - (int32_t)cycles_atstart + (int32_t)cycles_atend + 1; | |
| 875 | #ifdef STP_TIMING | |
| 876 | if (likely (c->statp)) _stp_stat_add(*c->statp, cycles_elapsed); | |
| 877 | #endif | |
| 878 | #ifdef STP_OVERLOAD | |
| 879 | {
| |
| 880 | cycles_t interval = (cycles_atend > c->cycles_base) | |
| 881 | ? (cycles_atend - c->cycles_base) | |
| 882 | : (STP_OVERLOAD_INTERVAL + 1); | |
| 883 | c->cycles_sum += cycles_elapsed; | |
| 884 | if (interval > STP_OVERLOAD_INTERVAL) {
| |
| 885 | if (c->cycles_sum > STP_OVERLOAD_THRESHOLD) {
| |
| 886 | _stp_error ("probe overhead exceeded threshold");
| |
| 887 | atomic_set (&session_state, STAP_SESSION_ERROR); | |
| 888 | atomic_inc (&error_count); | |
| 889 | } | |
| 890 | c->cycles_base = cycles_atend; | |
| 891 | c->cycles_sum = 0; | |
| 892 | } | |
| 893 | } | |
| 894 | #endif | |
| 895 | } | |
| 896 | #endif | |
| 897 | c->probe_point = 0; | |
| 898 | if (unlikely (c->last_error && c->last_error[0])) {
| |
| 899 | if (c->last_stmt != NULL) | |
| 900 | _stp_softerror ("%s near %s", c->last_error, c->last_stmt);
| |
| 901 | else | |
| 902 | _stp_softerror ("%s", c->last_error);
| |
| 903 | atomic_inc (& error_count); | |
| 904 | if (atomic_read (& error_count) > MAXERRORS) {
| |
| 905 | atomic_set (& session_state, STAP_SESSION_ERROR); | |
| 906 | _stp_exit (); | |
| 907 | } | |
| 908 | } | |
| 909 | atomic_dec (&c->busy); | |
| 910 | probe_epilogue: | |
| 911 | if (unlikely (atomic_read (& skipped_count) > MAXSKIPPED)) {
| |
| 912 | atomic_set (& session_state, STAP_SESSION_ERROR); | |
| 913 | _stp_exit (); | |
| 914 | } | |
| 915 | #if INTERRUPTIBLE | |
| 916 | preempt_enable_no_resched (); | |
| 917 | #else | |
| 918 | local_irq_restore (flags); | |
| 919 | #endif | |
| 920 | return 0; | |
| 921 | } | |
| 922 | ||
| 923 | static int systemtap_module_init (void) {
| |
| 924 | int rc = 0; | |
| 925 | int i=0, j=0; | |
| 926 | const char *probe_point = ""; | |
| 927 | {
| |
| 928 | const char* release = UTS_RELEASE; | |
| 929 | if (strcmp (release, "2.6.18-164.el5")) {
| |
| 930 | _stp_error ("module release mismatch (%s vs %s)", release, "2.6.18-164.el5");
| |
| 931 | rc = -EINVAL; | |
| 932 | } | |
| 933 | if (_stp_module_check()) rc = -EINVAL; | |
| 934 | } | |
| 935 | if (rc) goto out; | |
| 936 | (void) probe_point; | |
| 937 | (void) i; | |
| 938 | (void) j; | |
| 939 | atomic_set (&session_state, STAP_SESSION_STARTING); | |
| 940 | if (sizeof (struct context) <= 131072) | |
| 941 | contexts = alloc_percpu (struct context); | |
| 942 | if (contexts == NULL) {
| |
| 943 | _stp_error ("percpu context (size %lu) allocation failed", sizeof (struct context));
| |
| 944 | rc = -ENOMEM; | |
| 945 | goto out; | |
| 946 | } | |
| 947 | #ifdef STP_TIMING | |
| 948 | time_probe_0 = _stp_stat_init (HIST_NONE); | |
| 949 | #endif | |
| 950 | _stp_print_kernel_info("0.9.7/0.141", (num_online_cpus() * sizeof(struct context)), 1);
| |
| 951 | for (i=0; i<1; i++) {
| |
| 952 | struct stap_dwarf_probe *sdp = & stap_dwarf_probes[i]; | |
| 953 | struct stap_dwarf_kprobe *kp = & stap_dwarf_kprobes[i]; | |
| 954 | unsigned long relocated_addr = _stp_module_relocate (sdp->module, sdp->section, sdp->address); | |
| 955 | if (relocated_addr == 0) continue; | |
| 956 | probe_point = sdp->pp; | |
| 957 | if (sdp->return_p) {
| |
| 958 | kp->u.krp.kp.addr = (void *) relocated_addr; | |
| 959 | if (sdp->maxactive_p) {
| |
| 960 | kp->u.krp.maxactive = sdp->maxactive_val; | |
| 961 | } else {
| |
| 962 | kp->u.krp.maxactive = max(10, 4*NR_CPUS); | |
| 963 | } | |
| 964 | kp->u.krp.handler = &enter_kretprobe_probe; | |
| 965 | #ifdef __ia64__ | |
| 966 | kp->dummy.addr = kp->u.krp.kp.addr; | |
| 967 | kp->dummy.pre_handler = NULL; | |
| 968 | rc = register_kprobe (& kp->dummy); | |
| 969 | if (rc == 0) {
| |
| 970 | rc = register_kretprobe (& kp->u.krp); | |
| 971 | if (rc != 0) | |
| 972 | unregister_kprobe (& kp->dummy); | |
| 973 | } | |
| 974 | #else | |
| 975 | rc = register_kretprobe (& kp->u.krp); | |
| 976 | #endif | |
| 977 | } else {
| |
| 978 | kp->u.kp.addr = (void *) relocated_addr; | |
| 979 | kp->u.kp.pre_handler = &enter_kprobe_probe; | |
| 980 | #ifdef __ia64__ | |
| 981 | kp->dummy.addr = kp->u.kp.addr; | |
| 982 | kp->dummy.pre_handler = NULL; | |
| 983 | rc = register_kprobe (& kp->dummy); | |
| 984 | if (rc == 0) {
| |
| 985 | rc = register_kprobe (& kp->u.kp); | |
| 986 | if (rc != 0) | |
| 987 | unregister_kprobe (& kp->dummy); | |
| 988 | } | |
| 989 | #else | |
| 990 | rc = register_kprobe (& kp->u.kp); | |
| 991 | #endif | |
| 992 | } | |
| 993 | if (rc) {
| |
| 994 | sdp->registered_p = 0; | |
| 995 | _stp_warn ("probe %s registration error (rc %d)", probe_point, rc);
| |
| 996 | rc = 0; | |
| 997 | } | |
| 998 | else sdp->registered_p = 1; | |
| 999 | } | |
| 1000 | if (rc) {
| |
| 1001 | _stp_error ("probe %s registration error (rc %d)", probe_point, rc);
| |
| 1002 | atomic_set (&session_state, STAP_SESSION_ERROR); | |
| 1003 | goto out; | |
| 1004 | } | |
| 1005 | if (atomic_read (&session_state) == STAP_SESSION_STARTING) | |
| 1006 | atomic_set (&session_state, STAP_SESSION_RUNNING); | |
| 1007 | return 0; | |
| 1008 | out: | |
| 1009 | #ifdef STAPCONF_SYNCHRONIZE_SCHED | |
| 1010 | synchronize_sched(); | |
| 1011 | #endif | |
| 1012 | return rc; | |
| 1013 | } | |
| 1014 | ||
| 1015 | ||
| 1016 | static void systemtap_module_exit (void) {
| |
| 1017 | int holdon; | |
| 1018 | int i=0, j=0; | |
| 1019 | (void) i; | |
| 1020 | (void) j; | |
| 1021 | if (atomic_read (&session_state) == STAP_SESSION_STARTING) | |
| 1022 | return; | |
| 1023 | if (atomic_read (&session_state) == STAP_SESSION_RUNNING) | |
| 1024 | atomic_set (&session_state, STAP_SESSION_STOPPING); | |
| 1025 | #if defined(STAPCONF_UNREGISTER_KPROBES) | |
| 1026 | j = 0; | |
| 1027 | for (i=0; i<1; i++) {
| |
| 1028 | struct stap_dwarf_probe *sdp = & stap_dwarf_probes[i]; | |
| 1029 | struct stap_dwarf_kprobe *kp = & stap_dwarf_kprobes[i]; | |
| 1030 | if (! sdp->registered_p) continue; | |
| 1031 | if (!sdp->return_p) | |
| 1032 | stap_unreg_kprobes[j++] = &kp->u.kp; | |
| 1033 | } | |
| 1034 | unregister_kprobes((struct kprobe **)stap_unreg_kprobes, j); | |
| 1035 | j = 0; | |
| 1036 | for (i=0; i<1; i++) {
| |
| 1037 | struct stap_dwarf_probe *sdp = & stap_dwarf_probes[i]; | |
| 1038 | struct stap_dwarf_kprobe *kp = & stap_dwarf_kprobes[i]; | |
| 1039 | if (! sdp->registered_p) continue; | |
| 1040 | if (sdp->return_p) | |
| 1041 | stap_unreg_kprobes[j++] = &kp->u.krp; | |
| 1042 | } | |
| 1043 | unregister_kretprobes((struct kretprobe **)stap_unreg_kprobes, j); | |
| 1044 | #ifdef __ia64__ | |
| 1045 | j = 0; | |
| 1046 | for (i=0; i<1; i++) {
| |
| 1047 | struct stap_dwarf_probe *sdp = & stap_dwarf_probes[i]; | |
| 1048 | struct stap_dwarf_kprobe *kp = & stap_dwarf_kprobes[i]; | |
| 1049 | if (! sdp->registered_p) continue; | |
| 1050 | stap_unreg_kprobes[j++] = &kp->dummy; | |
| 1051 | } | |
| 1052 | unregister_kprobes((struct kprobe **)stap_unreg_kprobes, j); | |
| 1053 | #endif | |
| 1054 | #endif | |
| 1055 | for (i=0; i<1; i++) {
| |
| 1056 | struct stap_dwarf_probe *sdp = & stap_dwarf_probes[i]; | |
| 1057 | struct stap_dwarf_kprobe *kp = & stap_dwarf_kprobes[i]; | |
| 1058 | if (! sdp->registered_p) continue; | |
| 1059 | if (sdp->return_p) {
| |
| 1060 | #if !defined(STAPCONF_UNREGISTER_KPROBES) | |
| 1061 | unregister_kretprobe (&kp->u.krp); | |
| 1062 | #endif | |
| 1063 | atomic_add (kp->u.krp.nmissed, & skipped_count); | |
| 1064 | #ifdef STP_TIMING | |
| 1065 | if (kp->u.krp.nmissed) | |
| 1066 | _stp_warn ("Skipped due to missed kretprobe/1 on '%s': %d\n", sdp->pp, kp->u.krp.nmissed);
| |
| 1067 | #endif | |
| 1068 | atomic_add (kp->u.krp.kp.nmissed, & skipped_count); | |
| 1069 | #ifdef STP_TIMING | |
| 1070 | if (kp->u.krp.kp.nmissed) | |
| 1071 | _stp_warn ("Skipped due to missed kretprobe/2 on '%s': %d\n", sdp->pp, kp->u.krp.kp.nmissed);
| |
| 1072 | #endif | |
| 1073 | } else {
| |
| 1074 | #if !defined(STAPCONF_UNREGISTER_KPROBES) | |
| 1075 | unregister_kprobe (&kp->u.kp); | |
| 1076 | #endif | |
| 1077 | atomic_add (kp->u.kp.nmissed, & skipped_count); | |
| 1078 | #ifdef STP_TIMING | |
| 1079 | if (kp->u.kp.nmissed) | |
| 1080 | _stp_warn ("Skipped due to missed kprobe on '%s': %d\n", sdp->pp, kp->u.kp.nmissed);
| |
| 1081 | #endif | |
| 1082 | } | |
| 1083 | #if !defined(STAPCONF_UNREGISTER_KPROBES) && defined(__ia64__) | |
| 1084 | unregister_kprobe (&kp->dummy); | |
| 1085 | #endif | |
| 1086 | sdp->registered_p = 0; | |
| 1087 | } | |
| 1088 | #ifdef STAPCONF_SYNCHRONIZE_SCHED | |
| 1089 | synchronize_sched(); | |
| 1090 | #endif | |
| 1091 | do {
| |
| 1092 | int i; | |
| 1093 | holdon = 0; | |
| 1094 | for (i=0; i < NR_CPUS; i++) | |
| 1095 | if (cpu_possible (i) && atomic_read (& ((struct context *)per_cpu_ptr(contexts, i))->busy)) holdon = 1; | |
| 1096 | yield (); | |
| 1097 | } while (holdon); | |
| 1098 | #ifdef STAPCONF_SYNCHRONIZE_SCHED | |
| 1099 | synchronize_sched(); | |
| 1100 | #endif | |
| 1101 | free_percpu (contexts); | |
| 1102 | #ifdef STP_TIMING | |
| 1103 | {
| |
| 1104 | if (likely (time_probe_0)) {
| |
| 1105 | const char *probe_point = "syscall.connect.return"; | |
| 1106 | const char *decl_location = "strace-connect.stp:19:1"; | |
| 1107 | struct stat_data *stats = _stp_stat_get (time_probe_0, 0); | |
| 1108 | if (stats->count) {
| |
| 1109 | int64_t avg = _stp_div64 (NULL, stats->sum, stats->count); | |
| 1110 | _stp_printf ("probe %s (%s), hits: %lld, cycles: %lldmin/%lldavg/%lldmax\n",
| |
| 1111 | probe_point, decl_location, (long long) stats->count, (long long) stats->min, (long long) avg, (long long) stats->max); | |
| 1112 | } | |
| 1113 | _stp_stat_del (time_probe_0); | |
| 1114 | } | |
| 1115 | _stp_print_flush(); | |
| 1116 | } | |
| 1117 | #endif | |
| 1118 | if (atomic_read (& skipped_count) || atomic_read (& error_count) || atomic_read (& skipped_count_reentrant)) {
| |
| 1119 | _stp_warn ("Number of errors: %d, skipped probes: %d\n", (int) atomic_read (& error_count), (int) atomic_read (& skipped_count));
| |
| 1120 | #ifdef STP_TIMING | |
| 1121 | {
| |
| 1122 | int ctr; | |
| 1123 | ctr = atomic_read (& skipped_count_lowstack); | |
| 1124 | if (ctr) _stp_warn ("Skipped due to low stack: %d\n", ctr);
| |
| 1125 | ctr = atomic_read (& skipped_count_reentrant); | |
| 1126 | if (ctr) _stp_warn ("Skipped due to reentrancy: %d\n", ctr);
| |
| 1127 | ctr = atomic_read (& skipped_count_uprobe_reg); | |
| 1128 | if (ctr) _stp_warn ("Skipped due to uprobe register failure: %d\n", ctr);
| |
| 1129 | ctr = atomic_read (& skipped_count_uprobe_unreg); | |
| 1130 | if (ctr) _stp_warn ("Skipped due to uprobe unregister failure: %d\n", ctr);
| |
| 1131 | } | |
| 1132 | #endif | |
| 1133 | _stp_print_flush(); | |
| 1134 | } | |
| 1135 | } | |
| 1136 | ||
| 1137 | ||
| 1138 | static int probe_start (void) {
| |
| 1139 | return systemtap_module_init () ? -1 : 0; | |
| 1140 | } | |
| 1141 | ||
| 1142 | static void probe_exit (void) {
| |
| 1143 | systemtap_module_exit (); | |
| 1144 | } | |
| 1145 | #include "stap-symbols.h" | |
| 1146 | MODULE_DESCRIPTION("systemtap-generated probe");
| |
| 1147 | MODULE_LICENSE("GPL");
| |
| 1148 | ||
| 1149 | ======= /tmp/stappA7iFn/stap_27428.c code end ======= |